1
0
Fork 0
mirror of https://github.com/awesome-print/awesome_print synced 2023-03-27 23:22:34 -04:00

Adds further Appraisals for mongoid, mongo_mapper and ripple. Fixes mongoid specs and Ripple

This commit is contained in:
James Cox 2014-12-31 13:41:17 -05:00
parent eff2239e37
commit e3a9a3d638
14 changed files with 133 additions and 43 deletions

View file

@ -1,31 +1,39 @@
appraise 'rails-3.2' do
gem 'activesupport', '~> 3.2.0'
gem 'activerecord', '~> 3.2.0'
gem 'rails', '~> 3.2.0'
end
appraise 'rails-4.0' do
gem 'rails', '~> 4.0.0'
end
appraise 'rails-4.1' do
gem 'rails', '~> 4.1.0'
end
appraise 'rails-4.2' do
gem 'rails', '~> 4.2.0'
end
appraise 'mongoid-3.0' do
gem 'rails', '~> 3.2.0'
gem 'mongoid', '~> 3.0.0'
end
appraise 'mongoid-3.1' do
gem 'activesupport', '~> 3.2.0'
gem 'activerecord', '~> 3.2.0'
gem 'rails', '~> 3.2.0'
gem 'mongoid', '~> 3.1.0'
end
appraise 'rails-4.0' do
gem 'activesupport', '~> 4.0.0'
gem 'activerecord', '~> 4.0.0'
end
appraise 'rails-4.1' do
gem 'activesupport', '~> 4.1.0'
gem 'actionview', '~> 4.1.0'
gem 'activerecord', '~> 4.1.0'
appraise 'mongoid-4.0' do
gem 'rails', '~> 4.2.0'
gem 'mongoid', '~> 4.0.0'
end
appraise 'rails-4.2' do
gem 'activesupport', '~> 4.2.0'
gem 'actionview', '~> 4.2.0'
gem 'activerecord', '~> 4.2.0'
gem 'mongoid', '~> 4.0.0'
appraise 'mongo_mapper' do
gem 'mongo_mapper'
end
appraise 'ripple' do
gem 'tzinfo'
gem 'ripple'
end

View file

@ -0,0 +1,7 @@
# This file was generated by Appraisal
source "https://rubygems.org"
gem "mongo_mapper"
gemspec :path => "../"

View file

@ -0,0 +1,8 @@
# This file was generated by Appraisal
source "https://rubygems.org"
gem "rails", "~> 3.2.0"
gem "mongoid", "~> 3.0.0"
gemspec :path => "../"

View file

@ -2,8 +2,7 @@
source "https://rubygems.org"
gem "activesupport", "~> 3.2.0"
gem "activerecord", "~> 3.2.0"
gem "rails", "~> 3.2.0"
gem "mongoid", "~> 3.1.0"
gemspec :path => "../"

View file

@ -0,0 +1,8 @@
# This file was generated by Appraisal
source "https://rubygems.org"
gem "rails", "~> 4.2.0"
gem "mongoid", "~> 4.0.0"
gemspec :path => "../"

View file

@ -2,8 +2,6 @@
source "https://rubygems.org"
gem "activesupport", "~> 3.2.0"
gem "activerecord", "~> 3.2.0"
gem "mongoid", "~> 3.0.0"
gem "rails", "~> 3.2.0"
gemspec :path => "../"

View file

@ -2,7 +2,6 @@
source "https://rubygems.org"
gem "activesupport", "~> 4.0.0"
gem "activerecord", "~> 4.0.0"
gem "rails", "~> 4.0.0"
gemspec :path => "../"

View file

@ -2,9 +2,6 @@
source "https://rubygems.org"
gem "activesupport", "~> 4.1.0"
gem "actionview", "~> 4.1.0"
gem "activerecord", "~> 4.1.0"
gem "mongoid", "~> 4.0.0"
gem "rails", "~> 4.1.0"
gemspec :path => "../"

View file

@ -2,9 +2,6 @@
source "https://rubygems.org"
gem "activesupport", "~> 4.2.0"
gem "actionview", "~> 4.2.0"
gem "activerecord", "~> 4.2.0"
gem "mongoid", "~> 4.0.0"
gem "rails", "~> 4.2.0"
gemspec :path => "../"

8
gemfiles/ripple.gemfile Normal file
View file

@ -0,0 +1,8 @@
# This file was generated by Appraisal
source "https://rubygems.org"
gem "tzinfo"
gem "ripple"
gemspec :path => "../"

View file

@ -52,7 +52,7 @@ module AwesomePrint
end
end
"##{object} " << awesome_hash(data)
"#{object} " << awesome_hash(data)
end
# Format Ripple class object.

View file

@ -41,13 +41,34 @@ EOS
end
it "should print the class" do
expect(@ap.send(:awesome, MongoUser)).to eq <<-EOS.strip
class_spec = if mongoid_3_0?
<<-EOS.strip
class MongoUser < Object {
:_id => :"moped/bson/object_id",
:_type => :string,
:first_name => :string,
:last_name => :string
}
EOS
elsif mongoid_3_1?
<<-EOS.strip
class MongoUser < Object {
:_id => :"moped/bson/object_id",
:first_name => :string,
:last_name => :string
}
EOS
elsif mongoid_4_0?
<<-EOS.strip
class MongoUser < Object {
:_id => :"bson/object_id",
:first_name => :string,
:last_name => :string
}
EOS
EOS
end
expect(@ap.send(:awesome, MongoUser)).to eq class_spec
end
it "should print the class when type is undefined" do
@ -56,13 +77,32 @@ EOS
field :last_attribute
end
last_attribute = defined?(::Moped) ? 'object' : '"mongoid/fields/serializable/object"'
expect(@ap.send(:awesome, Chamelion)).to eq <<-EOS.strip
class_spec = if mongoid_3_0?
<<-EOS.strip
class Chamelion < Object {
:_id => :"bson/object_id",
:last_attribute => :#{last_attribute}
:_id => :"moped/bson/object_id",
:_type => :string,
:last_attribute => :object
}
EOS
elsif mongoid_3_1?
<<-EOS.strip
class Chamelion < Object {
:_id => :"moped/bson/object_id",
:last_attribute => :object
}
EOS
elsif mongoid_4_0?
<<-EOS.strip
class Chamelion < Object {
:_id => :"bson/object_id",
:last_attribute => :object
}
EOS
end
expect(@ap.send(:awesome, Chamelion)).to eq class_spec
end
end

View file

@ -29,8 +29,8 @@ begin
user = RippleUser.new :_id => "12345", :first_name => "Al", :last_name => "Capone"
out = @ap.send :awesome, user
expect(out).to eq <<-EOS.strip
#<RippleUser:12345> {
expect(out.gsub(/0x([a-f\d]+)/, "0x01234567")).to eq <<-EOS.strip
#<RippleUser:0x01234567> {
:_id => "12345",
:first_name => "Al",
:last_name => "Capone"
@ -42,7 +42,6 @@ EOS
expect(@ap.send(:awesome, RippleUser)).to eq <<-EOS.strip
class RippleUser < Object {
:_id => :string,
:_type => :string,
:first_name => :string,
:last_name => :string
}

View file

@ -0,0 +1,22 @@
module MongoidVersions
def mongoid_version
Gem::Version.new(Mongoid::VERSION)
end
def mongoid_4_0?
Gem::Requirement.new('~> 4.0.0').satisfied_by?(mongoid_version)
end
def mongoid_3_0?
Gem::Requirement.new('~> 3.0.0').satisfied_by?(mongoid_version)
end
def mongoid_3_1?
Gem::Requirement.new('~> 3.1.0').satisfied_by?(mongoid_version)
end
end
RSpec.configure do |config|
config.include(MongoidVersions)
config.extend(MongoidVersions)
end