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 8511013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:52:08+00:00 2026-06-11T03:52:08+00:00

I am trying to use both Capybara and Cucumber in my Rails application. So,

  • 0

I am trying to use both Capybara and Cucumber in my Rails application. So, that’s what i did:

  • Installed gems needed and added them to the Gemfile
  • Ran the rails generate capybara:install --cucumber
  • Created a feature and its steps definitions for cucumber

Here’s my feature (yeah, i am creating blog application):

Feature: Browse posts
    So that I can browse through the posts
    As a visitor
    I want to see all and/or particular posts

    Scenario: Viewing all the posts
        Given Posts exist
        When I navigate to the website home
        Then I should see all the posts

    Scenario: Viewing particular post
        Given Post #1 exists
        When I navigate to /posts/view/1
        Then I should see the post with id=1

And here’s its step definitions:

Given /^Posts exist$/ do
    assert (not Post.all.empty?), "No posts found at all"
end

Given /^Post #(\d+) exists$) do |id|
    assert Post.find_by_id(id).valid?, "Post ##{ id } was not found at all"
end

When /^I navigate to (.+)$/ do |url|
    if url =~ /^the website home$/ then
        visit '/'
    else
        visit url
    end
end

Then /^I should see all(.+)posts$/ do |delimiter|
    posts = Post.all

    posts.each do |post|
        page.should have_content post.title
    end
end

Then /^I should see the post with id([^\d]{1,})(\d+)$/ do |delimiter, id|
    post = Post.find_by_id id

    page.should have_content post.title
end

And when running rake cucumber i get this message:

Then I should see all the posts     # features/step_definitions/browsing_posts.rb:13
  undefined method `should' for #<Capybara::Session> (NoMethodError)
  ./features/step_definitions/browsing_posts.rb:17:in `block (2 levels) in <top (required)>'
  ./features/step_definitions/browsing_posts.rb:16:in `each'
  ./features/step_definitions/browsing_posts.rb:16:in `/^I should see all(.+)posts$/'
  features/browsing_posts.feature:9:in `Then I should see all the posts'

What am I doing wrong? And yeah, are there any mistakes in my feature?

  • 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-06-11T03:52:09+00:00Added an answer on June 11, 2026 at 3:52 am

    Replace page.should have_content post.title with assert page.has_content?(post.title). If that works, apply that similarly to the other have_content statements

    Edit: Those statements involving should are based on rspec expectations, and should be used only if you are already using rspec or some other testing framework that responds_to should. Coming from the test::unit angle, this is probably just another kind of assert.

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

Sidebar

Related Questions

I'm trying to use jQuery to find the number of divs that are both
I am trying to use both client_side_validations and devise in my Rails app, and
In Rails 2.3.6 I'm trying to use both MongoDb via MongoMapper and Mysql on
I'm trying to set up rails to use both the ID and the Handle
I'm trying to use construction injection using both Jersey-injected @Context parameters and Guice-injected parameters.
I'm trying to use mezzanine's overextends tag to both override and extends the existing
I'm trying to use an open-source project. Both the latest official (from a *.tar.gz
I am trying use gem tire to search in my application. I have tables
I am trying to use both mysqli_real_escape_string and trim together before making a MySQL
This is my first time trying to use both ARC and Core Data. I

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.