mirror of
https://github.com/aasm/aasm
synced 2023-03-27 23:22:41 -04:00
using RSpec 2.99 now (preparing RSpec 3)
This commit is contained in:
parent
cdc3d5e829
commit
34de314baa
7 changed files with 32 additions and 32 deletions
|
@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|||
|
||||
s.add_development_dependency 'rake'
|
||||
s.add_development_dependency 'sdoc'
|
||||
s.add_development_dependency 'rspec', '>= 2.14', '< 2.99'
|
||||
s.add_development_dependency 'rspec', '2.99'
|
||||
|
||||
# debugging
|
||||
# s.add_development_dependency 'debugger'
|
||||
|
|
|
@ -8,7 +8,7 @@ describe 'on initialization' do
|
|||
end
|
||||
|
||||
it 'should have an activation code' do
|
||||
expect(auth.has_activation_code?).to be_true
|
||||
expect(auth.has_activation_code?).to be_truthy
|
||||
expect(auth.activation_code).not_to be_nil
|
||||
end
|
||||
end
|
||||
|
@ -19,24 +19,24 @@ describe 'when being unsuspended' do
|
|||
it 'should be able to be unsuspended' do
|
||||
auth.activate!
|
||||
auth.suspend!
|
||||
expect(auth.may_unsuspend?).to be_true
|
||||
expect(auth.may_unsuspend?).to be_truthy
|
||||
end
|
||||
|
||||
it 'should not be able to be unsuspended into active' do
|
||||
auth.suspend!
|
||||
expect(auth.may_unsuspend?(:active)).not_to be_true
|
||||
expect(auth.may_unsuspend?(:active)).not_to be_truthy
|
||||
end
|
||||
|
||||
it 'should be able to be unsuspended into active if polite' do
|
||||
auth.suspend!
|
||||
expect(auth.may_wait?(:waiting, :please)).to be_true
|
||||
expect(auth.may_wait?(:waiting, :please)).to be_truthy
|
||||
auth.wait!(nil, :please)
|
||||
end
|
||||
|
||||
it 'should not be able to be unsuspended into active if not polite' do
|
||||
auth.suspend!
|
||||
expect(auth.may_wait?(:waiting)).not_to be_true
|
||||
expect(auth.may_wait?(:waiting, :rude)).not_to be_true
|
||||
expect(auth.may_wait?(:waiting)).not_to be_truthy
|
||||
expect(auth.may_wait?(:waiting, :rude)).not_to be_truthy
|
||||
expect {auth.wait!(nil, :rude)}.to raise_error(AASM::InvalidTransition)
|
||||
expect {auth.wait!}.to raise_error(AASM::InvalidTransition)
|
||||
end
|
||||
|
@ -46,7 +46,7 @@ describe 'when being unsuspended' do
|
|||
auth.suspend!
|
||||
auth.unsuspend!
|
||||
|
||||
expect(auth.may_unpassify?).not_to be_true
|
||||
expect(auth.may_unpassify?).not_to be_truthy
|
||||
expect {auth.unpassify!}.to raise_error(AASM::InvalidTransition)
|
||||
end
|
||||
|
||||
|
@ -74,11 +74,11 @@ describe 'when being unsuspended' do
|
|||
end
|
||||
|
||||
it "should be able to fire known events" do
|
||||
expect(auth.aasm.may_fire_event?(:activate)).to be_true
|
||||
expect(auth.aasm.may_fire_event?(:activate)).to be_truthy
|
||||
end
|
||||
|
||||
it "should not be able to fire unknown events" do
|
||||
expect(auth.aasm.may_fire_event?(:unknown)).to be_false
|
||||
expect(auth.aasm.may_fire_event?(:unknown)).to be_falsey
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -43,18 +43,18 @@ describe 'transition inspection' do
|
|||
|
||||
it 'should support inspecting transitions from other states' do
|
||||
expect(event.transitions_from_state(:sleeping).map(&:to)).to eq([:running])
|
||||
expect(event.transitions_from_state?(:sleeping)).to be_true
|
||||
expect(event.transitions_from_state?(:sleeping)).to be_truthy
|
||||
|
||||
expect(event.transitions_from_state(:cleaning).map(&:to)).to eq([])
|
||||
expect(event.transitions_from_state?(:cleaning)).to be_false
|
||||
expect(event.transitions_from_state?(:cleaning)).to be_falsey
|
||||
end
|
||||
|
||||
it 'should support inspecting transitions to other states' do
|
||||
expect(event.transitions_to_state(:running).map(&:from)).to eq([:sleeping])
|
||||
expect(event.transitions_to_state?(:running)).to be_true
|
||||
expect(event.transitions_to_state?(:running)).to be_truthy
|
||||
|
||||
expect(event.transitions_to_state(:cleaning).map(&:to)).to eq([])
|
||||
expect(event.transitions_to_state?(:cleaning)).to be_false
|
||||
expect(event.transitions_to_state?(:cleaning)).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -67,10 +67,10 @@ describe 'transition inspection without from' do
|
|||
|
||||
it 'should support inspecting transitions from other states' do
|
||||
expect(event.transitions_from_state(:sleeping).map(&:to)).to eq([:running])
|
||||
expect(event.transitions_from_state?(:sleeping)).to be_true
|
||||
expect(event.transitions_from_state?(:sleeping)).to be_truthy
|
||||
|
||||
expect(event.transitions_from_state(:cleaning).map(&:to)).to eq([:running])
|
||||
expect(event.transitions_from_state?(:cleaning)).to be_true
|
||||
expect(event.transitions_from_state?(:cleaning)).to be_truthy
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -67,11 +67,11 @@ describe "special cases" do
|
|||
expect(Argument.aasm.states).to include(:valid)
|
||||
|
||||
argument = Argument.new
|
||||
expect(argument.invalid?).to be_true
|
||||
expect(argument.invalid?).to be_truthy
|
||||
expect(argument.aasm.current_state).to eq(:invalid)
|
||||
|
||||
argument.valid!
|
||||
expect(argument.valid?).to be_true
|
||||
expect(argument.valid?).to be_truthy
|
||||
expect(argument.aasm.current_state).to eq(:valid)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -38,7 +38,7 @@ describe "instance methods" do
|
|||
let(:column) { double(Object, type: :integer) }
|
||||
|
||||
it "returns true" do
|
||||
expect(subject.call).to be_true
|
||||
expect(subject.call).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -46,7 +46,7 @@ describe "instance methods" do
|
|||
let(:column) { double(Object, type: :string) }
|
||||
|
||||
it "returns false" do
|
||||
expect(subject.call).to be_false
|
||||
expect(subject.call).to be_falsey
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -299,7 +299,7 @@ describe "named scopes with the new DSL" do
|
|||
context "Does not already respond_to? the scope name" do
|
||||
it "should add a scope" do
|
||||
expect(SimpleNewDsl).to respond_to(:unknown_scope)
|
||||
expect(SimpleNewDsl.unknown_scope.is_a?(ActiveRecord::Relation)).to be_true
|
||||
expect(SimpleNewDsl.unknown_scope.is_a?(ActiveRecord::Relation)).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -358,7 +358,7 @@ describe 'transitions with persistence' do
|
|||
|
||||
validator.name = nil
|
||||
expect(validator).not_to be_valid
|
||||
expect(validator.run!).to be_false
|
||||
expect(validator.run!).to be_falsey
|
||||
expect(validator).to be_sleeping
|
||||
|
||||
validator.reload
|
||||
|
@ -367,7 +367,7 @@ describe 'transitions with persistence' do
|
|||
|
||||
validator.name = 'another name'
|
||||
expect(validator).to be_valid
|
||||
expect(validator.run!).to be_true
|
||||
expect(validator.run!).to be_truthy
|
||||
expect(validator).to be_running
|
||||
|
||||
validator.reload
|
||||
|
@ -382,7 +382,7 @@ describe 'transitions with persistence' do
|
|||
|
||||
persistor.name = nil
|
||||
expect(persistor).not_to be_valid
|
||||
expect(persistor.run!).to be_true
|
||||
expect(persistor.run!).to be_truthy
|
||||
expect(persistor).to be_running
|
||||
|
||||
persistor = InvalidPersistor.find(persistor.id)
|
||||
|
@ -487,7 +487,7 @@ describe "invalid states with persistence" do
|
|||
it "should not store states" do
|
||||
validator = Validator.create(:name => 'name')
|
||||
validator.status = 'invalid_state'
|
||||
expect(validator.save).to be_false
|
||||
expect(validator.save).to be_falsey
|
||||
expect {validator.save!}.to raise_error(ActiveRecord::RecordInvalid)
|
||||
|
||||
validator.reload
|
||||
|
@ -497,7 +497,7 @@ describe "invalid states with persistence" do
|
|||
it "should store invalid states if configured" do
|
||||
persistor = InvalidPersistor.create(:name => 'name')
|
||||
persistor.status = 'invalid_state'
|
||||
expect(persistor.save).to be_true
|
||||
expect(persistor.save).to be_truthy
|
||||
|
||||
persistor.reload
|
||||
expect(persistor.status).to eq('invalid_state')
|
||||
|
|
|
@ -19,7 +19,7 @@ describe 'subclassing' do
|
|||
end
|
||||
|
||||
it 'should know how to respond to `may_add_details?`' do
|
||||
expect(son.may_add_details?).to be_true
|
||||
expect(son.may_add_details?).to be_truthy
|
||||
end
|
||||
|
||||
it 'should not break if I call Son#update_state' do
|
||||
|
|
|
@ -10,19 +10,19 @@ describe 'transitions' do
|
|||
|
||||
it 'should not raise an exception when not whiny' do
|
||||
silencer = Silencer.new
|
||||
expect(silencer.smile!).to be_false
|
||||
expect(silencer.smile!).to be_falsey
|
||||
expect(silencer).to be_silent
|
||||
end
|
||||
|
||||
it 'should not raise an exception when superclass not whiny' do
|
||||
sub = SubClassing.new
|
||||
expect(sub.smile!).to be_false
|
||||
expect(sub.smile!).to be_falsey
|
||||
expect(sub).to be_silent
|
||||
end
|
||||
|
||||
it 'should not raise an exception when from is nil even if whiny' do
|
||||
silencer = Silencer.new
|
||||
expect(silencer.smile_any!).to be_true
|
||||
expect(silencer.smile_any!).to be_truthy
|
||||
expect(silencer).to be_smiling
|
||||
end
|
||||
|
||||
|
@ -43,7 +43,7 @@ describe 'transitions' do
|
|||
silencer.smile! do
|
||||
success = true
|
||||
end
|
||||
}.not_to change { success }.to(true)
|
||||
}.not_to change { success }
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -124,7 +124,7 @@ describe AASM::Core::Transition, '- when performing guard checks' do
|
|||
opts = {:from => 'foo', :to => 'bar'}
|
||||
st = AASM::Core::Transition.new(opts)
|
||||
|
||||
expect(st.allowed?(nil)).to be_true
|
||||
expect(st.allowed?(nil)).to be_truthy
|
||||
end
|
||||
|
||||
it 'should call the method on the object if guard is a symbol' do
|
||||
|
|
Loading…
Add table
Reference in a new issue