Reputation: 71
I have recently started using RSpec for Integration testing in my Rails application, to avoid having to keep up to date with multiple testing frameworks, and am in the process of converting my Cucumber features to RSpec.
I have successfully got 1 integration test running, however, it appears to run through the example twice:
rspec spec/integration/create_article_spec.rb -f documentation
admin creates article
successfully creates article
admin creates article
successfully creates article
Finished in 0.51816 seconds
2 examples, 0 failures
Here is the contents of create_article_spec.rb:
require 'spec_helper'
feature "admin creates article" do
scenario "successfully creates article" do
visit admin_articles_url
click_link "New Article"
fill_in "Title", with: "Test 1"
fill_in "Body", with: "Test Article"
click_button "Save"
page.should have_content "New Article Published"
end
end
I can't find any reason why this may be happening, and all the other situations where this has happened don't apply in my case.
It only appears to happen with my Integration tests, all other tests do not appear to be affected.
I'm hoping someone with more RSpec knowledge than I can figure out where I may be missing something.
Rails (3.2.2) RSpec (2.8.0) RSpec-rails (2.8.1)
Upvotes: 3
Views: 1803
Reputation: 71
I realised that I had a line in my spec_helper.rb file including all the files in my integration tests folder, so they were in fact being loaded twice. I removed that line and it solved my issue.
Upvotes: 4
Reputation: 10898
Did you upgrade from a previous version of rspec? If so (and check even if you didn't) you may have a superfluous lib/tasks/rspec.rake
script. If you do, delete that file and re-run your tests. You should then see that they only execute once.
Upvotes: 1