diff options
author | Luke Kanies <luke@reductivelabs.com> | 2010-01-19 15:45:27 -0800 |
---|---|---|
committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
commit | c30494f15ccaf1c1f15a9fde8b5a46a9adc4894a (patch) | |
tree | b4e0b65e443ee15a5c46b544006eebbf9727f206 | |
parent | 8d5f052b08078f0f356b30fb3fed60eab4490f6d (diff) | |
download | puppet-c30494f15ccaf1c1f15a9fde8b5a46a9adc4894a.tar.gz puppet-c30494f15ccaf1c1f15a9fde8b5a46a9adc4894a.tar.xz puppet-c30494f15ccaf1c1f15a9fde8b5a46a9adc4894a.zip |
Renaming some methods in Transaction::Change
Renaming 'go' to 'apply', which is a much more
reasonable name.
Also removing the 'backward' and 'forward' methods,
since they're not actually used anywhere. (Well,
'forward' was used, but it just called 'go'.)
Signed-off-by: Luke Kanies <luke@reductivelabs.com>
-rw-r--r-- | lib/puppet/transaction/change.rb | 17 | ||||
-rwxr-xr-x | spec/unit/transaction/change.rb | 53 |
2 files changed, 12 insertions, 58 deletions
diff --git a/lib/puppet/transaction/change.rb b/lib/puppet/transaction/change.rb index f8e2a7a82..b3aac5a32 100644 --- a/lib/puppet/transaction/change.rb +++ b/lib/puppet/transaction/change.rb @@ -6,15 +6,6 @@ require 'puppet/transaction/event' class Puppet::Transaction::Change attr_accessor :is, :should, :property, :proxy - # Switch the goals of the property, thus running the change in reverse. - def backward - @is, @should = @should, @is - @property.should = @should - - @property.info "Reversing %s" % self - return self.go - end - # Create our event object. def event result = property.event @@ -32,9 +23,7 @@ class Puppet::Transaction::Change @changed = false end - # Perform the actual change. This method can go either forward or - # backward, and produces an event. - def go + def apply return noop_event if noop? property.sync @@ -56,10 +45,6 @@ class Puppet::Transaction::Change result end - def forward - return self.go - end - # Is our property noop? This is used for generating special events. def noop? return @property.noop diff --git a/spec/unit/transaction/change.rb b/spec/unit/transaction/change.rb index be1267bf6..183414777 100755 --- a/spec/unit/transaction/change.rb +++ b/spec/unit/transaction/change.rb @@ -95,7 +95,7 @@ describe Puppet::Transaction::Change do @event.expects(:message=).with { |msg| msg.include?("should be") } - @change.forward + @change.apply end it "should produce a :noop event and return" do @@ -103,14 +103,14 @@ describe Puppet::Transaction::Change do @event.expects(:status=).with("noop") - @change.forward.should == @event + @change.apply.should == @event end end it "should sync the property" do @property.expects(:sync) - @change.forward + @change.apply end it "should return the default event if syncing the property returns nil" do @@ -118,7 +118,7 @@ describe Puppet::Transaction::Change do @change.expects(:event).with(nil).returns @event - @change.forward.should == @event + @change.apply.should == @event end it "should return the default event if syncing the property returns an empty array" do @@ -126,7 +126,7 @@ describe Puppet::Transaction::Change do @change.expects(:event).with(nil).returns @event - @change.forward.should == @event + @change.apply.should == @event end it "should log the change" do @@ -134,16 +134,16 @@ describe Puppet::Transaction::Change do @event.expects(:send_log) - @change.forward + @change.apply end it "should set the event's message to the change log" do @property.expects(:change_to_s).returns "my change" - @change.forward.message.should == "my change" + @change.apply.message.should == "my change" end it "should set the event's status to 'success'" do - @change.forward.status.should == "success" + @change.apply.status.should == "success" end describe "and the change fails" do @@ -151,46 +151,15 @@ describe Puppet::Transaction::Change do it "should catch the exception and log the err" do @event.expects(:send_log) - lambda { @change.forward }.should_not raise_error + lambda { @change.apply }.should_not raise_error end it "should mark the event status as 'failure'" do - @change.forward.status.should == "failure" + @change.apply.status.should == "failure" end it "should set the event log to a failure log" do - @change.forward.message.should be_include("failed") - end - end - - describe "backward" do - before do - @property = stub 'property' - @property.stub_everything - @property.stubs(:should).returns "shouldval" - @change = Change.new(@property, "value") - @change.stubs :go - end - - it "should swap the 'is' and 'should' values" do - @change.backward - @change.is.should == "shouldval" - @change.should.should == "value" - end - - it "should set the 'should' value on the property to the previous 'is' value" do - @property.expects(:should=).with "value" - @change.backward - end - - it "should log that it's reversing the change" do - @property.expects(:info) - @change.backward - end - - it "should execute and return the resulting event" do - @change.expects(:go).returns :myevent - @change.backward.should == :myevent + @change.apply.message.should be_include("failed") end end end |