Skip to content

Instantly share code, notes, and snippets.

@stevenharman
Created December 2, 2011 22:21
Show Gist options
  • Select an option

  • Save stevenharman/1425103 to your computer and use it in GitHub Desktop.

Select an option

Save stevenharman/1425103 to your computer and use it in GitHub Desktop.
Using Capybara 1.1.2, "session#has_text?" doesn't exist?
require 'spec_helper'
# spec/acceptance/thing_spec.rb
feature "Viewing a thing" do
let(:thing) { Factory.create(:thing, name: "I'm a thing!") }
scenario "show a summary of the thing" do
visit thing_path(thing)
page.should have_text "I'm a thing!"
end
end
# Failures:
#
# 1) Viewing a thing show a summary of the thing
# Failure/Error: page.should have_text "I'm a thing!"
# NoMethodError:
# undefined method `has_text?' for #<Capybara::Session>
@stevenharman
Copy link
Copy Markdown
Author

Figured it out. Capybara::Session#has_text? hasn't yet been released. For now I'm just going right to GitHub gem 'capybara', git: 'https://github.com/jnicklas/capybara.git'

@joshuaflanagan
Copy link
Copy Markdown

If you want to stick with capybara 1.1.2 (latest release, for now), use #has_content? instead. It is mostly the same, but will also successfully match on text which isn't visible.

page.should have_content "I'm a thing!"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment