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:
Preparing data in your application for testing is called “seeding.” For example, if you have a test that creates a report, you need dummy data to display. Or, if you want testers to log in, you need test accounts with login credentials.
Enable Cucumber support in Rails applicationsIn the Setup Cucumber Support dialog, choose the test framework for Cucumber, specify the required options, and click OK. RubyMine will run the cucumber:install generator that sets up Cucumber in your Rails project and generates necessary files in the features directory.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With