mirror of
https://github.com/aasm/aasm
synced 2023-03-27 23:22:41 -04:00
disabling mongoid specs for Rails 4 (not yet supported by mongoid)
This commit is contained in:
parent
9d77504f9f
commit
e7c4302b87
4 changed files with 109 additions and 101 deletions
1
Gemfile
1
Gemfile
|
@ -6,5 +6,6 @@ gem 'rubysl', :platforms => :rbx
|
||||||
gem "jruby-openssl", :platforms => :jruby
|
gem "jruby-openssl", :platforms => :jruby
|
||||||
gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
|
gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
|
||||||
gem "rails", "3.2.15"
|
gem "rails", "3.2.15"
|
||||||
|
gem 'mongoid' if Gem::Version.create(RUBY_VERSION.dup) >= Gem::Version.create('1.9.3')
|
||||||
|
|
||||||
gemspec
|
gemspec
|
||||||
|
|
|
@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
||||||
# s.add_development_dependency 'activerecord', '3.2.15'
|
# s.add_development_dependency 'activerecord', '3.2.15'
|
||||||
# s.add_development_dependency 'activerecord', '4.0.1'
|
# s.add_development_dependency 'activerecord', '4.0.1'
|
||||||
|
|
||||||
s.add_development_dependency 'mongoid' if Gem::Version.create(RUBY_VERSION.dup) >= Gem::Version.create('1.9.3')
|
# s.add_development_dependency 'mongoid' if Gem::Version.create(RUBY_VERSION.dup) >= Gem::Version.create('1.9.3')
|
||||||
s.add_development_dependency 'rake'
|
s.add_development_dependency 'rake'
|
||||||
s.add_development_dependency 'sdoc'
|
s.add_development_dependency 'sdoc'
|
||||||
s.add_development_dependency 'rspec', '~> 2.14'
|
s.add_development_dependency 'rspec', '~> 2.14'
|
||||||
|
|
|
@ -6,5 +6,6 @@ gem 'rubysl', :platforms => :rbx
|
||||||
gem "jruby-openssl", :platforms => :jruby
|
gem "jruby-openssl", :platforms => :jruby
|
||||||
gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
|
gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
|
||||||
gem "rails", "3.2.15"
|
gem "rails", "3.2.15"
|
||||||
|
gem 'mongoid' if Gem::Version.create(RUBY_VERSION.dup) >= Gem::Version.create('1.9.3')
|
||||||
|
|
||||||
gemspec :path => "../"
|
gemspec :path => "../"
|
||||||
|
|
|
@ -1,131 +1,137 @@
|
||||||
describe 'mongoid', :if => Gem::Version.create(RUBY_VERSION.dup) >= Gem::Version.create('1.9.3') do
|
describe 'mongoid', :if => Gem::Version.create(RUBY_VERSION.dup) >= Gem::Version.create('1.9.3') do
|
||||||
# describe 'mongoid' do
|
# describe 'mongoid' do
|
||||||
|
|
||||||
before(:all) do
|
begin
|
||||||
require 'mongoid'
|
require 'mongoid'
|
||||||
require 'logger'
|
require 'logger'
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
Dir[File.dirname(__FILE__) + "/../../models/mongoid/*.rb"].sort.each { |f| require File.expand_path(f) }
|
|
||||||
|
|
||||||
# if you want to see the statements while running the spec enable the following line
|
before(:all) do
|
||||||
# Mongoid.logger = Logger.new(STDERR)
|
Dir[File.dirname(__FILE__) + "/../../models/mongoid/*.rb"].sort.each { |f| require File.expand_path(f) }
|
||||||
|
|
||||||
DATABASE_NAME = "mongoid_#{Process.pid}"
|
# if you want to see the statements while running the spec enable the following line
|
||||||
|
# Mongoid.logger = Logger.new(STDERR)
|
||||||
|
|
||||||
Mongoid.configure do |config|
|
DATABASE_NAME = "mongoid_#{Process.pid}"
|
||||||
config.connect_to DATABASE_NAME
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
after do
|
Mongoid.configure do |config|
|
||||||
Mongoid.purge!
|
config.connect_to DATABASE_NAME
|
||||||
end
|
|
||||||
|
|
||||||
describe "named scopes with the old DSL" do
|
|
||||||
|
|
||||||
context "Does not already respond_to? the scope name" do
|
|
||||||
it "should add a scope" do
|
|
||||||
SimpleMongoid.should respond_to(:unknown_scope)
|
|
||||||
SimpleMongoid.unknown_scope.class.should == Mongoid::Criteria
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "Already respond_to? the scope name" do
|
after do
|
||||||
it "should not add a scope" do
|
Mongoid.purge!
|
||||||
SimpleMongoid.should respond_to(:new)
|
end
|
||||||
SimpleMongoid.new.class.should == SimpleMongoid
|
|
||||||
|
describe "named scopes with the old DSL" do
|
||||||
|
|
||||||
|
context "Does not already respond_to? the scope name" do
|
||||||
|
it "should add a scope" do
|
||||||
|
puts "------------- mongoid"
|
||||||
|
SimpleMongoid.should respond_to(:unknown_scope)
|
||||||
|
SimpleMongoid.unknown_scope.class.should == Mongoid::Criteria
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
end
|
context "Already respond_to? the scope name" do
|
||||||
|
it "should not add a scope" do
|
||||||
describe "named scopes with the new DSL" do
|
SimpleMongoid.should respond_to(:new)
|
||||||
|
SimpleMongoid.new.class.should == SimpleMongoid
|
||||||
context "Does not already respond_to? the scope name" do
|
end
|
||||||
it "should add a scope" do
|
|
||||||
SimpleNewDslMongoid.should respond_to(:unknown_scope)
|
|
||||||
SimpleNewDslMongoid.unknown_scope.class.should == Mongoid::Criteria
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "Already respond_to? the scope name" do
|
describe "named scopes with the new DSL" do
|
||||||
it "should not add a scope" do
|
|
||||||
SimpleNewDslMongoid.should respond_to(:new)
|
context "Does not already respond_to? the scope name" do
|
||||||
SimpleNewDslMongoid.new.class.should == SimpleNewDslMongoid
|
it "should add a scope" do
|
||||||
|
SimpleNewDslMongoid.should respond_to(:unknown_scope)
|
||||||
|
SimpleNewDslMongoid.unknown_scope.class.should == Mongoid::Criteria
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "Already respond_to? the scope name" do
|
||||||
|
it "should not add a scope" do
|
||||||
|
SimpleNewDslMongoid.should respond_to(:new)
|
||||||
|
SimpleNewDslMongoid.new.class.should == SimpleNewDslMongoid
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it "does not create scopes if requested" do
|
||||||
|
NoScopeMongoid.should_not respond_to(:ignored_scope)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not create scopes if requested" do
|
describe "#find_in_state" do
|
||||||
NoScopeMongoid.should_not respond_to(:ignored_scope)
|
|
||||||
|
let!(:model) { SimpleNewDslMongoid.create!(:status => :unknown_scope) }
|
||||||
|
let!(:model_id) { model._id }
|
||||||
|
|
||||||
|
it "should respond to method" do
|
||||||
|
SimpleNewDslMongoid.should respond_to(:find_in_state)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should find the model when given the correct scope and model id" do
|
||||||
|
SimpleNewDslMongoid.find_in_state(model_id, 'unknown_scope').class.should == SimpleNewDslMongoid
|
||||||
|
SimpleNewDslMongoid.find_in_state(model_id, 'unknown_scope').should == model
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should raise DocumentNotFound error when given incorrect scope" do
|
||||||
|
expect {SimpleNewDslMongoid.find_in_state(model_id, 'new')}.to raise_error Mongoid::Errors::DocumentNotFound
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should raise DocumentNotFound error when given incorrect model id" do
|
||||||
|
expect {SimpleNewDslMongoid.find_in_state('bad_id', 'unknown_scope')}.to raise_error Mongoid::Errors::DocumentNotFound
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
describe "#count_in_state" do
|
||||||
|
|
||||||
describe "#find_in_state" do
|
before do
|
||||||
|
3.times { SimpleNewDslMongoid.create!(:status => :unknown_scope) }
|
||||||
|
end
|
||||||
|
|
||||||
let!(:model) { SimpleNewDslMongoid.create!(:status => :unknown_scope) }
|
it "should respond to method" do
|
||||||
let!(:model_id) { model._id }
|
SimpleNewDslMongoid.should respond_to(:count_in_state)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should return n for a scope with n records persisted" do
|
||||||
|
SimpleNewDslMongoid.count_in_state('unknown_scope').class.should == Fixnum
|
||||||
|
SimpleNewDslMongoid.count_in_state('unknown_scope').should == 3
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should return zero for a scope without records persisted" do
|
||||||
|
SimpleNewDslMongoid.count_in_state('new').class.should == Fixnum
|
||||||
|
SimpleNewDslMongoid.count_in_state('new').should == 0
|
||||||
|
end
|
||||||
|
|
||||||
it "should respond to method" do
|
|
||||||
SimpleNewDslMongoid.should respond_to(:find_in_state)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should find the model when given the correct scope and model id" do
|
describe "#with_state_scope" do
|
||||||
SimpleNewDslMongoid.find_in_state(model_id, 'unknown_scope').class.should == SimpleNewDslMongoid
|
|
||||||
SimpleNewDslMongoid.find_in_state(model_id, 'unknown_scope').should == model
|
before do
|
||||||
|
3.times { SimpleNewDslMongoid.create!(:status => :unknown_scope) }
|
||||||
|
2.times { SimpleNewDslMongoid.create!(:status => :new) }
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should respond to method" do
|
||||||
|
SimpleNewDslMongoid.should respond_to(:with_state_scope)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should correctly process block" do
|
||||||
|
SimpleNewDslMongoid.with_state_scope('unknown_scope') do
|
||||||
|
SimpleNewDslMongoid.count
|
||||||
|
end.should == 3
|
||||||
|
SimpleNewDslMongoid.with_state_scope('new') do
|
||||||
|
SimpleNewDslMongoid.count
|
||||||
|
end.should == 2
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
rescue LoadError
|
||||||
it "should raise DocumentNotFound error when given incorrect scope" do
|
puts "Not running Mongoid specs because mongoid gem if not installed!!!"
|
||||||
expect {SimpleNewDslMongoid.find_in_state(model_id, 'new')}.to raise_error Mongoid::Errors::DocumentNotFound
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should raise DocumentNotFound error when given incorrect model id" do
|
|
||||||
expect {SimpleNewDslMongoid.find_in_state('bad_id', 'unknown_scope')}.to raise_error Mongoid::Errors::DocumentNotFound
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#count_in_state" do
|
|
||||||
|
|
||||||
before do
|
|
||||||
3.times { SimpleNewDslMongoid.create!(:status => :unknown_scope) }
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should respond to method" do
|
|
||||||
SimpleNewDslMongoid.should respond_to(:count_in_state)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should return n for a scope with n records persisted" do
|
|
||||||
SimpleNewDslMongoid.count_in_state('unknown_scope').class.should == Fixnum
|
|
||||||
SimpleNewDslMongoid.count_in_state('unknown_scope').should == 3
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should return zero for a scope without records persisted" do
|
|
||||||
SimpleNewDslMongoid.count_in_state('new').class.should == Fixnum
|
|
||||||
SimpleNewDslMongoid.count_in_state('new').should == 0
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#with_state_scope" do
|
|
||||||
|
|
||||||
before do
|
|
||||||
3.times { SimpleNewDslMongoid.create!(:status => :unknown_scope) }
|
|
||||||
2.times { SimpleNewDslMongoid.create!(:status => :new) }
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should respond to method" do
|
|
||||||
SimpleNewDslMongoid.should respond_to(:with_state_scope)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should correctly process block" do
|
|
||||||
SimpleNewDslMongoid.with_state_scope('unknown_scope') do
|
|
||||||
SimpleNewDslMongoid.count
|
|
||||||
end.should == 3
|
|
||||||
SimpleNewDslMongoid.with_state_scope('new') do
|
|
||||||
SimpleNewDslMongoid.count
|
|
||||||
end.should == 2
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue