Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Rebase ardm changes on top of most recent DM master to make this releasable as dm-active_model 1.3 #5

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
language: ruby
sudo: false
rvm:
- 1.9.3
- 2.0.0
- 2.1.5
- 2.2.0
11 changes: 2 additions & 9 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -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
Expand All @@ -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
6 changes: 4 additions & 2 deletions dm-active_model.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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', '~> 10.0')
gem.add_development_dependency('rspec', '~> 3.0')
gem.add_development_dependency('test-unit', '= 1.2.3')
end
1 change: 1 addition & 0 deletions lib/dm-active_model.rb
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
10 changes: 10 additions & 0 deletions spec/amo_interface_compliance_examples.rb
Original file line number Diff line number Diff line change
@@ -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
45 changes: 0 additions & 45 deletions spec/amo_interface_compliance_spec.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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|
Expand Down
20 changes: 4 additions & 16 deletions spec/dm-active_model_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
2 changes: 0 additions & 2 deletions spec/spec.opts

This file was deleted.

20 changes: 20 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -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
39 changes: 2 additions & 37 deletions tasks/spec.rake
Original file line number Diff line number Diff line change
@@ -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