Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7022669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:36:43+00:00 2026-05-27T23:36:43+00:00

I can’t make Capybara to work successfully, it complains that has_text is an undefined

  • 0

I can’t make Capybara to work successfully, it complains that has_text is an undefined method.

I have created a new rails 3.1 project (rails new test -T).

Gemfile:

source 'http://rubygems.org'

gem 'rails', '3.1.3'

gem 'sqlite3'

group :assets do
  gem 'sass-rails',   '~> 3.1.5'
  gem 'coffee-rails', '~> 3.1.1'
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

group :test do
  gem 'rspec-rails'
  gem 'capybara'
end

I have installed the spec folder: rails g rspec:install.

spec/spec_helper.rb:

ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rspec'

Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}

RSpec.configure do |config|
  config.mock_with :rspec
  config.fixture_path = "#{::Rails.root}/spec/fixtures"
  config.use_transactional_fixtures = true
  config.infer_base_class_for_anonymous_controllers = false
end

And finally my test file:

require 'spec_helper'

feature "the test" do
  scenario "GET /" do
    visit('/')
    page.should have_text('Welcome aboard')
  end
end

So I launch rspec: bundle exec rspec spec/my_test.rb and this is the error:

F

Failures:

  1) the test GET /
     Failure/Error: page.should have_text('Welcome aboard')
     NoMethodError:
       undefined method `has_text?' for #<Capybara::Session>
     # ./spec/my_test.rb:6:in `block (2 levels) in <top (required)>'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:36:44+00:00Added an answer on May 27, 2026 at 11:36 pm

    Most likely you’re using capybara 1.1.2 that is the current stable version, but it doesn’t have has_text? method. You can either use has_content? (and corresponding have_content matcher) instead or use capybara directly from github repository as Skydreamer suggested.

    Note that has_content? has a bit different behaviour as described in README. On the other hand using gem directly from repository is not always safe as this version might be not very stable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can't work out a way to make an array of buttons in android. This
Can somebody point me to a resource that explains how to go about having
Can a LINQ enabled app run on a machine that only has the .NET
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't
Can't figure out how to do this in a pretty way : I have
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Can some one Guide me to work with these things... What is Model popup
can anyone tell me why this doesn't work? db = openOrCreateDatabase(database.db, SQLiteDatabase.CREATE_IF_NECESSARY, null); db.setLocale(Locale.getDefault());
Can anyone help me with an excel formula that groups related rows and creates

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.