Skip to content
Browse files

Initializing the actor: Roles with role_preparation initialize themse…

…lves
  • Loading branch information...
1 parent 8bd5f5e commit 0de053a9e4494a9002c020609cbaf31cd9a953b3 @antonymarcano antonymarcano committed Jul 3, 2011
Showing with 37 additions and 1 deletion.
  1. +31 −0 features/prepare_the_actor_for_the_role.feature
  2. +6 −1 lib/cukesalad/actor.rb
View
31 features/prepare_the_actor_for_the_role.feature
@@ -0,0 +1,31 @@
+Feature: Prepare the actor for the role
+ As a Step Free Cuker
+ 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
+ And you were able to create a new Cuke Salad project
+
+ Scenario: Initialization
+ Given you were able to create a file, at 'features/roles/role_with_prep.rb' containing
+ """
+ module RoleWithPrep
+ def role_preparation
+ take_note_of :something, 'important'
+ end
+ end
+ """
+ And you were able to create a task, called 'recall something' containing
+ """
+ in_order_to 'recall something' do
+ recall :something
+ end
+ """
+ When you attempt to run a scenario, containing
+ """
+ Given I am a Role With Prep
+ Then I should recall something 'important'
+ """
+ Then you should see it has 'passed'
+
View
7 lib/cukesalad/actor.rb
@@ -5,8 +5,8 @@ class Actor
def initialize this_type_of_role, directed_by=Director.new
@director = directed_by
- get_into_character_for this_type_of_role
@note_pad = {}
+ get_into_character_for this_type_of_role
end
def perform described_task, details = {}
@@ -28,6 +28,11 @@ def get_ready_to_perform something
def see_how_to_do something
extend something
+ role_preparation
+ end
+
+ def role_preparation
+ # Does nothing unless you override it from your role
end
def value_of(symbol)

0 comments on commit 0de053a

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