0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Ruby Hanamiでguard-rspecを使うときのGuardfileの参考例

Posted at

これで良さそう

directories(%w[apps lib config spec].select { |d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist") })

guard :rspec, cmd: 'bundle exec rspec -c -fd' do
  require 'guard/rspec/dsl'
  dsl = Guard::RSpec::Dsl.new(self)

  # RSpec files
  rspec = dsl.rspec
  watch(rspec.spec_helper) { rspec.spec_dir }
  watch(rspec.spec_support) { rspec.spec_dir }
  watch(rspec.spec_files)

  # Hanami files
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
  watch(%r{^apps/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
  watch(%r{^apps/(.+)/controllers/(.+)\.rb$}) { |m| "spec/requests/#{m[1]}/#{m[2]}_spec.rb" }
end

想定動作

  • apps, lib 以下のファイルを変更したときに対応するspecが実行される
  • specs/requestsにはAPIのE2Eテストを配置する想定、controllersに変更があった場合に対応するunitテストと一緒に実行される

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?