diff options
| author | Luke Kanies <luke@madstop.com> | 2008-07-04 15:35:18 -0500 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2008-07-04 15:35:18 -0500 |
| commit | 2863df288150da87a58ce4d938bbcf9a5d841f43 (patch) | |
| tree | 571c8de49b1133655551f6a43dd7f4ec39d28e30 /spec/unit | |
| parent | a37a7845073ef0b0923549364cbac5e0e39e3194 (diff) | |
| download | puppet-2863df288150da87a58ce4d938bbcf9a5d841f43.tar.gz puppet-2863df288150da87a58ce4d938bbcf9a5d841f43.tar.xz puppet-2863df288150da87a58ce4d938bbcf9a5d841f43.zip | |
Refactoring the Transaction::Event class.
The class had a 'transaction' accessor that was assigned
but never used, and it is simple enough that it needed
direct arguments rather than named arguments.
The rest of the code is changing the other classes that use
Events.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit')
| -rwxr-xr-x | spec/unit/other/pgraph.rb | 4 | ||||
| -rwxr-xr-x | spec/unit/transaction/change.rb | 2 | ||||
| -rwxr-xr-x | spec/unit/transaction/event.rb | 26 |
3 files changed, 10 insertions, 22 deletions
diff --git a/spec/unit/other/pgraph.rb b/spec/unit/other/pgraph.rb index 25d99b921..cad0832a5 100755 --- a/spec/unit/other/pgraph.rb +++ b/spec/unit/other/pgraph.rb @@ -47,8 +47,8 @@ end describe Puppet::PGraph, " when matching edges" do before do @graph = Puppet::PGraph.new - @event = Puppet::Transaction::Event.new(:source => "a", :event => :yay) - @none = Puppet::Transaction::Event.new(:source => "a", :event => :NONE) + @event = Puppet::Transaction::Event.new(:yay, "a") + @none = Puppet::Transaction::Event.new(:NONE, "a") @edges = {} @edges["a/b"] = Puppet::Relationship.new("a", "b", {:event => :yay, :callback => :refresh}) diff --git a/spec/unit/transaction/change.rb b/spec/unit/transaction/change.rb index bb9915bda..6da87d85b 100755 --- a/spec/unit/transaction/change.rb +++ b/spec/unit/transaction/change.rb @@ -75,7 +75,7 @@ describe Puppet::Transaction::Change do @property.stubs(:warning) @property.expects(:event).with(@change.should).returns :myevent - Puppet::Transaction::Event.expects(:new).with { |args| args[:event] == :myevent } + Puppet::Transaction::Event.expects(:new).with { |name, source| name == :myevent } @change.event("a string") end diff --git a/spec/unit/transaction/event.rb b/spec/unit/transaction/event.rb index 7332b782d..9fd71aae1 100755 --- a/spec/unit/transaction/event.rb +++ b/spec/unit/transaction/event.rb @@ -7,31 +7,19 @@ require 'puppet/transaction/event' describe Puppet::Transaction::Event do Event = Puppet::Transaction::Event - it "should have an event accessor" do - event = Event.new :event => :foo, :source => "foo" - event.event.should == :foo + it "should require a name and a source" do + lambda { Event.new }.should raise_error(ArgumentError) end - it "should have a source accessor" do - event = Event.new :event => :foo, :source => "foo" - event.source.should == "foo" - end - - it "should have a transaction accessor" do - event = Event.new :event => :foo, :source => "foo" - event.transaction = "eh" - event.transaction.should == "eh" + it "should have a name getter" do + Event.new(:foo, "bar").name.should == :foo end - it "should require a source" do - lambda { Event.new :event => :foo }.should raise_error - end - - it "should require an event" do - lambda { Event.new :source => "eh" }.should raise_error + it "should have a source accessor" do + Event.new(:foo, "bar").source.should == "bar" end it "should be able to produce a string containing the event name and the source" do - Event.new(:event => :event, :source => :source).to_s.should == "source -> event" + Event.new(:event, :source).to_s.should == "source -> event" end end |
