From ad48863e7a001a23bc6d84b15e8c5a058fc66261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20B=C3=B6ttger?= Date: Fri, 15 Nov 2013 11:19:26 +0100 Subject: [PATCH] using the latest version of rspec --- aasm.gemspec | 2 +- spec/unit/callbacks_spec.rb | 10 +++--- spec/unit/event_spec.rb | 12 +++---- .../active_record_persistence_spec.rb | 6 ++-- spec/unit/state_spec.rb | 10 +++--- spec/unit/transition_spec.rb | 36 +++++++++---------- 6 files changed, 38 insertions(+), 38 deletions(-) diff --git a/aasm.gemspec b/aasm.gemspec index 189d4871..d7e316d7 100644 --- a/aasm.gemspec +++ b/aasm.gemspec @@ -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' diff --git a/spec/unit/callbacks_spec.rb b/spec/unit/callbacks_spec.rb index 26c00d8f..b1faad63 100644 --- a/spec/unit/callbacks_spec.rb +++ b/spec/unit/callbacks_spec.rb @@ -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 @@ -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 @@ -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 diff --git a/spec/unit/event_spec.rb b/spec/unit/event_spec.rb index da5dad1b..936c66be 100644 --- a/spec/unit/event_spec.rb +++ b/spec/unit/event_spec.rb @@ -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 @@ -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 @@ -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 diff --git a/spec/unit/persistence/active_record_persistence_spec.rb b/spec/unit/persistence/active_record_persistence_spec.rb index 1b9bfec1..8cb202c3 100644 --- a/spec/unit/persistence/active_record_persistence_spec.rb +++ b/spec/unit/persistence/active_record_persistence_spec.rb @@ -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 @@ -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 diff --git a/spec/unit/state_spec.rb b/spec/unit/state_spec.rb index 6f276e77..30f2b9ae 100644 --- a/spec/unit/state_spec.rb +++ b/spec/unit/state_spec.rb @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/spec/unit/transition_spec.rb b/spec/unit/transition_spec.rb index 2e033449..f8dd30af 100644 --- a/spec/unit/transition_spec.rb +++ b/spec/unit/transition_spec.rb @@ -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 @@ -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 @@ -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 @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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'} @@ -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'}