How can I get Rspec to run all tests nested under a folder?

后端 未结 2 1901
北荒
北荒 2021-02-05 01:40

I like to run my Rspec tests with Spork running in a separate tab. I usually run my tests using rspec spec, by which I intend to say \"search recursively and run ev

相关标签:
2条回答
  • 2021-02-05 01:48

    Rspec should already look recursively through the directory you named and find all tests. Note however, that it's looking for files ending in _spec.rb. Maybe some of your files are not named correctly?

    If you need to be more specific about which files it should find, you can also use the --pattern option. For example: rspec --pattern spec/requests/*_spec.rb. (Option --pattern is equal to -P. Taken from rspec --help)

    0 讨论(0)
  • 2021-02-05 01:49

    you can create a rake task

    desc "Run PCMag tests"
      RSpec::Core::RakeTask.new('test') do |t|
      t.rspec_opts = ["-Ilib","--format documentation","--color"]
      t.pattern = ['spec/test/*.rb']
    end
    

    Then execute command rake test.

    Above command will execute all .rb tests under folder 'test'

    Please check following link for more details.

    http://testautomationarchives.blogspot.in/2013/10/rspec-rake-framework-in-ruby-with.html

    0 讨论(0)
提交回复
热议问题