From d853e9cb26316876f9db3a1e4a1f7b66797feddb Mon Sep 17 00:00:00 2001 From: Travis Tilley Date: Fri, 27 Aug 2010 16:35:26 -0400 Subject: [PATCH] fix various tests --- lib/aasm/persistence/active_record_persistence.rb | 12 ++++++------ spec/functional/conversation_spec.rb | 4 ++-- spec/spec_helper.rb | 4 ++-- spec/unit/aasm_spec.rb | 2 +- spec/unit/active_record_persistence_spec.rb | 10 ++++------ spec/unit/before_after_callbacks_spec.rb | 2 +- spec/unit/event_spec.rb | 2 +- spec/unit/state_spec.rb | 2 +- spec/unit/state_transition_spec.rb | 2 +- 9 files changed, 19 insertions(+), 21 deletions(-) diff --git a/lib/aasm/persistence/active_record_persistence.rb b/lib/aasm/persistence/active_record_persistence.rb index 04d94400..a7574f8b 100644 --- a/lib/aasm/persistence/active_record_persistence.rb +++ b/lib/aasm/persistence/active_record_persistence.rb @@ -38,14 +38,14 @@ def self.included(base) base.send(:include, AASM::Persistence::ActiveRecordPersistence::WriteState) unless base.method_defined?(:aasm_write_state) base.send(:include, AASM::Persistence::ActiveRecordPersistence::WriteStateWithoutPersistence) unless base.method_defined?(:aasm_write_state_without_persistence) - if base.respond_to?(:named_scope) + if base.respond_to?(:scope) base.extend(AASM::Persistence::ActiveRecordPersistence::NamedScopeMethods) base.class_eval do class << self - unless method_defined?(:aasm_state_without_named_scope) - alias_method :aasm_state_without_named_scope, :aasm_state - alias_method :aasm_state, :aasm_state_with_named_scope + unless method_defined?(:aasm_state_without_scope) + alias_method :aasm_state_without_scope, :aasm_state + alias_method :aasm_state, :aasm_state_with_scope end end end @@ -236,8 +236,8 @@ def aasm_read_state end module NamedScopeMethods - def aasm_state_with_named_scope name, options = {} - aasm_state_without_named_scope name, options + def aasm_state_with_scope name, options = {} + aasm_state_without_scope name, options self.scope name, :conditions => { "#{table_name}.#{self.aasm_column}" => name.to_s} unless self.respond_to?(name) end end diff --git a/spec/functional/conversation_spec.rb b/spec/functional/conversation_spec.rb index 3e0a63fe..8cfc97c9 100644 --- a/spec/functional/conversation_spec.rb +++ b/spec/functional/conversation_spec.rb @@ -1,5 +1,5 @@ -require File.join(File.dirname(__FILE__), "..", "spec_helper") -require File.join(File.dirname(__FILE__), 'conversation') +require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) +require File.expand_path(File.join(File.dirname(__FILE__), 'conversation')) describe Conversation, 'description' do it '.aasm_states should contain all of the states' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e4d3fc0e..9b9df8e5 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,5 @@ -$LOAD_PATH.unshift(File.dirname(__FILE__)) -$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) +$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__))) +$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))) require 'aasm' diff --git a/spec/unit/aasm_spec.rb b/spec/unit/aasm_spec.rb index 231b69ea..7d7e0613 100644 --- a/spec/unit/aasm_spec.rb +++ b/spec/unit/aasm_spec.rb @@ -1,4 +1,4 @@ -require File.join(File.dirname(__FILE__), '..', 'spec_helper') +require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) class Foo include AASM diff --git a/spec/unit/active_record_persistence_spec.rb b/spec/unit/active_record_persistence_spec.rb index 5df1a997..cf7743d6 100644 --- a/spec/unit/active_record_persistence_spec.rb +++ b/spec/unit/active_record_persistence_spec.rb @@ -1,5 +1,3 @@ -require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'aasm') - begin require 'rubygems' require 'active_record' @@ -214,15 +212,15 @@ class NamedScopeExample < ActiveRecord::Base end context "Does not already respond_to? the scope name" do - it "should add a named_scope" do - NamedScopeExample.should_receive(:named_scope) + it "should add a scope" do + NamedScopeExample.should_receive(:scope) NamedScopeExample.aasm_state :unknown_scope end end context "Already respond_to? the scope name" do - it "should not add a named_scope" do - NamedScopeExample.should_not_receive(:named_scope) + it "should not add a scope" do + NamedScopeExample.should_not_receive(:scope) NamedScopeExample.aasm_state :new end end diff --git a/spec/unit/before_after_callbacks_spec.rb b/spec/unit/before_after_callbacks_spec.rb index 6d93254e..9784befe 100644 --- a/spec/unit/before_after_callbacks_spec.rb +++ b/spec/unit/before_after_callbacks_spec.rb @@ -1,4 +1,4 @@ -require File.join(File.dirname(__FILE__), '..', 'spec_helper') +require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) class Foo2 include AASM diff --git a/spec/unit/event_spec.rb b/spec/unit/event_spec.rb index 7dd6e96e..88550963 100644 --- a/spec/unit/event_spec.rb +++ b/spec/unit/event_spec.rb @@ -1,4 +1,4 @@ -require File.join(File.dirname(__FILE__), '..', 'spec_helper') +require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) describe AASM::SupportingClasses::Event do before(:each) do diff --git a/spec/unit/state_spec.rb b/spec/unit/state_spec.rb index 0115799d..114163d9 100644 --- a/spec/unit/state_spec.rb +++ b/spec/unit/state_spec.rb @@ -1,4 +1,4 @@ -require File.join(File.dirname(__FILE__), '..', 'spec_helper') +require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) # TODO These are specs ported from original aasm describe AASM::SupportingClasses::State do diff --git a/spec/unit/state_transition_spec.rb b/spec/unit/state_transition_spec.rb index ba276549..d0812c57 100644 --- a/spec/unit/state_transition_spec.rb +++ b/spec/unit/state_transition_spec.rb @@ -1,4 +1,4 @@ -require File.join(File.dirname(__FILE__), '..', 'spec_helper') +require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) describe AASM::SupportingClasses::StateTransition do it 'should set from, to, and opts attr readers' do