1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00

refactored inspection spec

This commit is contained in:
Thorsten Böttger 2012-10-26 22:40:57 +13:00
parent 50e335be05
commit e8671ae448
5 changed files with 17 additions and 8 deletions

View file

@ -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")

View file

@ -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

View file

@ -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

View file

@ -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

View 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