From 11d48862ddd04fa27b6c63517c3277ec4f6d89bb Mon Sep 17 00:00:00 2001 From: Martin Emde Date: Mon, 26 Jan 2015 12:19:17 -0800 Subject: [PATCH 1/8] Modernize the gemspec and Gemfile. Remove jeweler. --- Gemfile | 9 +-------- dm-active_model.gemspec | 6 ++++-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Gemfile b/Gemfile index 803f95f..7105289 100644 --- a/Gemfile +++ b/Gemfile @@ -16,11 +16,6 @@ gem 'activemodel', RAILS_VERSION, :require => nil group :development do gem 'dm-validations', DM_VERSION, SOURCE => "#{DATAMAPPER}/dm-validations#{REPO_POSTFIX}", :branch => CURRENT_BRANCH - - gem 'jeweler', '~> 1.6.4' - gem 'rake', '~> 0.9.2' - gem 'rspec', '~> 1.3.2' - gem 'test-unit', '= 1.2.3' end platforms :mri_18 do @@ -39,9 +34,7 @@ group :datamapper do plugins = plugins.to_s.tr(',', ' ').split.uniq plugins.each do |plugin| - gem plugin, DM_VERSION, - SOURCE => "#{DATAMAPPER}/#{plugin}#{REPO_POSTFIX}", - :branch => CURRENT_BRANCH + gem plugin, DM_VERSION, SOURCE => "#{DATAMAPPER}/#{plugin}#{REPO_POSTFIX}", :branch => CURRENT_BRANCH end end diff --git a/dm-active_model.gemspec b/dm-active_model.gemspec index 14b8cdc..afceb96 100644 --- a/dm-active_model.gemspec +++ b/dm-active_model.gemspec @@ -7,6 +7,7 @@ Gem::Specification.new do |gem| gem.summary = "active_model compliance for datamapper" gem.description = 'A datamapper plugin for active_model compliance and thus rails 3 compatibility.' gem.homepage = "http://datamapper.org" + gem.license = 'MIT' gem.files = `git ls-files`.split("\n") gem.test_files = `git ls-files -- {spec}/*`.split("\n") @@ -19,7 +20,8 @@ Gem::Specification.new do |gem| gem.add_runtime_dependency('dm-core', '~> 1.2', '>= 1.2.0') gem.add_runtime_dependency('activemodel', '>= 3.0', '< 5.0') - gem.add_development_dependency('rake', '~> 0.9.2') - gem.add_development_dependency('rspec', '~> 1.3.2') + gem.add_development_dependency('dm-validations', '~> 1.2') + gem.add_development_dependency('rake', '~> 0.9') + gem.add_development_dependency('rspec', '~> 1.3') gem.add_development_dependency('test-unit', '= 1.2.3') end From 594a8d3adc3fd414723f43da752a65693b86a914 Mon Sep 17 00:00:00 2001 From: Martin Emde Date: Mon, 26 Jan 2015 15:54:33 -0800 Subject: [PATCH 2/8] Build on travis --- .travis.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..78f2e0c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: ruby +sudo: false +rvm: + - 1.9.3 + - 2.0.0 + - 2.1.5 + - 2.2.0 +matrix: + allow_failures: + - rvm: 2.1.5 + - rvm: 2.2.0 From 7712be35cbf0b46573cc149b81af76a93c70d957 Mon Sep 17 00:00:00 2001 From: Dan Kubb Date: Tue, 25 Jun 2013 13:06:00 -0700 Subject: [PATCH 3/8] Update dm-rails to work with rails 4 --- Gemfile | 2 +- lib/dm-active_model.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 7105289..6f76f14 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gemspec SOURCE = ENV.fetch('SOURCE', :git).to_sym REPO_POSTFIX = SOURCE == :path ? '' : '.git' DATAMAPPER = SOURCE == :path ? Pathname(__FILE__).dirname.parent : 'http://github.com/datamapper' -DM_VERSION = '~> 1.3.0.beta' +DM_VERSION = '~> 1.2' RAILS_VERSION = [ '>= 3.0', '< 5.0' ] CURRENT_BRANCH = ENV.fetch('GIT_BRANCH', 'master') diff --git a/lib/dm-active_model.rb b/lib/dm-active_model.rb index 9d295eb..e33f0a6 100644 --- a/lib/dm-active_model.rb +++ b/lib/dm-active_model.rb @@ -1,5 +1,6 @@ require 'dm-core' require 'active_support/core_ext/module/delegation' # needed by active_model/naming +require 'active_support/core_ext/module/remove_method' # needed for Module.remove_possible_method in active_model/naming.rb (active_model ~> 4.1) require 'active_support/concern' # needed by active_model/conversion require 'active_model/naming' require 'active_model/conversion' From f1bb018a53cdc266a8569bb062b87b8bdb98e220 Mon Sep 17 00:00:00 2001 From: Martin Emde Date: Tue, 27 Jan 2015 16:21:06 -0800 Subject: [PATCH 4/8] More future-proof testing with Lint We previously were relying on Lint to never add new tests. --- spec/amo_interface_compliance_spec.rb | 31 ++++----------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/spec/amo_interface_compliance_spec.rb b/spec/amo_interface_compliance_spec.rb index 2b7df48..f9ba267 100644 --- a/spec/amo_interface_compliance_spec.rb +++ b/spec/amo_interface_compliance_spec.rb @@ -14,32 +14,9 @@ include ActiveModel::Lint::Tests - it 'must implement the #to_key interface' do - test_to_key - end - - it 'must implement the #to_param interface' do - test_to_param - end - - it 'must implement the #to_partial_path interface' do - test_to_partial_path if respond_to?(:test_to_partial_path) - end - - it 'must implement the #valid? interface' do - test_valid? if respond_to?(:test_valid?) - end - - it 'must implement the #persisted? interface' do - test_persisted? - end - - it 'must implement the .model_name interface' do - test_model_naming - end - - it 'must implement the #errors interface' do - test_errors_aref - test_errors_full_messages if respond_to?(:test_errors_full_messages) + instance_methods.grep(/^test_/).each do |meth| + it meth.to_s do + send(meth) + end end end From d3c6278fddfdcc60f9790db19b9ec008889e9419 Mon Sep 17 00:00:00 2001 From: Martin Emde Date: Tue, 3 Feb 2015 09:57:43 -0800 Subject: [PATCH 5/8] Remove 2.1.5 from allow failures in travis --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 78f2e0c..145e8ad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,5 +7,4 @@ rvm: - 2.2.0 matrix: allow_failures: - - rvm: 2.1.5 - rvm: 2.2.0 From 4d0b0441f13335b407225b5f5f147be858d358de Mon Sep 17 00:00:00 2001 From: Martin Emde Date: Thu, 26 Feb 2015 16:06:57 -0800 Subject: [PATCH 6/8] RSpec 2.99 compatible --- dm-active_model.gemspec | 4 +- spec/amo_interface_compliance_examples.rb | 10 +++++ spec/amo_interface_compliance_spec.rb | 22 ----------- ... => amo_validation_compliance_examples.rb} | 6 +-- spec/dm-active_model_spec.rb | 20 ++-------- spec/spec.opts | 2 - spec/spec_helper.rb | 20 ++++++++++ tasks/spec.rake | 39 +------------------ 8 files changed, 39 insertions(+), 84 deletions(-) create mode 100644 spec/amo_interface_compliance_examples.rb delete mode 100644 spec/amo_interface_compliance_spec.rb rename spec/{amo_validation_compliance_spec.rb => amo_validation_compliance_examples.rb} (66%) delete mode 100644 spec/spec.opts create mode 100644 spec/spec_helper.rb diff --git a/dm-active_model.gemspec b/dm-active_model.gemspec index afceb96..3d07bfe 100644 --- a/dm-active_model.gemspec +++ b/dm-active_model.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |gem| gem.add_runtime_dependency('activemodel', '>= 3.0', '< 5.0') gem.add_development_dependency('dm-validations', '~> 1.2') - gem.add_development_dependency('rake', '~> 0.9') - gem.add_development_dependency('rspec', '~> 1.3') + gem.add_development_dependency('rake', '~> 10.0') + gem.add_development_dependency('rspec', '~> 2.0') gem.add_development_dependency('test-unit', '= 1.2.3') end diff --git a/spec/amo_interface_compliance_examples.rb b/spec/amo_interface_compliance_examples.rb new file mode 100644 index 0000000..191c70f --- /dev/null +++ b/spec/amo_interface_compliance_examples.rb @@ -0,0 +1,10 @@ +RSpec.shared_examples_for 'an active_model compliant object' do + + include ActiveModel::Lint::Tests + + instance_methods.grep(/^test_/).each do |meth| + it meth.to_s do + send(meth) + end + end +end diff --git a/spec/amo_interface_compliance_spec.rb b/spec/amo_interface_compliance_spec.rb deleted file mode 100644 index f9ba267..0000000 --- a/spec/amo_interface_compliance_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'spec/test/unit' -require 'active_support/core_ext/object/blank' # needed by active_model/lint -require 'active_model/lint' -require 'active_support/core_ext/string' - -# This must be kept in sync with active_model/lint tests -# at least for as long as -# -# http://rspec.lighthouseapp.com/projects/5645/tickets/900 -# -# isn't resolved in some way (probably with rspec2) - -share_examples_for 'an active_model compliant object' do - - include ActiveModel::Lint::Tests - - instance_methods.grep(/^test_/).each do |meth| - it meth.to_s do - send(meth) - end - end -end diff --git a/spec/amo_validation_compliance_spec.rb b/spec/amo_validation_compliance_examples.rb similarity index 66% rename from spec/amo_validation_compliance_spec.rb rename to spec/amo_validation_compliance_examples.rb index fd61bf9..bd8d733 100644 --- a/spec/amo_validation_compliance_spec.rb +++ b/spec/amo_validation_compliance_examples.rb @@ -1,8 +1,4 @@ -require 'spec/test/unit' -require 'lib/amo_lint_extensions' - -share_examples_for 'an active_model/validations compliant object' do - +RSpec.shared_examples_for 'an active_model/validations compliant object' do include ActiveModel::Lint::Tests::Validations ActiveModel::Lint::Tests::Validations::VALIDATION_METHODS.each do |validation_method| diff --git a/spec/dm-active_model_spec.rb b/spec/dm-active_model_spec.rb index ccd3f1b..1850a3e 100644 --- a/spec/dm-active_model_spec.rb +++ b/spec/dm-active_model_spec.rb @@ -1,17 +1,7 @@ -require 'dm-core' -require 'dm-active_model' - -require 'amo_interface_compliance_spec' - -if ENV['DM_VALIDATIONS'] || ENV['AMO_VALIDATIONS'] - require 'dm-validations' - require 'amo_validation_compliance_spec' -end - -describe 'An active_model compliant DataMapper::Resource' do +require 'spec_helper' +RSpec.describe 'An active_model compliant DataMapper::Resource' do before :all do - module ::ComplianceTest class ProfileInfo include DataMapper::Resource @@ -21,17 +11,15 @@ class ProfileInfo end DataMapper.setup(:default, { :adapter => :in_memory }) - end before :each do @model = ComplianceTest::ProfileInfo.new.to_model end - it_should_behave_like 'an active_model compliant object' + include_examples 'an active_model compliant object' if ENV['AMO_VALIDATIONS'] == 'true' - it_should_behave_like 'an active_model/validations compliant object' + include_examples 'an active_model/validations compliant object' end - end diff --git a/spec/spec.opts b/spec/spec.opts deleted file mode 100644 index e0f74bb..0000000 --- a/spec/spec.opts +++ /dev/null @@ -1,2 +0,0 @@ ---format specdoc ---colour diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..ad6842a --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,20 @@ +require 'rspec' +require 'test/unit/assertions' + +require 'dm-core' +require 'dm-active_model' + +require 'active_support/core_ext/object/blank' # needed by active_model/lint +require 'active_model/lint' + +require 'amo_interface_compliance_examples' + +if ENV['DM_VALIDATIONS'] || ENV['AMO_VALIDATIONS'] + require 'dm-validations' + require 'lib/amo_lint_extensions' + require 'amo_validation_compliance_examples' +end + +RSpec.configure do |config| + config.include Test::Unit::Assertions +end diff --git a/tasks/spec.rake b/tasks/spec.rake index 652b946..45a7860 100644 --- a/tasks/spec.rake +++ b/tasks/spec.rake @@ -1,38 +1,3 @@ -spec_defaults = lambda do |spec| - spec.pattern = 'spec/**/*_spec.rb' - spec.libs << 'lib' << 'spec' - spec.spec_opts << '--options' << 'spec/spec.opts' -end - -begin - require 'spec/rake/spectask' - - Spec::Rake::SpecTask.new(:spec, &spec_defaults) -rescue LoadError - task :spec do - abort 'rspec is not available. In order to run spec, you must: gem install rspec' - end -end - -begin - require 'rcov' - require 'spec/rake/verify_rcov' - - Spec::Rake::SpecTask.new(:rcov) do |rcov| - spec_defaults.call(rcov) - rcov.rcov = true - rcov.rcov_opts = File.read('spec/rcov.opts').split(/\s+/) - end - - RCov::VerifyTask.new(:verify_rcov => :rcov) do |rcov| - rcov.threshold = 100 - end -rescue LoadError - %w[ rcov verify_rcov ].each do |name| - task name do - abort "rcov is not available. In order to run #{name}, you must: gem install rcov" - end - end -end - +require 'rspec/core/rake_task' +RSpec::Core::RakeTask.new(:spec) task :default => :spec From e4f5db9ab9d585331ebb6fc19064ee11170f291f Mon Sep 17 00:00:00 2001 From: Martin Emde Date: Thu, 26 Feb 2015 17:08:25 -0800 Subject: [PATCH 7/8] rspec ~> 3.0 --- dm-active_model.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dm-active_model.gemspec b/dm-active_model.gemspec index 3d07bfe..812e479 100644 --- a/dm-active_model.gemspec +++ b/dm-active_model.gemspec @@ -22,6 +22,6 @@ Gem::Specification.new do |gem| gem.add_development_dependency('dm-validations', '~> 1.2') gem.add_development_dependency('rake', '~> 10.0') - gem.add_development_dependency('rspec', '~> 2.0') + gem.add_development_dependency('rspec', '~> 3.0') gem.add_development_dependency('test-unit', '= 1.2.3') end From 7b94e0d0504ada704d55f80f577995cfa7e59b73 Mon Sep 17 00:00:00 2001 From: Martin Emde Date: Thu, 26 Feb 2015 17:41:24 -0800 Subject: [PATCH 8/8] rspec 2.0 fixes ruby 2.2.0, require it in travis --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 145e8ad..129d139 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,3 @@ rvm: - 2.0.0 - 2.1.5 - 2.2.0 -matrix: - allow_failures: - - rvm: 2.2.0