1
votes

I have used RSpec and Capybara with Rails for both unit and integration (feature) testing for a few years and I've grown used to a certain workflow based on the behavior of the combined apps. However, I've just started a brand-new Rails application and the behavior has either changed or I have set up something wrong. I am using Ruby on Rails 4.2.1, RSpec core 3.2.3, Rspec rails 3.2.1 and Capybara 2.4.4. All of these are the most recent versions as of this writing. I have tried using the require 'capybara-rails' and require 'capybara-rspec' lines as indicated in the Capybara docs and I've tried not using the requires at all. Here is a simple feature spec (located in spec/features as required): require 'rails_helper'

feature 'Viewing the list of people', type: :feature do
  scenario 'returns a message if there are no people records' do
    visit root_url

    click_link 'People'

    expect(current_path).to eq(people_path)
    expect(page).to have_text('There are no people matching your request.')
  end
end

When I first run the spec in an empty app, I get the error that there is no root_url which is as expected. However, when I set up the route as route to: 'home#index', the next error that I see is "Unable to find link 'People'. Normally, I would see an error for the missing controller and then for the missing template before this error would appear. When I do create the home controller and index.html file and then run the spec again, I get the error "Unable to find the text "There are no people...". I receive no errors about the lack of people_path or the missing People controller or the template file. When I add resources :people to the routes.rb, the spec passes even though I still have not created a People controller or an index template, so there is nowhere that either Capybara or RSpec could be reading the expected string except in the spec itself. The errors are appearing as usual in the browser - I see all of the expected messages if I browser-check each step. Is anyone else experiencing this problem? It completely ruins my workflow of "follow the messages" to make sure all of the MVC components are in place and then dropping down to unit tests for the implementation details.

1

1 Answers

0
votes

Upgraded to rspec-rails 3.2.3 (released 6/6/15), making no other changes and the issue has disappeared. For verification, I set up another Rails app with rspec-rails 3.2.1 and the issue replicated. Upon upgrading that app to rspec-rails 3.2.3, it disappeared. I think it is safe to say that whatever caused the issue has been fixed. I haven't had the time to look over the commits yet, so I do not know how it was done.