mirror of
https://github.com/aasm/aasm
synced 2023-03-27 23:22:41 -04:00
refactored inspection spec
This commit is contained in:
parent
50e335be05
commit
e8671ae448
5 changed files with 17 additions and 8 deletions
|
@ -21,6 +21,7 @@ Gem::Specification.new do |s|
|
||||||
s.add_development_dependency 'shoulda'
|
s.add_development_dependency 'shoulda'
|
||||||
s.add_development_dependency 'sqlite3'
|
s.add_development_dependency 'sqlite3'
|
||||||
s.add_development_dependency 'minitest'
|
s.add_development_dependency 'minitest'
|
||||||
|
# s.add_development_dependency 'debugger'
|
||||||
s.add_development_dependency 'ruby-debug-completion'
|
s.add_development_dependency 'ruby-debug-completion'
|
||||||
|
|
||||||
s.files = `git ls-files`.split("\n")
|
s.files = `git ls-files`.split("\n")
|
||||||
|
|
|
@ -16,6 +16,14 @@ module AASM
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def <=>(state)
|
||||||
|
if state.is_a? Symbol
|
||||||
|
name <=> state
|
||||||
|
else
|
||||||
|
name <=> state.name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def fire_callbacks(action, record)
|
def fire_callbacks(action, record)
|
||||||
action = @options[action]
|
action = @options[action]
|
||||||
catch :halt_aasm_chain do
|
catch :halt_aasm_chain do
|
||||||
|
|
|
@ -41,7 +41,7 @@ end
|
||||||
|
|
||||||
|
|
||||||
describe AASM, '- aasm_states_for_select' do
|
describe AASM, '- aasm_states_for_select' do
|
||||||
it "should return a select friendly array of states in the form of [['Friendly name', 'state_name']]" do
|
it "should return a select friendly array of states" do
|
||||||
Foo.aasm_states_for_select.should == [['Open', 'open'], ['Closed', 'closed']]
|
Foo.aasm_states_for_select.should == [['Open', 'open'], ['Closed', 'closed']]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
|
||||||
|
|
||||||
describe 'aasm_states' do
|
|
||||||
it 'should contain all of the states' do
|
|
||||||
Conversation.aasm_states.should == [:needs_attention, :read, :closed, :awaiting_response, :junk]
|
|
||||||
end
|
|
||||||
end
|
|
7
spec/unit/inspection_spec.rb
Normal file
7
spec/unit/inspection_spec.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'inspecting AASM' do
|
||||||
|
it 'should support listing all states in the order they have been defined' do
|
||||||
|
Conversation.aasm_states.should == [:needs_attention, :read, :closed, :awaiting_response, :junk]
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue