Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RSpec integration test example being run twice

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.

Versions

Rails (3.2.2) RSpec (2.8.0) RSpec-rails (2.8.1)

like image 300
delphiniccoder Avatar asked Dec 02 '25 19:12

delphiniccoder


1 Answers

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.

like image 133
delphiniccoder Avatar answered Dec 05 '25 09:12

delphiniccoder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!