Skip to content

Commit

Permalink
Initializing the actor: Roles with role_preparation initialize themse…
Browse files Browse the repository at this point in the history
…lves
  • Loading branch information
antonymarcano committed Jul 3, 2011
1 parent 8bd5f5e commit 0de053a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
31 changes: 31 additions & 0 deletions 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'

7 changes: 6 additions & 1 deletion lib/cukesalad/actor.rb
Expand Up @@ -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 = {}
Expand All @@ -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)
Expand Down

0 comments on commit 0de053a

Please sign in to comment.