Skip to content

Commit

Permalink
using the latest version of rspec
Browse files Browse the repository at this point in the history
  • Loading branch information
alto committed Nov 15, 2013
1 parent 04187f5 commit ad48863
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion aasm.gemspec
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'mongoid' if Gem::Version.create(RUBY_VERSION.dup) >= Gem::Version.create('1.9.3')
s.add_development_dependency 'rake'
s.add_development_dependency 'sdoc'
s.add_development_dependency 'rspec', '~> 2.0'
s.add_development_dependency 'rspec', '~> 2.14'
s.add_development_dependency 'rr'
s.add_development_dependency 'sqlite3'
s.add_development_dependency 'minitest'
Expand Down
10 changes: 5 additions & 5 deletions spec/unit/callbacks_spec.rb
Expand Up @@ -51,19 +51,19 @@ class Foo
it "should run error_callback if an exception is raised and error_callback defined" do
def @foo.error_callback(e); end

@foo.stub!(:enter).and_raise(e=StandardError.new)
@foo.stub(:enter).and_raise(e=StandardError.new)
@foo.should_receive(:error_callback).with(e)

@foo.safe_close!
end

it "should raise NoMethodError if exceptionis raised and error_callback is declared but not defined" do
@foo.stub!(:enter).and_raise(StandardError)
@foo.stub(:enter).and_raise(StandardError)
lambda{@foo.safe_close!}.should raise_error(NoMethodError)
end

it "should propagate an error if no error callback is declared" do
@foo.stub!(:enter).and_raise("Cannot enter safe")
@foo.stub(:enter).and_raise("Cannot enter safe")
lambda{@foo.close!}.should raise_error(StandardError, "Cannot enter safe")
end
end
Expand All @@ -85,7 +85,7 @@ def @foo.aasm_event_fired(event, from, to); end
end

it 'should not call it for failing bang fire' do
@foo.aasm.stub!(:set_current_state_with_persistence).and_return(false)
@foo.aasm.stub(:set_current_state_with_persistence).and_return(false)
@foo.should_not_receive(:aasm_event_fired)
@foo.close!
end
Expand All @@ -108,7 +108,7 @@ def @foo.aasm_event_failed(event, from); end
end

it 'should not call it if persist fails for bang fire' do
@foo.aasm.stub!(:set_current_state_with_persistence).and_return(false)
@foo.aasm.stub(:set_current_state_with_persistence).and_return(false)
@foo.should_receive(:aasm_event_failed)
@foo.close!
end
Expand Down
12 changes: 6 additions & 6 deletions spec/unit/event_spec.rb
Expand Up @@ -60,8 +60,8 @@

describe 'firing an event' do
it 'should return nil if the transitions are empty' do
obj = mock('object')
obj.stub!(:aasm_current_state)
obj = double('object')
obj.stub(:aasm_current_state)

event = AASM::Event.new(:event)
event.fire(obj).should be_nil
Expand All @@ -72,8 +72,8 @@
transitions :to => :closed, :from => [:open, :received]
end

obj = mock('object')
obj.stub!(:aasm_current_state).and_return(:open)
obj = double('object')
obj.stub(:aasm_current_state).and_return(:open)

event.fire(obj).should == :closed
end
Expand All @@ -83,8 +83,8 @@
transitions :to => :closed, :from => [:open, :received], :guard => :guard_fn
end

obj = mock('object')
obj.stub!(:aasm_current_state).and_return(:open)
obj = double('object')
obj.stub(:aasm_current_state).and_return(:open)
obj.should_receive(:guard_fn).with('arg1', 'arg2').and_return(true)

event.fire(obj, nil, 'arg1', 'arg2').should == :closed
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/persistence/active_record_persistence_spec.rb
Expand Up @@ -33,13 +33,13 @@
end

it "should return the aasm column when not new and the aasm_column is not nil" do
gate.stub!(:new_record?).and_return(false)
gate.stub(:new_record?).and_return(false)
gate.aasm_state = "state"
gate.aasm_current_state.should == :state
end

it "should allow a nil state" do
gate.stub!(:new_record?).and_return(false)
gate.stub(:new_record?).and_return(false)
gate.aasm_state = nil
gate.aasm_current_state.should be_nil
end
Expand All @@ -50,7 +50,7 @@
end

it "should not call aasm_ensure_initial_state on validation before update" do
gate.stub!(:new_record?).and_return(false)
gate.stub(:new_record?).and_return(false)
gate.should_not_receive(:aasm_ensure_initial_state)
gate.valid?
end
Expand Down
10 changes: 5 additions & 5 deletions spec/unit/state_spec.rb
Expand Up @@ -38,7 +38,7 @@ def new_state(options={})
it 'should send a message to the record for an action if the action is present as a symbol' do
state = new_state(:entering => :foo)

record = mock('record')
record = double('record')
record.should_receive(:foo)

state.fire_callbacks(:entering, record)
Expand All @@ -47,7 +47,7 @@ def new_state(options={})
it 'should send a message to the record for an action if the action is present as a string' do
state = new_state(:entering => 'foo')

record = mock('record')
record = double('record')
record.should_receive(:foo)

state.fire_callbacks(:entering, record)
Expand All @@ -56,7 +56,7 @@ def new_state(options={})
it 'should send a message to the record for each action' do
state = new_state(:entering => [:a, :b, "c", lambda {|r| r.foobar }])

record = mock('record')
record = double('record')
record.should_receive(:a)
record.should_receive(:b)
record.should_receive(:c)
Expand All @@ -68,7 +68,7 @@ def new_state(options={})
it "should stop calling actions if one of them raises :halt_aasm_chain" do
state = new_state(:entering => [:a, :b, :c])

record = mock('record')
record = double('record')
record.should_receive(:a)
record.should_receive(:b).and_throw(:halt_aasm_chain)
record.should_not_receive(:c)
Expand All @@ -79,7 +79,7 @@ def new_state(options={})
it 'should call a proc, passing in the record for an action if the action is present' do
state = new_state(:entering => Proc.new {|r| r.foobar})

record = mock('record')
record = double('record')
record.should_receive(:foobar)

state.fire_callbacks(:entering, record)
Expand Down
36 changes: 18 additions & 18 deletions spec/unit/transition_spec.rb
Expand Up @@ -42,9 +42,9 @@
opts = {:from => 'foo', :to => 'bar', :guard => 'g'}
st = AASM::Transition.new(opts)

obj = mock('object')
obj.stub!(:from).and_return(opts[:from])
obj.stub!(:to).and_return(opts[:to])
obj = double('object')
obj.stub(:from).and_return(opts[:from])
obj.stub(:to).and_return(opts[:to])

st.should == obj
end
Expand All @@ -53,9 +53,9 @@
opts = {:from => 'foo', :to => 'bar', :guard => 'g'}
st = AASM::Transition.new(opts)

obj = mock('object')
obj.stub!(:from).and_return('blah')
obj.stub!(:to).and_return(opts[:to])
obj = double('object')
obj.stub(:from).and_return('blah')
obj.stub(:to).and_return(opts[:to])

st.should_not == obj
end
Expand All @@ -64,9 +64,9 @@
opts = {:from => 'foo', :to => 'bar', :guard => 'g'}
st = AASM::Transition.new(opts)

obj = mock('object')
obj.stub!(:from).and_return(opts[:from])
obj.stub!(:to).and_return('blah')
obj = double('object')
obj.stub(:from).and_return(opts[:from])
obj.stub(:to).and_return('blah')

st.should_not == obj
end
Expand All @@ -84,7 +84,7 @@
opts = {:from => 'foo', :to => 'bar', :guard => :test}
st = AASM::Transition.new(opts)

obj = mock('object')
obj = double('object')
obj.should_receive(:test)

st.perform(obj)
Expand All @@ -94,7 +94,7 @@
opts = {:from => 'foo', :to => 'bar', :guard => 'test'}
st = AASM::Transition.new(opts)

obj = mock('object')
obj = double('object')
obj.should_receive(:test)

st.perform(obj)
Expand All @@ -104,7 +104,7 @@
opts = {:from => 'foo', :to => 'bar', :guard => Proc.new {|o| o.test}}
st = AASM::Transition.new(opts)

obj = mock('object')
obj = double('object')
obj.should_receive(:test)

st.perform(obj)
Expand All @@ -116,7 +116,7 @@
opts = {:from => 'foo', :to => 'bar', :on_transition => Proc.new {|o| o.test}}
st = AASM::Transition.new(opts)
args = {:arg1 => '1', :arg2 => '2'}
obj = mock('object')
obj = double('object')

opts[:on_transition].should_receive(:call).with(any_args)

Expand All @@ -127,7 +127,7 @@
opts = {:from => 'foo', :to => 'bar', :on_transition => Proc.new {||}}
st = AASM::Transition.new(opts)
args = {:arg1 => '1', :arg2 => '2'}
obj = mock('object')
obj = double('object')

opts[:on_transition].should_receive(:call).with(no_args)

Expand All @@ -140,7 +140,7 @@
opts = {:from => 'foo', :to => 'bar', :on_transition => 'test'}
st = AASM::Transition.new(opts)
args = {:arg1 => '1', :arg2 => '2'}
obj = mock('object')
obj = double('object')

obj.should_receive(:test)

Expand All @@ -151,7 +151,7 @@
opts = {:from => 'foo', :to => 'bar', :on_transition => :test}
st = AASM::Transition.new(opts)
args = {:arg1 => '1', :arg2 => '2'}
obj = mock('object')
obj = double('object')

obj.should_receive(:test)

Expand All @@ -162,7 +162,7 @@
opts = {:from => 'foo', :to => 'bar', :on_transition => :test}
st = AASM::Transition.new(opts)
args = {:arg1 => '1', :arg2 => '2'}
obj = mock('object')
obj = double('object')

obj.class.class_eval do
define_method(:test) {|*args| 'success'}
Expand All @@ -177,7 +177,7 @@
opts = {:from => 'foo', :to => 'bar', :on_transition => :test}
st = AASM::Transition.new(opts)
args = {:arg1 => '1', :arg2 => '2'}
obj = mock('object')
obj = double('object')

obj.class.class_eval do
define_method(:test) {|*args| 'success'}
Expand Down

0 comments on commit ad48863

Please sign in to comment.