Skip to content
Browse files

Expressing Expectations: Now you can use either single or double quotes

  • Loading branch information...
1 parent 1378141 commit 931b952e27642d6bbcb6d9a467bc1045e96472c1 @antonymarcano antonymarcano committed Jul 3, 2011
View
2 Examples/Calculator/features/lib/default/tasks/arithmetic/calculate.rb
@@ -1,4 +1,4 @@
in_order_to "Calculate", with_the_following: :calculation do
- see_how_to_do Calculations
+ see_how_to Calculations
follow_the_steps_for the( :calculation ).split(" ")
end
View
39 features/expressing_expectations.feature
@@ -0,0 +1,39 @@
+Feature: Expressing expectations
+ As a Step Free Cuker
+ You want to express expectations
+ So that you know whether your scenario has passed
+
+ Background:
+ Given you are a Step Free Cuker
+ And you were able to create a file, at 'features/roles/role_with_answers.rb' containing
+ """
+ module RoleWithAnswers
+ def see_the_answer
+ get_the_answer_from_the_application
+ end
+
+ def get_the_answer_from_the_application
+ # Pretending to get the answer from the application
+ return 'correct answer'
+ end
+ end
+ """
+ And you were able to create a task, called 'see the answer is' containing
+ """
+ in_order_to 'see the answer is' do
+ see_the_answer
+ end
+ """
+
+ Scenario Outline: Simple Expectation
+ When you attempt to run a scenario, containing
+ """
+ Given I am a Role With Answers
+ Then I should see the answer is <answer>
+ """
+ Then you should see it has 'passed'
+
+ Examples:
+ | answer |
+ | 'correct answer' |
+ | "correct answer" |
View
6 features/prepare_the_actor_for_the_role.feature
@@ -3,11 +3,9 @@ Feature: Prepare the actor for the role
You want the role to initialize some things
So that you can define the things that the role always does at the start
- Background:
- Given you are a Step Free Cuker
-
Scenario: Initialization
- Given you were able to create a file, at 'features/roles/role_with_prep.rb' containing
+ Given you are a Step Free Cuker
+ And you were able to create a file, at 'features/roles/role_with_prep.rb' containing
"""
module RoleWithPrep
def role_preparation
View
1 lib/cukesalad/actor.rb
@@ -30,6 +30,7 @@ def get_ready_to_perform something
def see_how_to_do something
extend something
end
+ alias :see_how_to :see_how_to_do
def role_preparation
# Does nothing unless you override it from your role
View
6 lib/cukesalad/cucumber_steps.rb
@@ -26,7 +26,11 @@ def in_order_to(do_something, *with_attributes, &actions)
@actor.answer( this_question ).to_s.should == expect_value
end
-Then /^(?:I|you) should ([^':]+)$/ do | this_question |
+Then /^(?:I|you) should ([^':]*)(?: "([^"]*)")$/ do | this_question, expect_value |
+ @actor.answer( this_question ).to_s.should == expect_value
+end
+
+Then /^(?:I|you) should ([^'^":]+)$/ do | this_question |
@actor.answer( this_question )
end

0 comments on commit 931b952

Please sign in to comment.
Something went wrong with that request. Please try again.