Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why won't my features specs run in RSpec?

In my Rails 4 app, I'm using Rspec for testing. My directory structure is

spec
-- controllers
-- factories
-- features
-- spec_helper.rb
-- support

When I run rspec spec, it runs my tests in controllers, but not in features. I can specify rspec spec/features and they'll run, but I want to be able to run all tests under spec at once. My guess is it's not looking in features because of a configuration setting, but I don't know where this is.

I've tried different incantations of starting rspec but haven't had any luck.

like image 403
JennyDanger Avatar asked Dec 02 '13 02:12

JennyDanger


People also ask

How do I run a specific file in RSpec?

To run a single Rspec test file, you can do: rspec spec/models/your_spec. rb to run the tests in the your_spec. rb file.

What are feature specs?

Feature specs, a kind of acceptance test, are high-level tests that walk through your entire application ensuring that each of the components work together. They're written from the perspective of a user clicking around the application and filling in forms.

How do I use RSpec gems?

Boot up your terminal and punch in gem install rspec to install RSpec. Once that's done, you can verify your version of RSpec with rspec --version , which will output the current version of each of the packaged gems. Take a minute also to hit rspec --help and look through the various options available. That's it.


1 Answers

Based on your feedback to the comments above, the issue is one of file naming. I've definitely been burned by that before too. By default Rspec will go through the files looking for ones ending with _spec.rb, this default behaviour is overridden if you specify the folder manually.

like image 57
muttonlamb Avatar answered Oct 11 '22 15:10

muttonlamb