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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:45:55+00:00 2026-05-15T16:45:55+00:00

I’m writing a web app which is used a SaS. Each customer has their

  • 0

I’m writing a web app which is used a SaS. Each customer has their own db and app directory so I have a rake task which creates all necessary minimum data (seed data) to run their website: default rights and roles, a superadmin user, a “us_states” table already populated, some local depots and terminals (it’s a logistics app).

I don’t have any cucumber scenarios for it and I just started building some. I’m a beginner with cucumber.

I first put that seed data task in a Given line, but that is pretty much is a given for all scenarios, and it doesn’t make much sense to non-programmers who look at the scenarios (for humans, it is such a given that it doesn’t need to be expressed consciously) so I moved it into hooks.rb.

My first scenario looks like this:

  1 Feature: Place an order
  2   In order to keep orders in the database
  3   As a admin
  4   I want to place orders
  5
  6 Scenario: Using common legs
  7   Given I have 1 customers
  8   And I'm on the homepage
  9   And I follow "Place an Order"
 10   When I select the customer
 11   And I select the SSLine
 12   And I click "Use Common Legs"
 13   Then I should see "PICKUP AT"
 14   And I should see "DELIVER TO" or "LOAD AT"
 15   And I should see EMPTY RETURN

My hooks.rb looks like this:

1 Before do
2   MinimumData.new('costi', '1234').populate  #username and password
3 end

Questions:

  1. I don’t want to run this MinimumData.populate task before each scenario because it takes 8 seconds. Should I make it run just once, globally? How?
  2. Do I have to cleanup the database with an After.do? I really don’t want to do that, because I will duplicate the logic in the After.do, only with Model.delete_all statements. I noticed that after my first run, the test db has all that data still in. I can purge it with rake db:test:purge and the reinitialize it. Is that a good practice?
  • 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-15T16:45:56+00:00Added an answer on May 15, 2026 at 4:45 pm

    I don’t know of a before(:all) equivalent in cucumber. What you could do is add your seed to a file say features/support/seeds.rb and then at the top of your features/support/env.rb and below the line that requires your environment.rb put the line:

    require File.dirname(__FILE__) + '/seeds'
    

    or alternatively

    #just write the code you want to execute directly into the env.rb file
    

    These are your available blocks to add in the env.rb

    Before do
      #this code is run before each scenario
    end
    
    after do
      #this code is run after each scenario
    end
    
    at_exit do
      #this code is run at the end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.