Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Volute.apply() for application on-demand
Volute.apply(object, attribute=nil, previous_value=nil, value=nil)
- Loading branch information
Showing
6 changed files
with
118 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
require File.join(File.dirname(__FILE__), 'spec_helper.rb') | ||
|
||
|
||
class Engine | ||
attr_accessor :state | ||
|
||
def turn_key! | ||
@key_turned = true | ||
Volute.apply(self, :key_turned) | ||
end | ||
|
||
def press_red_button! | ||
Volute.apply(self) | ||
end | ||
end | ||
|
||
|
||
describe 'Volute.apply' do | ||
|
||
before(:each) do | ||
|
||
Volute.clear! | ||
|
||
volute Engine do | ||
if attribute == :key_turned | ||
object.state = :running | ||
else | ||
object.state = :off | ||
end | ||
end | ||
|
||
@engine = Engine.new | ||
|
||
volute Package do | ||
volute do | ||
over if object.delivered | ||
end | ||
volute :location do | ||
(object.comment ||= []) << value | ||
end | ||
end | ||
end | ||
|
||
it 'should apply volutes' do | ||
|
||
@engine.turn_key! | ||
|
||
@engine.state.should == :running | ||
end | ||
end | ||
|
This file contains 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 characters