Instiki 0.16.3: Rails 2.3.0
Instiki now runs on the Rails 2.3.0 Candidate Release. Among other improvements, this means that it now automagically selects between WEBrick and Mongrel. Just run ./instiki --daemon
This commit is contained in:
parent
43aadecc99
commit
4e14ccc74d
893 changed files with 71965 additions and 28511 deletions
|
@ -24,6 +24,8 @@ module ActiveModel
|
|||
:even => "must be even"
|
||||
}
|
||||
|
||||
##
|
||||
# :singleton-method:
|
||||
# Holds a hash with all the default error messages that can be replaced by your own copy or localizations.
|
||||
cattr_accessor :default_error_messages
|
||||
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
Dir[File.dirname(__FILE__) + "/state_machine/*.rb"].sort.each do |path|
|
||||
filename = File.basename(path)
|
||||
require "active_model/state_machine/#{filename}"
|
||||
end
|
||||
|
||||
module ActiveModel
|
||||
module StateMachine
|
||||
class InvalidTransition < Exception
|
||||
end
|
||||
|
||||
def self.included(base)
|
||||
require 'active_model/state_machine/machine'
|
||||
base.extend ClassMethods
|
||||
end
|
||||
|
||||
|
@ -35,6 +31,12 @@ module ActiveModel
|
|||
state_machines[name] ||= Machine.new(self, name)
|
||||
block ? state_machines[name].update(options, &block) : state_machines[name]
|
||||
end
|
||||
|
||||
def define_state_query_method(state_name)
|
||||
name = "#{state_name}?"
|
||||
undef_method(name) if method_defined?(name)
|
||||
class_eval "def #{name}; current_state.to_s == %(#{state_name}) end"
|
||||
end
|
||||
end
|
||||
|
||||
def current_state(name = nil, new_state = nil, persist = false)
|
||||
|
@ -63,4 +65,4 @@ module ActiveModel
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'active_model/state_machine/state_transition'
|
||||
|
||||
module ActiveModel
|
||||
module StateMachine
|
||||
class Event
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
require 'active_model/state_machine/state'
|
||||
require 'active_model/state_machine/event'
|
||||
|
||||
module ActiveModel
|
||||
module StateMachine
|
||||
class Machine
|
||||
attr_accessor :initial_state, :states, :events, :state_index
|
||||
attr_writer :initial_state
|
||||
attr_accessor :states, :events, :state_index
|
||||
attr_reader :klass, :name
|
||||
|
||||
def initialize(klass, name, options = {}, &block)
|
||||
|
@ -71,4 +75,4 @@ module ActiveModel
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,11 +5,8 @@ module ActiveModel
|
|||
|
||||
def initialize(name, options = {})
|
||||
@name = name
|
||||
machine = options.delete(:machine)
|
||||
if machine
|
||||
machine.klass.send(:define_method, "#{name}?") do
|
||||
current_state.to_s == name.to_s
|
||||
end
|
||||
if machine = options.delete(:machine)
|
||||
machine.klass.define_state_query_method(name)
|
||||
end
|
||||
update(options)
|
||||
end
|
||||
|
|
38
vendor/rails/activemodel/test/observing_test.rb
vendored
38
vendor/rails/activemodel/test/observing_test.rb
vendored
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
|
||||
require 'test_helper'
|
||||
|
||||
class ObservedModel < ActiveModel::Base
|
||||
class Observer
|
||||
|
@ -40,24 +40,22 @@ class ObservingTest < ActiveModel::TestCase
|
|||
assert ObservedModel.observers.include?(:bar), ":bar not in #{ObservedModel.observers.inspect}"
|
||||
end
|
||||
|
||||
uses_mocha "observer instantiation" do
|
||||
test "instantiates observer names passed as strings" do
|
||||
ObservedModel.observers << 'foo_observer'
|
||||
FooObserver.expects(:instance)
|
||||
ObservedModel.instantiate_observers
|
||||
end
|
||||
|
||||
test "instantiates observer names passed as symbols" do
|
||||
ObservedModel.observers << :foo_observer
|
||||
FooObserver.expects(:instance)
|
||||
ObservedModel.instantiate_observers
|
||||
end
|
||||
|
||||
test "instantiates observer classes" do
|
||||
ObservedModel.observers << ObservedModel::Observer
|
||||
ObservedModel::Observer.expects(:instance)
|
||||
ObservedModel.instantiate_observers
|
||||
end
|
||||
test "instantiates observer names passed as strings" do
|
||||
ObservedModel.observers << 'foo_observer'
|
||||
FooObserver.expects(:instance)
|
||||
ObservedModel.instantiate_observers
|
||||
end
|
||||
|
||||
test "instantiates observer names passed as symbols" do
|
||||
ObservedModel.observers << :foo_observer
|
||||
FooObserver.expects(:instance)
|
||||
ObservedModel.instantiate_observers
|
||||
end
|
||||
|
||||
test "instantiates observer classes" do
|
||||
ObservedModel.observers << ObservedModel::Observer
|
||||
ObservedModel::Observer.expects(:instance)
|
||||
ObservedModel.instantiate_observers
|
||||
end
|
||||
|
||||
test "passes observers to subclasses" do
|
||||
|
@ -120,4 +118,4 @@ class ObserverTest < ActiveModel::TestCase
|
|||
Foo.send(:changed)
|
||||
Foo.send(:notify_observers, :whatever, foo)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,31 +1,29 @@
|
|||
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
|
||||
require 'test_helper'
|
||||
|
||||
class EventTest < ActiveModel::TestCase
|
||||
def setup
|
||||
@name = :close_order
|
||||
@state_name = :close_order
|
||||
@success = :success_callback
|
||||
end
|
||||
|
||||
def new_event
|
||||
@event = ActiveModel::StateMachine::Event.new(nil, @name, {:success => @success}) do
|
||||
@event = ActiveModel::StateMachine::Event.new(nil, @state_name, {:success => @success}) do
|
||||
transitions :to => :closed, :from => [:open, :received]
|
||||
end
|
||||
end
|
||||
|
||||
test 'should set the name' do
|
||||
assert_equal @name, new_event.name
|
||||
assert_equal @state_name, new_event.name
|
||||
end
|
||||
|
||||
test 'should set the success option' do
|
||||
assert_equal @success, new_event.success
|
||||
end
|
||||
|
||||
uses_mocha 'StateTransition creation' do
|
||||
test 'should create StateTransitions' do
|
||||
ActiveModel::StateMachine::StateTransition.expects(:new).with(:to => :closed, :from => :open)
|
||||
ActiveModel::StateMachine::StateTransition.expects(:new).with(:to => :closed, :from => :received)
|
||||
new_event
|
||||
end
|
||||
test 'should create StateTransitions' do
|
||||
ActiveModel::StateMachine::StateTransition.expects(:new).with(:to => :closed, :from => :open)
|
||||
ActiveModel::StateMachine::StateTransition.expects(:new).with(:to => :closed, :from => :received)
|
||||
new_event
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
|
||||
require 'test_helper'
|
||||
|
||||
class MachineTestSubject
|
||||
include ActiveModel::StateMachine
|
||||
|
@ -40,4 +40,4 @@ class StateMachineMachineTest < ActiveModel::TestCase
|
|||
assert events.include?(:shutdown)
|
||||
assert events.include?(:timeout)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
|
||||
require 'test_helper'
|
||||
|
||||
class StateTestSubject
|
||||
include ActiveModel::StateMachine
|
||||
|
@ -9,13 +9,13 @@ end
|
|||
|
||||
class StateTest < ActiveModel::TestCase
|
||||
def setup
|
||||
@name = :astate
|
||||
@state_name = :astate
|
||||
@machine = StateTestSubject.state_machine
|
||||
@options = { :crazy_custom_key => 'key', :machine => @machine }
|
||||
end
|
||||
|
||||
def new_state(options={})
|
||||
ActiveModel::StateMachine::State.new(@name, @options.merge(options))
|
||||
ActiveModel::StateMachine::State.new(@state_name, @options.merge(options))
|
||||
end
|
||||
|
||||
test 'sets the name' do
|
||||
|
@ -43,32 +43,30 @@ class StateTest < ActiveModel::TestCase
|
|||
assert_equal new_state, new_state
|
||||
end
|
||||
|
||||
uses_mocha 'state actions' do
|
||||
test 'should send a message to the record for an action if the action is present as a symbol' do
|
||||
state = new_state(:entering => :foo)
|
||||
test '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 = stub
|
||||
record.expects(:foo)
|
||||
record = stub
|
||||
record.expects(:foo)
|
||||
|
||||
state.call_action(:entering, record)
|
||||
end
|
||||
|
||||
test '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 = stub
|
||||
record.expects(:foo)
|
||||
|
||||
state.call_action(:entering, record)
|
||||
end
|
||||
|
||||
test '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 = stub
|
||||
record.expects(:foobar)
|
||||
|
||||
state.call_action(:entering, record)
|
||||
end
|
||||
state.call_action(:entering, record)
|
||||
end
|
||||
end
|
||||
|
||||
test '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 = stub
|
||||
record.expects(:foo)
|
||||
|
||||
state.call_action(:entering, record)
|
||||
end
|
||||
|
||||
test '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 = stub
|
||||
record.expects(:foobar)
|
||||
|
||||
state.call_action(:entering, record)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
|
||||
require 'test_helper'
|
||||
|
||||
class StateTransitionTest < ActiveModel::TestCase
|
||||
test 'should set from, to, and opts attr readers' do
|
||||
|
@ -10,39 +10,37 @@ class StateTransitionTest < ActiveModel::TestCase
|
|||
assert_equal opts, st.options
|
||||
end
|
||||
|
||||
uses_mocha 'checking ActiveModel StateMachine transitions' do
|
||||
test 'should pass equality check if from and to are the same' do
|
||||
opts = {:from => 'foo', :to => 'bar', :guard => 'g'}
|
||||
st = ActiveModel::StateMachine::StateTransition.new(opts)
|
||||
test 'should pass equality check if from and to are the same' do
|
||||
opts = {:from => 'foo', :to => 'bar', :guard => 'g'}
|
||||
st = ActiveModel::StateMachine::StateTransition.new(opts)
|
||||
|
||||
obj = stub
|
||||
obj.stubs(:from).returns(opts[:from])
|
||||
obj.stubs(:to).returns(opts[:to])
|
||||
obj = stub
|
||||
obj.stubs(:from).returns(opts[:from])
|
||||
obj.stubs(:to).returns(opts[:to])
|
||||
|
||||
assert_equal st, obj
|
||||
end
|
||||
assert_equal st, obj
|
||||
end
|
||||
|
||||
test 'should fail equality check if from are not the same' do
|
||||
opts = {:from => 'foo', :to => 'bar', :guard => 'g'}
|
||||
st = ActiveModel::StateMachine::StateTransition.new(opts)
|
||||
test 'should fail equality check if from are not the same' do
|
||||
opts = {:from => 'foo', :to => 'bar', :guard => 'g'}
|
||||
st = ActiveModel::StateMachine::StateTransition.new(opts)
|
||||
|
||||
obj = stub
|
||||
obj.stubs(:from).returns('blah')
|
||||
obj.stubs(:to).returns(opts[:to])
|
||||
obj = stub
|
||||
obj.stubs(:from).returns('blah')
|
||||
obj.stubs(:to).returns(opts[:to])
|
||||
|
||||
assert_not_equal st, obj
|
||||
end
|
||||
|
||||
test 'should fail equality check if to are not the same' do
|
||||
opts = {:from => 'foo', :to => 'bar', :guard => 'g'}
|
||||
st = ActiveModel::StateMachine::StateTransition.new(opts)
|
||||
assert_not_equal st, obj
|
||||
end
|
||||
|
||||
obj = stub
|
||||
obj.stubs(:from).returns(opts[:from])
|
||||
obj.stubs(:to).returns('blah')
|
||||
test 'should fail equality check if to are not the same' do
|
||||
opts = {:from => 'foo', :to => 'bar', :guard => 'g'}
|
||||
st = ActiveModel::StateMachine::StateTransition.new(opts)
|
||||
|
||||
assert_not_equal st, obj
|
||||
end
|
||||
obj = stub
|
||||
obj.stubs(:from).returns(opts[:from])
|
||||
obj.stubs(:to).returns('blah')
|
||||
|
||||
assert_not_equal st, obj
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -54,35 +52,33 @@ class StateTransitionGuardCheckTest < ActiveModel::TestCase
|
|||
assert st.perform(nil)
|
||||
end
|
||||
|
||||
uses_mocha 'checking ActiveModel StateMachine transition guard checks' do
|
||||
test 'should call the method on the object if guard is a symbol' do
|
||||
opts = {:from => 'foo', :to => 'bar', :guard => :test_guard}
|
||||
st = ActiveModel::StateMachine::StateTransition.new(opts)
|
||||
test 'should call the method on the object if guard is a symbol' do
|
||||
opts = {:from => 'foo', :to => 'bar', :guard => :test_guard}
|
||||
st = ActiveModel::StateMachine::StateTransition.new(opts)
|
||||
|
||||
obj = stub
|
||||
obj.expects(:test_guard)
|
||||
|
||||
obj = stub
|
||||
obj.expects(:test_guard)
|
||||
|
||||
st.perform(obj)
|
||||
end
|
||||
st.perform(obj)
|
||||
end
|
||||
|
||||
test 'should call the method on the object if guard is a string' do
|
||||
opts = {:from => 'foo', :to => 'bar', :guard => 'test_guard'}
|
||||
st = ActiveModel::StateMachine::StateTransition.new(opts)
|
||||
|
||||
obj = stub
|
||||
obj.expects(:test_guard)
|
||||
|
||||
test 'should call the method on the object if guard is a string' do
|
||||
opts = {:from => 'foo', :to => 'bar', :guard => 'test_guard'}
|
||||
st = ActiveModel::StateMachine::StateTransition.new(opts)
|
||||
|
||||
obj = stub
|
||||
obj.expects(:test_guard)
|
||||
|
||||
st.perform(obj)
|
||||
end
|
||||
|
||||
test 'should call the proc passing the object if the guard is a proc' do
|
||||
opts = {:from => 'foo', :to => 'bar', :guard => Proc.new {|o| o.test_guard}}
|
||||
st = ActiveModel::StateMachine::StateTransition.new(opts)
|
||||
|
||||
obj = stub
|
||||
obj.expects(:test_guard)
|
||||
|
||||
st.perform(obj)
|
||||
end
|
||||
st.perform(obj)
|
||||
end
|
||||
|
||||
test 'should call the proc passing the object if the guard is a proc' do
|
||||
opts = {:from => 'foo', :to => 'bar', :guard => Proc.new {|o| o.test_guard}}
|
||||
st = ActiveModel::StateMachine::StateTransition.new(opts)
|
||||
|
||||
obj = stub
|
||||
obj.expects(:test_guard)
|
||||
|
||||
st.perform(obj)
|
||||
end
|
||||
end
|
||||
|
|
180
vendor/rails/activemodel/test/state_machine_test.rb
vendored
180
vendor/rails/activemodel/test/state_machine_test.rb
vendored
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
|
||||
require 'test_helper'
|
||||
|
||||
class StateMachineSubject
|
||||
include ActiveModel::StateMachine
|
||||
|
@ -122,24 +122,22 @@ class StateMachineEventFiringWithPersistenceTest < ActiveModel::TestCase
|
|||
assert_equal :closed, @subj.current_state
|
||||
end
|
||||
|
||||
uses_mocha "StateMachineEventFiringWithPersistenceTest with callbacks" do
|
||||
test 'fires the Event' do
|
||||
@subj.class.state_machine.events[:close].expects(:fire).with(@subj)
|
||||
@subj.close!
|
||||
test 'fires the Event' do
|
||||
@subj.class.state_machine.events[:close].expects(:fire).with(@subj)
|
||||
@subj.close!
|
||||
end
|
||||
|
||||
test 'calls the success callback if one was provided' do
|
||||
@subj.expects(:success_callback)
|
||||
@subj.close!
|
||||
end
|
||||
|
||||
test 'attempts to persist if write_state is defined' do
|
||||
def @subj.write_state
|
||||
end
|
||||
|
||||
test 'calls the success callback if one was provided' do
|
||||
@subj.expects(:success_callback)
|
||||
@subj.close!
|
||||
end
|
||||
|
||||
test 'attempts to persist if write_state is defined' do
|
||||
def @subj.write_state
|
||||
end
|
||||
|
||||
@subj.expects(:write_state)
|
||||
@subj.close!
|
||||
end
|
||||
@subj.expects(:write_state)
|
||||
@subj.close!
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -151,98 +149,90 @@ class StateMachineEventFiringWithoutPersistence < ActiveModel::TestCase
|
|||
assert_equal :closed, subj.current_state
|
||||
end
|
||||
|
||||
uses_mocha 'StateMachineEventFiringWithoutPersistence' do
|
||||
test 'fires the Event' do
|
||||
subj = StateMachineSubject.new
|
||||
test 'fires the Event' do
|
||||
subj = StateMachineSubject.new
|
||||
|
||||
StateMachineSubject.state_machine.events[:close].expects(:fire).with(subj)
|
||||
subj.close
|
||||
StateMachineSubject.state_machine.events[:close].expects(:fire).with(subj)
|
||||
subj.close
|
||||
end
|
||||
|
||||
test 'attempts to persist if write_state is defined' do
|
||||
subj = StateMachineSubject.new
|
||||
|
||||
def subj.write_state
|
||||
end
|
||||
|
||||
test 'attempts to persist if write_state is defined' do
|
||||
subj = StateMachineSubject.new
|
||||
subj.expects(:write_state_without_persistence)
|
||||
|
||||
def subj.write_state
|
||||
end
|
||||
|
||||
subj.expects(:write_state_without_persistence)
|
||||
|
||||
subj.close
|
||||
end
|
||||
subj.close
|
||||
end
|
||||
end
|
||||
|
||||
uses_mocha 'StateMachinePersistenceTest' do
|
||||
class StateMachinePersistenceTest < ActiveModel::TestCase
|
||||
test 'reads the state if it has not been set and read_state is defined' do
|
||||
subj = StateMachineSubject.new
|
||||
def subj.read_state
|
||||
end
|
||||
|
||||
subj.expects(:read_state).with(StateMachineSubject.state_machine)
|
||||
|
||||
subj.current_state
|
||||
class StateMachinePersistenceTest < ActiveModel::TestCase
|
||||
test 'reads the state if it has not been set and read_state is defined' do
|
||||
subj = StateMachineSubject.new
|
||||
def subj.read_state
|
||||
end
|
||||
|
||||
subj.expects(:read_state).with(StateMachineSubject.state_machine)
|
||||
|
||||
subj.current_state
|
||||
end
|
||||
end
|
||||
|
||||
uses_mocha 'StateMachineEventCallbacksTest' do
|
||||
class StateMachineEventCallbacksTest < ActiveModel::TestCase
|
||||
test 'should call aasm_event_fired if defined and successful for bang fire' do
|
||||
subj = StateMachineSubject.new
|
||||
def subj.aasm_event_fired(from, to)
|
||||
end
|
||||
|
||||
subj.expects(:event_fired)
|
||||
|
||||
subj.close!
|
||||
class StateMachineEventCallbacksTest < ActiveModel::TestCase
|
||||
test 'should call aasm_event_fired if defined and successful for bang fire' do
|
||||
subj = StateMachineSubject.new
|
||||
def subj.aasm_event_fired(from, to)
|
||||
end
|
||||
|
||||
test 'should call aasm_event_fired if defined and successful for non-bang fire' do
|
||||
subj = StateMachineSubject.new
|
||||
def subj.aasm_event_fired(from, to)
|
||||
end
|
||||
subj.expects(:event_fired)
|
||||
|
||||
subj.expects(:event_fired)
|
||||
subj.close!
|
||||
end
|
||||
|
||||
subj.close
|
||||
test 'should call aasm_event_fired if defined and successful for non-bang fire' do
|
||||
subj = StateMachineSubject.new
|
||||
def subj.aasm_event_fired(from, to)
|
||||
end
|
||||
|
||||
test 'should call aasm_event_failed if defined and transition failed for bang fire' do
|
||||
subj = StateMachineSubject.new
|
||||
def subj.event_failed(event)
|
||||
end
|
||||
subj.expects(:event_fired)
|
||||
|
||||
subj.expects(:event_failed)
|
||||
subj.close
|
||||
end
|
||||
|
||||
subj.null!
|
||||
test 'should call aasm_event_failed if defined and transition failed for bang fire' do
|
||||
subj = StateMachineSubject.new
|
||||
def subj.event_failed(event)
|
||||
end
|
||||
|
||||
test 'should call aasm_event_failed if defined and transition failed for non-bang fire' do
|
||||
subj = StateMachineSubject.new
|
||||
def subj.aasm_event_failed(event)
|
||||
end
|
||||
subj.expects(:event_failed)
|
||||
|
||||
subj.expects(:event_failed)
|
||||
subj.null!
|
||||
end
|
||||
|
||||
subj.null
|
||||
test 'should call aasm_event_failed if defined and transition failed for non-bang fire' do
|
||||
subj = StateMachineSubject.new
|
||||
def subj.aasm_event_failed(event)
|
||||
end
|
||||
|
||||
subj.expects(:event_failed)
|
||||
|
||||
subj.null
|
||||
end
|
||||
end
|
||||
|
||||
uses_mocha 'StateMachineStateActionsTest' do
|
||||
class StateMachineStateActionsTest < ActiveModel::TestCase
|
||||
test "calls enter when entering state" do
|
||||
subj = StateMachineSubject.new
|
||||
subj.expects(:enter)
|
||||
subj.close
|
||||
end
|
||||
class StateMachineStateActionsTest < ActiveModel::TestCase
|
||||
test "calls enter when entering state" do
|
||||
subj = StateMachineSubject.new
|
||||
subj.expects(:enter)
|
||||
subj.close
|
||||
end
|
||||
|
||||
test "calls exit when exiting state" do
|
||||
subj = StateMachineSubject.new
|
||||
subj.expects(:exit)
|
||||
subj.close
|
||||
end
|
||||
test "calls exit when exiting state" do
|
||||
subj = StateMachineSubject.new
|
||||
subj.expects(:exit)
|
||||
subj.close
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -306,19 +296,17 @@ class StateMachineWithComplexTransitionsTest < ActiveModel::TestCase
|
|||
assert_equal :working, @subj.current_state(:chetan_patil)
|
||||
end
|
||||
|
||||
uses_mocha "StateMachineWithComplexTransitionsTest on_transition tests" do
|
||||
test 'calls on_transition method with args' do
|
||||
@subj.wakeup! :showering
|
||||
|
||||
@subj.expects(:wear_clothes).with('blue', 'jeans')
|
||||
@subj.dress! :working, 'blue', 'jeans'
|
||||
end
|
||||
|
||||
test 'calls on_transition proc' do
|
||||
@subj.wakeup! :showering
|
||||
|
||||
@subj.expects(:wear_clothes).with('purple', 'slacks')
|
||||
@subj.dress!(:dating, 'purple', 'slacks')
|
||||
end
|
||||
test 'calls on_transition method with args' do
|
||||
@subj.wakeup! :showering
|
||||
|
||||
@subj.expects(:wear_clothes).with('blue', 'jeans')
|
||||
@subj.dress! :working, 'blue', 'jeans'
|
||||
end
|
||||
end
|
||||
|
||||
test 'calls on_transition proc' do
|
||||
@subj.wakeup! :showering
|
||||
|
||||
@subj.expects(:wear_clothes).with('purple', 'slacks')
|
||||
@subj.dress!(:dating, 'purple', 'slacks')
|
||||
end
|
||||
end
|
||||
|
|
36
vendor/rails/activemodel/test/test_helper.rb
vendored
36
vendor/rails/activemodel/test/test_helper.rb
vendored
|
@ -1,39 +1,21 @@
|
|||
$:.unshift "#{File.dirname(__FILE__)}/../lib"
|
||||
$:.unshift File.dirname(__FILE__)
|
||||
|
||||
require 'rubygems'
|
||||
require 'test/unit'
|
||||
|
||||
gem 'mocha', '>= 0.9.3'
|
||||
require 'mocha'
|
||||
|
||||
require 'active_model'
|
||||
require 'active_model/state_machine'
|
||||
require 'active_support/callbacks' # needed by ActiveModel::TestCase
|
||||
|
||||
$:.unshift File.dirname(__FILE__) + "/../../activesupport/lib"
|
||||
require 'active_support'
|
||||
require 'active_support/test_case'
|
||||
|
||||
def uses_gem(gem_name, test_name, version = '> 0')
|
||||
require 'rubygems'
|
||||
gem gem_name.to_s, version
|
||||
require gem_name.to_s
|
||||
yield
|
||||
rescue LoadError
|
||||
$stderr.puts "Skipping #{test_name} tests. `gem install #{gem_name}` and try again."
|
||||
end
|
||||
|
||||
# Wrap tests that use Mocha and skip if unavailable.
|
||||
unless defined? uses_mocha
|
||||
def uses_mocha(test_name, &block)
|
||||
uses_gem('mocha', test_name, '>= 0.5.5', &block)
|
||||
end
|
||||
class ActiveModel::TestCase < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
begin
|
||||
require 'rubygems'
|
||||
require 'ruby-debug'
|
||||
Debugger.start
|
||||
rescue LoadError
|
||||
end
|
||||
|
||||
ActiveSupport::TestCase.send :include, ActiveSupport::Testing::Default
|
||||
|
||||
module ActiveModel
|
||||
class TestCase < ActiveSupport::TestCase
|
||||
include ActiveSupport::Testing::Default
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue