Note that there are some explanatory texts on larger screens.

plurals
  1. POBroken controller tests after installing Capybara?
    primarykey
    data
    text
    <p>I had a bunch of combined controller/view tests written with rspec. I added the Capybara gem and wrote some integrations tests which pass fine. The only problem is that now in all my controller tests, where I have </p> <p>response.should have_selector("some selector")</p> <p>rspec gives errors such as:</p> <pre><code>NoMethodError: undefined method `has_selector?' for #&lt;ActionController::TestResponse:0xa03e7ec&gt; </code></pre> <p>when I run controller tests. I'm guessing that Capybara is being used in my controller tests and has overwritten some Rspec methods. How can I fix this?</p> <pre><code># gemfile.rb group :test do gem 'rspec' gem "capybara" gem "launchy" gem 'factory_girl_rails', '1.0' end # spec_helper.rb RSpec.configure do |config| config.include IntegrationSpecHelper, :type =&gt; :request end </code></pre> <p>Here's an example of a failing test:</p> <pre><code># spec/controllers/books_controller_spec.rb require 'spec_helper' describe BooksController do render_views it "should have the right page title" do get :show, :id =&gt; @book.ean response.should have_selector("title", :content =&gt; "Lexicase | " + @book.title) end end </code></pre> <p>and it's associated error:</p> <pre><code> 1) BooksController GET 'show' should have the right page title Failure/Error: response.should have_selector("title", :content =&gt; "Lexicase | " + @book.title) NoMethodError: undefined method `has_selector?' for #&lt;ActionController::TestResponse:0xa8488c0&gt; # ./spec/controllers/books_controller_spec.rb:23:in `block (3 levels) in &lt;top (required)&gt;' </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload