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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:42:08+00:00 2026-05-24T16:42:08+00:00

As best I can tell cucumber is only hitting the database once between these

  • 0

As best I can tell cucumber is only hitting the database once between these two scenarios, but it’s clearing out the database between scenarios.

The Features:

Feature: a new user vists the site and signs up
    in order to get new users
    when an unlogged in users comes to the website
    then they should see the sign-up dialog
    and be able to signup for the website 

    Background:
        Given I have at least one deal

    Scenario: a new user is asked to signup
        Given I am on show deal
        Then I should see "New Here?"

    @javascript
    Scenario: new user signup failure
        Given I am on show deal
        When I fill in "consumer[user_attributes][email]" with "test@test.com"
        And I press "consumer_submit"
        Then I should see "1 error prohibited"

The Step Definition:

Given /^I have at least one deal$/ do
  Deal.create copy:'Example Deal Copy', copy_header:'Example Deal Header', copy_subheader:'Example Deal Subheader' if Deal.all.size == 0
end

The Result:

Background:                      # features/new_user_signup.feature:7
    Given I have at least one deal # features/step_definitions/new_user_signup_steps.rb:1

  Scenario: a new user is asked to signup # features/new_user_signup.feature:10
    Given I am on show deal               # features/step_definitions/web_steps.rb:44
    Then I should see "New Here?"         # features/step_definitions/web_steps.rb:105

  @javascript
  Scenario: new user signup failure                                        # features/new_user_signup.feature:15
    Given I am on show deal                                                # features/step_definitions/web_steps.rb:44
      Couldn't find Deal with ID=1 (ActiveRecord::RecordNotFound)
      ./app/controllers/deals_controller.rb:17:in `show'
      <internal:prelude>:10:in `synchronize'
      ./features/step_definitions/web_steps.rb:45:in `/^(?:|I )am on (.+)$/'
      features/new_user_signup.feature:16:in `Given I am on show deal'
    When I fill in "consumer[user_attributes][email]" with "test@test.com" # features/step_definitions/web_steps.rb:60
    And I press "consumer_submit"                                          # features/step_definitions/web_steps.rb:52
    Then I should see "1 error prohibited"                                 # features/step_definitions/web_steps.rb:105

Failing Scenarios:
cucumber features/new_user_signup.feature:15 # Scenario: new user signup failure

Whichever scenario I put second will give the ActiveRecord error. Why are there no records in the database for my second scenario?

  • 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-24T16:42:09+00:00Added an answer on May 24, 2026 at 4:42 pm

    Now I know how you’ve mapped “show deal” I am tempted to say that the problem is that the Deal instance possibly exists but it’s id is not equal 1. Can you check please?

    And here is a tip: while you’re defining paths in your path.rb, you may do something like this:

    when /the edit deal page/
    edit_deal_path(Deal.first)
    

    or even this:

    when /the deal page for deal named ".*"/
            deal_name = page_name.scan(/".*"/).first.gsub("\"", '') 
            deal = Deal.find_by_name(deal_name)
            deal_path(deal)
    

    As long as you’ve defined your “I am on” webstep like this:

    Given /^(?:|I )am on (.+)$/ do |page_name|
      visit path_to(page_name)
    end
    

    It’s far better than “deals/1” 🙂

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

Sidebar

Related Questions

I tried to follow this example from Microsoft, best I can tell I did
Someone can tell me the best way, through a web Java application, how to
Between the following test frameworks which one is the easiest to use and learn?
Did the usual google searches and can't seem to find any explanation of when
I'm interested in switching from Capistrano to Chef, but am having a few issues
I'm rolling my own ActivatableCollection<T> for db4o but cribbing heavily from the builtin ActivatableList<T>
There is some precedent for search-engine-ranking-related questions on StackOverflow, so please don't close this
I've got a desktop browser app which uses a WebView to host a Flash
I am new to both openGL and android development so please forgive me if
We're in the middle of re-designing our. We decided to put the home page

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.