Odkazy:
Testovací nástroj v kterém píšeme testovací scénáře.
project_root/
|
`-- features
|-- awesomeness.feature
|-- greatest_ever.feature
`-- support
|-- env.rb
`-- other_helpers.rb
|-- step_definitions
| |-- domain_concept_A.rb
| `-- domain_concept_B.rb
STEP: Given a widget
Definition:
Given /^a widget$/ do
# codes go here
endPříklad 35.3. features/manage_my_wishes.feature
Feature: manage my wishes
In order to get more stuff
As a greedy person
I want to manage my wish list for my family memebers to view
Scenario: add wish
Given I am logged in
When I make a "New car" wish
Then "New car" should appear on my wish list$ cucumber features/manage_my_wishes.feature:77 je řádek scénáře
cucumber some.feature --language en-lol
Příklad 35.4. features/setp_definitions/user_steps.rb
Given /^I am logged in$/ do
@current_user = create_user(:email_confirmed => true)
visit new_session_path
fill_in "Email", :with => @current_user.email
fill_in "Password", :with => valid_user_attributes["password"]
click_button
# make sure we have actually logged in- so we fail fast if not
#-- session[:user_id].should == @current_user.id
#-- controller.current_user.should == @current_user
endFixture Replacement, Fixjour, Factory Girl, etc
Příklad 35.5. spec/fixjour_builders.rb
Fixjour do
define_builder(User) do |klass, overrides|
klass.new(
:email => "user#{counter(:user)}@email.com",
:password => 'password',
:password_confirmation => 'password'
)
end
end$gem install thoughtbot-clearance$./script generate clearance$./script generate clearance_features
Tables
Step tables
Scenario: view members list
Given the following wishes exist
| Wish | Family Memeber |
| Laptop | Thomas |
| Nintendo Wii | Candace |
| CHEEZBURGER | FuzzBuzz |
When I view the wish list for "Candace"
Then I Should see the following wishes
| Wish |
| Nintendo Wii |