Skip to content

Commit

Permalink
Remove the need to set to_state as nil in specs
Browse files Browse the repository at this point in the history
  • Loading branch information
teohm authored and Anil Kumar Maurya committed Jul 27, 2017
1 parent 6a5fc30 commit ed88361
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions spec/unit/complex_example_spec.rb
Expand Up @@ -30,14 +30,14 @@
it 'should be able to be unsuspended into active if polite' do
auth.suspend!
expect(auth.may_wait?(:waiting, :please)).to be true
auth.wait!(nil, :please)
auth.wait!(: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.wait!(nil, :rude)}.to raise_error(AASM::InvalidTransition)
expect {auth.wait!(:rude)}.to raise_error(AASM::InvalidTransition)
expect {auth.wait!}.to raise_error(AASM::InvalidTransition)
end

Expand Down
6 changes: 3 additions & 3 deletions spec/unit/complex_multiple_example_spec.rb
Expand Up @@ -39,18 +39,18 @@
it 'should be able to wait into waiting if polite' do
auth.left_suspend!
expect(auth.may_left_wait?(:waiting, :please)).to be true
auth.left_wait!(nil, :please)
auth.left_wait!(:please)

auth.right_suspend!
expect(auth.may_right_wait?(:waiting)).to be false
auth.right_wait!(nil, :please)
auth.right_wait!(:please)
end

it 'should not be able to be unsuspended into active if not polite' do
auth.left_suspend!
expect(auth.may_left_wait?(:waiting)).not_to be true
expect(auth.may_left_wait?(:waiting, :rude)).not_to be true
expect {auth.left_wait!(nil, :rude)}.to raise_error(AASM::InvalidTransition)
expect {auth.left_wait!(:rude)}.to raise_error(AASM::InvalidTransition)
expect {auth.left_wait!}.to raise_error(AASM::InvalidTransition)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/unit/event_multiple_spec.rb
Expand Up @@ -37,7 +37,7 @@
end

it 'should transition to default state when :after transition invoked' do
pe.dress!(nil, 'purple', 'dressy')
pe.dress!('purple', 'dressy')
expect(pe.aasm(:left).current_state).to eq(:working)
end

Expand Down
8 changes: 4 additions & 4 deletions spec/unit/event_spec.rb
Expand Up @@ -106,7 +106,7 @@
obj = double('object', :aasm => double('aasm', :current_state => :open))
expect(obj).to receive(:guard_fn).with('arg1', 'arg2').and_return(true)

expect(event.fire(obj, {}, nil, 'arg1', 'arg2')).to eq(:closed)
expect(event.fire(obj, {}, 'arg1', 'arg2')).to eq(:closed)
end

context 'when given a gaurd proc' do
Expand All @@ -118,7 +118,7 @@
line_number = __LINE__ - 2
obj = double('object', :aasm => double('aasm', :current_state => :student))

event.fire(obj, {}, nil)
event.fire(obj, {})
expect(event.failed_callbacks).to eq ["#{__FILE__}##{line_number}"]
end
end
Expand All @@ -133,7 +133,7 @@
obj = double('object', :aasm => double('aasm', :current_state => :student))
allow(obj).to receive(:paid_tuition?).and_return(false)

event.fire(obj, {}, nil)
event.fire(obj, {})
expect(event.failed_callbacks).to eq [:paid_tuition?]
end
end
Expand Down Expand Up @@ -315,7 +315,7 @@
end

it 'should transition to default state when :after transition invoked' do
pe.dress!(nil, 'purple', 'dressy')
pe.dress!('purple', 'dressy')
expect(pe.aasm.current_state).to eq(:working)
end

Expand Down

0 comments on commit ed88361

Please sign in to comment.