Sha256: c779480ae0a6a683fc716a0b1a3313938ee7fb1386a156c9cd0d2059b7995f8b

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 KB

Contents

require File.join( File.dirname(__FILE__),  "spec_helper" )

include Updater

describe "running an update" do
  
  before :each do
    Update.clear_all
    Foo.reset
  end
  
  it "should call the named method with a class target" do
    u = Update.immidiate(Foo,:bar,[:arg1,:arg2])
    Foo.should_receive(:bar).with(:arg1,:arg2)
    u.run
  end
  
  it "should call the named method with an conforming instance target" do
    f = Foo.create
    u = Update.immidiate(f,:bar,[:arg1,:arg2])
    Foo.should_receive(:bar).with(:instance,:arg1,:arg2)
    u.run
  end
  
  it "should delete the record once it is run" do
    u = Update.immidiate(Foo,:bar,[:arg1,:arg2])
    Foo.should_receive(:bar).with(:arg1,:arg2)
    u.run
    Update.orm.get(u.orm.id).should be_nil
  end
  
  it "should delete the record if there is a failure" do
    u = Update.immidiate(Foo,:bar,[:arg1,:arg2])
    Foo.should_receive(:bar).with(:arg1,:arg2).and_raise(RuntimeError)
    u.run
    Update.orm.get(u.orm.id).should be_nil
  end
  
  it "should NOT delete the record if it is a chain record" do
    u = Update.chain(Foo,:bar,[:arg1,:arg2])
    Foo.should_receive(:bar).with(:arg1,:arg2).and_raise(RuntimeError)
    u.run
    Update.orm.get(u.orm.id).should_not be_nil
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
updater-0.10.1 spec/update_runner_spec.rb
updater-0.10.0 spec/update_runner_spec.rb