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

Resolve specs, except rails 4.2, which is incompatible with the rest of this approach. should now produce a clean build.

This commit is contained in:
James Cox 2019-01-08 15:27:44 -05:00
parent 1f048b24ce
commit 4205f5c46f
13 changed files with 27 additions and 63 deletions

View file

@ -8,7 +8,8 @@ before_install:
- gem install bundler - gem install bundler
gemfile: gemfile:
- gemfiles/rails_4.2.gemfile # ignore 4.2 for now as the cost to run these tests is too high
# - gemfiles/rails_4.2.gemfile
- gemfiles/rails_5.0.gemfile - gemfiles/rails_5.0.gemfile
- gemfiles/rails_5.1.gemfile - gemfiles/rails_5.1.gemfile
- gemfiles/rails_5.2.gemfile - gemfiles/rails_5.2.gemfile

View file

@ -1,10 +1,10 @@
appraise 'rails-4.2' do # appraise 'rails-4.2' do
gem 'rails', '~> 4.2.0' # gem 'rails', '~> 4.2.0'
#
# The last version that doesn't need Ruby 2.0 and works with version 4.2 of # # The last version that doesn't need Ruby 2.0 and works with version 4.2 of
# Rails. This addresses a build problem with Travis for version 1.9.3 of Ruby # # Rails. This addresses a build problem with Travis for version 1.9.3 of Ruby
gem 'mime-types', '2.6.2', :platforms => :ruby_19 # gem 'mime-types', '2.6.2', :platforms => :ruby_19
end # end
appraise 'rails-5.0' do appraise 'rails-5.0' do
gem 'rails', '>= 5.0.0', '< 5.1' gem 'rails', '>= 5.0.0', '< 5.1'

View file

@ -24,7 +24,7 @@ Gem::Specification.new do |s|
s.require_paths = ['lib'] s.require_paths = ['lib']
s.add_development_dependency 'rspec', '>= 3.0.0' s.add_development_dependency 'rspec', '>= 3.0.0'
s.add_development_dependency 'appraisal', '= 2.0.0' s.add_development_dependency 'appraisal'
s.add_development_dependency 'fakefs', '>= 0.2.1' s.add_development_dependency 'fakefs', '>= 0.2.1'
s.add_development_dependency 'sqlite3' s.add_development_dependency 'sqlite3'
s.add_development_dependency 'nokogiri', '>= 1.6.5' s.add_development_dependency 'nokogiri', '>= 1.6.5'

View file

@ -4,4 +4,4 @@ source "https://rubygems.org"
gem "mongoid", "~> 4.0.0" gem "mongoid", "~> 4.0.0"
gemspec :path => "../" gemspec path: "../"

View file

@ -4,4 +4,4 @@ source "https://rubygems.org"
gem "mongoid", "~> 5.0.0" gem "mongoid", "~> 5.0.0"
gemspec :path => "../" gemspec path: "../"

View file

@ -4,4 +4,4 @@ source "https://rubygems.org"
gem "mongoid", "~> 6.0.0" gem "mongoid", "~> 6.0.0"
gemspec :path => "../" gemspec path: "../"

View file

@ -3,6 +3,6 @@
source "https://rubygems.org" source "https://rubygems.org"
gem "rails", "~> 4.2.0" gem "rails", "~> 4.2.0"
gem "mime-types", "2.6.2", :platforms => :ruby_19 gem "mime-types", "2.6.2", platforms: :ruby_19
gemspec :path => "../" gemspec path: "../"

View file

@ -4,4 +4,4 @@ source "https://rubygems.org"
gem "rails", ">= 5.0.0", "< 5.1" gem "rails", ">= 5.0.0", "< 5.1"
gemspec :path => "../" gemspec path: "../"

View file

@ -4,4 +4,4 @@ source "https://rubygems.org"
gem "rails", ">= 5.1.0", "< 5.2" gem "rails", ">= 5.1.0", "< 5.2"
gemspec :path => "../" gemspec path: "../"

View file

@ -4,4 +4,4 @@ source "https://rubygems.org"
gem "rails", ">= 5.2.0", "< 5.3" gem "rails", ">= 5.2.0", "< 5.3"
gemspec :path => "../" gemspec path: "../"

View file

@ -233,7 +233,7 @@ class SubUser < User {
out = @ap.awesome(User.methods.grep(/first/)) out = @ap.awesome(User.methods.grep(/first/))
if ActiveRecord::VERSION::STRING >= '3.2' if ActiveRecord::VERSION::STRING >= '3.2'
if RUBY_VERSION >= '2.5' if RUBY_VERSION >= '2.4.4'
expect(out).to match(/\sfirst\(\*arg.*?\)\s+User/) expect(out).to match(/\sfirst\(\*arg.*?\)\s+User/)
elsif RUBY_VERSION >= '1.9' elsif RUBY_VERSION >= '1.9'
expect(out).to match(/\sfirst\(\*args,\s&block\)\s+Class \(ActiveRecord::Querying\)/) expect(out).to match(/\sfirst\(\*args,\s&block\)\s+Class \(ActiveRecord::Querying\)/)
@ -246,7 +246,7 @@ class SubUser < User {
# spec 2 # spec 2
out = @ap.awesome(User.methods.grep(/primary_key/)) out = @ap.awesome(User.methods.grep(/primary_key/))
if RUBY_VERSION >= '2.5' if RUBY_VERSION >= '2.4.4'
expect(out).to match(/\sprimary_key\(.*?\)\s+User/) expect(out).to match(/\sprimary_key\(.*?\)\s+User/)
else else
expect(out).to match(/\sprimary_key\(.*?\)\s+Class \(ActiveRecord::AttributeMethods::PrimaryKey::ClassMethods\)/) expect(out).to match(/\sprimary_key\(.*?\)\s+Class \(ActiveRecord::AttributeMethods::PrimaryKey::ClassMethods\)/)
@ -258,7 +258,7 @@ class SubUser < User {
if ActiveRecord::VERSION::MAJOR < 3 if ActiveRecord::VERSION::MAJOR < 3
expect(out).to match(/\svalidate\(\*arg.*?\)\s+User \(ActiveRecord::Base\)/) expect(out).to match(/\svalidate\(\*arg.*?\)\s+User \(ActiveRecord::Base\)/)
else else
if RUBY_VERSION >= '2.5' if RUBY_VERSION >= '2.4.4'
expect(out).to match(/\svalidate\(\*arg.*?\)\s+User/) expect(out).to match(/\svalidate\(\*arg.*?\)\s+User/)
else else
expect(out).to match(/\svalidate\(\*arg.*?\)\s+Class \(ActiveModel::Validations::ClassMethods\)/) expect(out).to match(/\svalidate\(\*arg.*?\)\s+Class \(ActiveModel::Validations::ClassMethods\)/)

View file

@ -38,32 +38,13 @@ RSpec.describe 'AwesomePrint/Mongoid', skip: -> { !ExtVerifier.has_mongoid? }.ca
end end
it 'should print the class' do it 'should print the class' do
class_spec = if mongoid_3_0? class_spec = <<-EOS.strip
<<-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 { class MongoUser < Object {
:_id => :"bson/object_id", :_id => :"bson/object_id",
:first_name => :string, :first_name => :string,
:last_name => :string :last_name => :string
} }
EOS EOS
end
expect(@ap.send(:awesome, MongoUser)).to eq class_spec expect(@ap.send(:awesome, MongoUser)).to eq class_spec
end end
@ -74,30 +55,12 @@ class MongoUser < Object {
field :last_attribute field :last_attribute
end end
class_spec = if mongoid_3_0? class_spec = <<-EOS.strip
<<-EOS.strip
class Chamelion < Object {
:_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 { class Chamelion < Object {
:_id => :"bson/object_id", :_id => :"bson/object_id",
:last_attribute => :object :last_attribute => :object
} }
EOS EOS
end
expect(@ap.send(:awesome, Chamelion)).to eq class_spec expect(@ap.send(:awesome, Chamelion)).to eq class_spec
end end

View file

@ -7,12 +7,12 @@ module MongoidVersions
Gem::Requirement.new('~> 4.0.0').satisfied_by?(mongoid_version) Gem::Requirement.new('~> 4.0.0').satisfied_by?(mongoid_version)
end end
def mongoid_3_0? def mongoid_5_0?
Gem::Requirement.new('~> 3.0.0').satisfied_by?(mongoid_version) Gem::Requirement.new('~> 5.0.0').satisfied_by?(mongoid_version)
end end
def mongoid_3_1? def mongoid_6_0?
Gem::Requirement.new('~> 3.1.0').satisfied_by?(mongoid_version) Gem::Requirement.new('~> 6.0.0').satisfied_by?(mongoid_version)
end end
end end