Forked from RiverGlide/dynamic_role_switching_spec.rb
Created
March 19, 2011 02:22
Revisions
-
James Martin revised this gist
Mar 19, 2011 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ module Butler def self.included base base.instance_eval { @place = [] } end def put_fork_on_the_left @@ -53,7 +53,6 @@ class MyActor #Todo: decide how we will make the actor know in which role they should perform the task def initialize role extend role end def perform task -
RiverGlide revised this gist
Mar 18, 2011 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -35,15 +35,15 @@ def place_boil_in_bag_into_pot end module MakeDinner def follow_instructions turn_on_stove boil_water place_boil_in_bag_into_pot end end module LayTable def follow_instructions put_fork_on_the_left put_knife_on_the_right end @@ -58,7 +58,7 @@ def initialize role def perform task recall_how_to_do task follow_instructions end private -
RiverGlide revised this gist
Mar 18, 2011 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,7 +19,7 @@ def put_knife_on_the_right end module Cook #Todo: Do something similar here def boil_water @@ -50,7 +50,7 @@ def instructions end class MyActor #Todo: decide how we will make the actor know in which role they should perform the task def initialize role extend role @place = [] #figure out how to initialize this in the role -
RiverGlide created this gist
Mar 18, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,77 @@ $:.unshift(File.dirname(__FILE__), ".") require 'spec_helper' module Butler def self.included base base.send :attr_accessor, :place end def put_fork_on_the_left @place.unshift "fork" @place end def put_knife_on_the_right @place.push "knife" @place end end module Cook #Do something similar here def boil_water end def turn_on_stove end def place_boil_in_bag_into_pot end end module MakeDinner def instructions turn_on_stove boil_water place_boil_in_bag_into_pot end end module LayTable def instructions put_fork_on_the_left put_knife_on_the_right end end class MyActor #decide how we will make the actor know in which role they should perform the task def initialize role extend role @place = [] #figure out how to initialize this in the role end def perform task recall_how_to_do task instructions end private def recall_how_to_do something extend something end end describe "Something" do it "Something" do butler = MyActor.new Butler butler.perform(LayTable).should == ["fork","knife"] end end