dm-active_model 0.4.0 → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,7 +1,35 @@
1
- *.sw?
1
+ ## MAC OS
2
2
  .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## Rubinius
17
+ *.rbc
18
+
19
+ ## PROJECT::GENERAL
20
+ *.gem
3
21
  coverage
4
22
  rdoc
5
23
  pkg
24
+ tmp
25
+ doc
26
+ log
27
+ .yardoc
28
+ measurements
29
+
30
+ ## BUNDLER
6
31
  .bundle
32
+ Gemfile.local
33
+ Gemfile.lock
7
34
 
35
+ ## PROJECT::SPECIFIC
data/Gemfile CHANGED
@@ -1,27 +1,115 @@
1
- # This will setup a complete development environment
1
+ # If you're working on more than one datamapper gem at a time, then it's
2
+ # recommended to create a local Gemfile and use this instead of the git
3
+ # sources. This will make sure that you are developing against your
4
+ # other local datamapper sources that you currently work on. Gemfile.local
5
+ # will behave identically to the standard Gemfile apart from the fact that
6
+ # it fetches the datamapper gems from local paths. This means that you can use
7
+ # the same environment variables, like ADAPTER(S) or PLUGIN(S) when running
8
+ # bundle commands. Gemfile.local is added to .gitignore, so you don't need to
9
+ # worry about accidentally checking local development paths into git.
10
+ # In order to create a local Gemfile, all you need to do is run:
2
11
  #
3
- # git clone git://github.com/snusnu/dm-active_model
4
- # cd dm-active_model
5
- # gem install bundler (if you haven't done so before)
6
- # bundle install
7
- # rake spec
12
+ # bundle exec rake local_gemfile
8
13
  #
14
+ # This will give you a Gemfile.local file that points to your local clones of
15
+ # the various datamapper gems. It's assumed that all datamapper repo clones
16
+ # reside in the same directory. You can use the Gemfile.local like so for
17
+ # running any bundle command:
18
+ #
19
+ # BUNDLE_GEMFILE=Gemfile.local bundle foo
20
+ #
21
+ # You can also specify which adapter(s) should be part of the bundle by setting
22
+ # an environment variable. This of course also works when using the Gemfile.local
23
+ #
24
+ # bundle foo # dm-sqlite-adapter
25
+ # ADAPTER=mysql bundle foo # dm-mysql-adapter
26
+ # ADAPTERS=sqlite,mysql bundle foo # dm-sqlite-adapter and dm-mysql-adapter
27
+ #
28
+ # Of course you can also use the ADAPTER(S) variable when using the Gemfile.local
29
+ # and running specs against selected adapters.
30
+ #
31
+ # For easily working with adapters supported on your machine, it's recommended
32
+ # that you first install all adapters that you are planning to use or work on
33
+ # by doing something like
34
+ #
35
+ # ADAPTERS=sqlite,mysql,postgres bundle install
36
+ #
37
+ # This will clone the various repositories and make them available to bundler.
38
+ # Once you have them installed you can easily switch between adapters for the
39
+ # various development tasks. Running something like
40
+ #
41
+ # ADAPTER=mysql bundle exec rake spec
42
+ #
43
+ # will make sure that the dm-mysql-adapter is part of the bundle, and will be used
44
+ # when running the specs.
45
+ #
46
+ # You can also specify which plugin(s) should be part of the bundle by setting
47
+ # an environment variable. This also works when using the Gemfile.local
48
+ #
49
+ # bundle foo # dm-migrations
50
+ # PLUGINS=dm-validations bundle foo # dm-migrations and dm-validations
51
+ # PLUGINS=dm-validations,dm-types bundle foo # dm-migrations, dm-validations and dm-types
52
+ #
53
+ # Of course you can combine the PLUGIN(S) and ADAPTER(S) env vars to run specs
54
+ # for certain adapter/plugin combinations.
55
+ #
56
+ # Finally, to speed up running specs and other tasks, it's recommended to run
57
+ #
58
+ # bundle lock
59
+ #
60
+ # after running 'bundle install' for the first time. This will make 'bundle exec' run
61
+ # a lot faster compared to the unlocked version. With an unlocked bundle you would
62
+ # typically just run 'bundle install' from time to time to fetch the latest sources from
63
+ # upstream. When you locked your bundle, you need to run
64
+ #
65
+ # bundle install --relock
66
+ #
67
+ # to make sure to fetch the latest updates and then lock the bundle again. Gemfile.lock
68
+ # is added to the .gitignore file, so you don't need to worry about accidentally checking
69
+ # it into version control.
70
+
71
+ source 'http://rubygems.org'
72
+
73
+ DATAMAPPER = 'git://github.com/datamapper'
74
+ DM_VERSION = '~> 1.0.0.rc1'
75
+
76
+ group :runtime do # Runtime dependencies (as in the gemspec)
77
+
78
+ gem 'dm-core', DM_VERSION, :git => "#{DATAMAPPER}/dm-core.git"
79
+ gem 'activesupport', '~> 3.0.0.beta3', :git => 'git://github.com/rails/rails.git', :require => nil
80
+ gem 'activemodel', '~> 3.0.0.beta3', :git => 'git://github.com/rails/rails.git', :require => nil
81
+
82
+ end
9
83
 
10
- source 'http://gemcutter.org'
84
+ group(:development) do # Development dependencies (as in the gemspec)
11
85
 
12
- git 'git://github.com/rails/rails.git'
13
- gem 'activesupport', '~> 3.0.0.beta1', :require => 'active_support'
14
- gem 'activemodel', '~> 3.0.0.beta1', :require => 'active_model'
86
+ gem 'dm-validations', DM_VERSION, :git => "#{DATAMAPPER}/dm-validations.git"
15
87
 
16
- git 'git://github.com/snusnu/dm-core.git', 'branch' => 'active_support'
17
- gem 'dm-core', '~> 0.10'
88
+ gem 'rake', '~> 0.8.7'
89
+ gem 'rspec', '~> 1.3'
90
+ gem 'jeweler', '~> 1.4'
91
+ gem 'test-unit', '= 1.2.3'
18
92
 
19
- group(:test) do
20
- gem 'rspec', '~> 1.3'
21
- gem 'do_sqlite3', '~> 0.10.1'
22
93
  end
23
94
 
24
- group(:development) do
25
- gem 'rake'
26
- gem 'jeweler', '~> 1.4'
95
+ group :quality do # These gems contain rake tasks that check the quality of the source code
96
+
97
+ gem 'metric_fu', '~> 1.3'
98
+ gem 'rcov', '~> 0.9.7'
99
+ gem 'reek', '~> 1.2.7'
100
+ gem 'roodi', '~> 2.1'
101
+ gem 'yard', '~> 0.5'
102
+ gem 'yardstick', '~> 0.1'
103
+
104
+ end
105
+
106
+ group :datamapper do # We need this because we want to pin these dependencies to their git master sources
107
+
108
+ plugins = ENV['PLUGINS'] || ENV['PLUGIN']
109
+ plugins = (plugins.to_s.gsub(',',' ').split(' ')).uniq
110
+
111
+ plugins.each do |plugin|
112
+ gem plugin, DM_VERSION, :git => "#{DATAMAPPER}/#{plugin}.git"
113
+ end
114
+
27
115
  end
data/Rakefile CHANGED
@@ -1,39 +1,25 @@
1
- begin
2
- # Just in case the bundle was locked
3
- # This shouldn't happen in a dev environment but lets be safe
4
- require File.expand_path('../../.bundle/environment', __FILE__)
5
- rescue LoadError
6
- require 'rubygems'
7
- require 'bundler'
8
- Bundler.setup
9
- end
10
-
11
- Bundler.require(:default, :development, :test)
12
-
1
+ require 'rubygems'
13
2
  require 'rake'
14
3
 
15
- require File.expand_path('../lib/dm-active_model/version', __FILE__)
16
-
17
4
  begin
18
5
 
19
- gem 'jeweler', '~> 1.4'
20
6
  require 'jeweler'
21
7
 
22
8
  Jeweler::Tasks.new do |gem|
23
9
 
24
- gem.version = DataMapper::ActiveModel::VERSION
25
-
26
10
  gem.name = 'dm-active_model'
27
11
  gem.summary = 'active_model compliance for datamapper'
28
12
  gem.description = 'A datamapper plugin for active_model compliance and thus rails 3 compatibility.'
29
13
  gem.email = 'gamsnjaga [a] gmail [d] com'
30
- gem.homepage = 'http://github.com/snusnu/dm-active_model'
14
+ gem.homepage = 'http://github.com/datamapper/dm-active_model'
31
15
  gem.authors = [ 'Martin Gamsjaeger (snusnu)' ]
32
16
 
33
- gem.add_dependency 'dm-core', '~> 0.10'
17
+ gem.add_dependency 'dm-core', '~> 1.0.0.rc1'
18
+ gem.add_dependency 'activemodel', '~> 3.0.0.beta3'
34
19
 
35
- gem.add_development_dependency 'rspec', '>= 1.2.9'
36
- gem.add_development_dependency 'yard', '~> 0.5'
20
+ gem.add_development_dependency 'dm-validations', '~> 1.0.0.rc1'
21
+ gem.add_development_dependency 'rspec', '~> 1.3'
22
+ gem.add_development_dependency 'test-unit', '= 1.2.3'
37
23
 
38
24
  end
39
25
 
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0.rc1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{dm-active_model}
8
- s.version = "0.4.0"
8
+ s.version = "1.0.0.rc1"
9
9
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Martin Gamsjaeger (snusnu)"]
12
- s.date = %q{2010-02-23}
12
+ s.date = %q{2010-05-19}
13
13
  s.description = %q{A datamapper plugin for active_model compliance and thus rails 3 compatibility.}
14
14
  s.email = %q{gamsnjaga [a] gmail [d] com}
15
15
  s.extra_rdoc_files = [
@@ -26,30 +26,34 @@ Gem::Specification.new do |s|
26
26
  "README.rdoc",
27
27
  "Rakefile",
28
28
  "TODO",
29
+ "VERSION",
29
30
  "dm-active_model.gemspec",
30
31
  "lib/dm-active_model.rb",
31
32
  "lib/dm-active_model/version.rb",
32
- "spec/amo_compliance_spec.rb",
33
+ "spec/amo_interface_compliance_spec.rb",
34
+ "spec/amo_validation_compliance_spec.rb",
33
35
  "spec/dm-active_model_spec.rb",
36
+ "spec/lib/amo_lint_extensions.rb",
34
37
  "spec/rcov.opts",
35
38
  "spec/spec.opts",
36
- "spec/spec_helper.rb",
37
39
  "tasks/changelog.rake",
38
40
  "tasks/ci.rake",
41
+ "tasks/local_gemfile.rake",
39
42
  "tasks/metrics.rake",
40
43
  "tasks/spec.rake",
41
44
  "tasks/yard.rake",
42
45
  "tasks/yardstick.rake"
43
46
  ]
44
- s.homepage = %q{http://github.com/snusnu/dm-active_model}
47
+ s.homepage = %q{http://github.com/datamapper/dm-active_model}
45
48
  s.rdoc_options = ["--charset=UTF-8"]
46
49
  s.require_paths = ["lib"]
47
50
  s.rubygems_version = %q{1.3.6}
48
51
  s.summary = %q{active_model compliance for datamapper}
49
52
  s.test_files = [
50
- "spec/amo_compliance_spec.rb",
53
+ "spec/amo_interface_compliance_spec.rb",
54
+ "spec/amo_validation_compliance_spec.rb",
51
55
  "spec/dm-active_model_spec.rb",
52
- "spec/spec_helper.rb"
56
+ "spec/lib/amo_lint_extensions.rb"
53
57
  ]
54
58
 
55
59
  if s.respond_to? :specification_version then
@@ -57,18 +61,24 @@ Gem::Specification.new do |s|
57
61
  s.specification_version = 3
58
62
 
59
63
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
60
- s.add_runtime_dependency(%q<dm-core>, ["~> 0.10"])
61
- s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
62
- s.add_development_dependency(%q<yard>, ["~> 0.5"])
64
+ s.add_runtime_dependency(%q<dm-core>, ["~> 1.0.0.rc1"])
65
+ s.add_runtime_dependency(%q<activemodel>, ["~> 3.0.0.beta3"])
66
+ s.add_development_dependency(%q<dm-validations>, ["~> 1.0.0.rc1"])
67
+ s.add_development_dependency(%q<rspec>, ["~> 1.3"])
68
+ s.add_development_dependency(%q<test-unit>, ["= 1.2.3"])
63
69
  else
64
- s.add_dependency(%q<dm-core>, ["~> 0.10"])
65
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
66
- s.add_dependency(%q<yard>, ["~> 0.5"])
70
+ s.add_dependency(%q<dm-core>, ["~> 1.0.0.rc1"])
71
+ s.add_dependency(%q<activemodel>, ["~> 3.0.0.beta3"])
72
+ s.add_dependency(%q<dm-validations>, ["~> 1.0.0.rc1"])
73
+ s.add_dependency(%q<rspec>, ["~> 1.3"])
74
+ s.add_dependency(%q<test-unit>, ["= 1.2.3"])
67
75
  end
68
76
  else
69
- s.add_dependency(%q<dm-core>, ["~> 0.10"])
70
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
71
- s.add_dependency(%q<yard>, ["~> 0.5"])
77
+ s.add_dependency(%q<dm-core>, ["~> 1.0.0.rc1"])
78
+ s.add_dependency(%q<activemodel>, ["~> 3.0.0.beta3"])
79
+ s.add_dependency(%q<dm-validations>, ["~> 1.0.0.rc1"])
80
+ s.add_dependency(%q<rspec>, ["~> 1.3"])
81
+ s.add_dependency(%q<test-unit>, ["= 1.2.3"])
72
82
  end
73
83
  end
74
84
 
@@ -1,7 +1,7 @@
1
1
  module DataMapper
2
2
  module ActiveModel
3
3
 
4
- VERSION = '0.4.0'.freeze
4
+ VERSION = '1.0.0.rc1'.freeze
5
5
 
6
6
  end
7
7
  end
@@ -1,4 +1,5 @@
1
1
  require 'spec/test/unit'
2
+ require 'active_model/lint'
2
3
 
3
4
  # This must be kept in sync with active_model/lint tests
4
5
  # at least for as long as
@@ -0,0 +1,14 @@
1
+ require 'spec/test/unit'
2
+ require 'lib/amo_lint_extensions'
3
+
4
+ share_examples_for 'an active_model/validations compliant object' do
5
+
6
+ include ActiveModel::Lint::Tests::Validations
7
+
8
+ ActiveModel::Lint::Tests::Validations::VALIDATION_METHODS.each do |validation_method|
9
+ it "must implement the .#{validation_method} interface" do
10
+ send("test_#{validation_method}")
11
+ end
12
+ end
13
+
14
+ end
@@ -1,18 +1,25 @@
1
- require 'spec_helper'
1
+ require 'dm-core'
2
+ require 'dm-active_model'
3
+
4
+ require 'amo_interface_compliance_spec'
5
+
6
+ if ENV['DM_VALIDATIONS'] || ENV['AMO_VALIDATIONS']
7
+ require 'dm-validations'
8
+ require 'amo_validation_compliance_spec'
9
+ end
2
10
 
3
11
  describe 'An active_model compliant DataMapper::Resource' do
4
12
 
5
13
  before :all do
6
14
 
7
- module ComplianceTest
15
+ module ::ComplianceTest
8
16
  class ProfileInfo
9
17
  include DataMapper::Resource
10
18
  property :id, Serial
11
19
  end
12
20
  end
13
21
 
14
- DataMapper.setup(:default, 'sqlite3::memory:')
15
- DataMapper.auto_migrate!
22
+ DataMapper.setup(:default, { :adapter => :in_memory })
16
23
 
17
24
  end
18
25
 
@@ -22,4 +29,8 @@ describe 'An active_model compliant DataMapper::Resource' do
22
29
 
23
30
  it_should_behave_like 'an active_model compliant object'
24
31
 
32
+ if ENV['AMO_VALIDATIONS'] == 'true'
33
+ it_should_behave_like 'an active_model/validations compliant object'
34
+ end
35
+
25
36
  end
@@ -0,0 +1,30 @@
1
+ module ActiveModel
2
+ module Lint
3
+ module Tests
4
+ module Validations
5
+
6
+ VALIDATION_METHODS = %w[
7
+ validate
8
+ validates
9
+ validates_each
10
+ validates_with
11
+ validates_acceptance_of
12
+ validates_confirmation_of
13
+ validates_exclusion_of
14
+ validates_format_of
15
+ validates_inclusion_of
16
+ validates_length_of
17
+ validates_numericality_of
18
+ validates_presence_of
19
+ ]
20
+
21
+ VALIDATION_METHODS.each do |validation_method|
22
+ define_method "test_#{validation_method}" do
23
+ assert model.class.respond_to?(validation_method)
24
+ end
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,18 @@
1
+ desc "Support bundling from local source code (allows BUNDLE_GEMFILE=Gemfile.local bundle exec foo)"
2
+ task :local_gemfile do |t|
3
+
4
+ root = Pathname(__FILE__).dirname.parent
5
+ datamapper = root.parent
6
+
7
+ source_regex = /datamapper = 'git:\/\/github.com\/datamapper'/
8
+ gem_source_regex = /:git => \"#\{datamapper\}\/(.+?)(?:\.git)?\"/
9
+
10
+ root.join('Gemfile.local').open('w') do |f|
11
+ root.join('Gemfile').open.each do |line|
12
+ line.sub!(source_regex, "datamapper = '#{datamapper}'")
13
+ line.sub!(gem_source_regex, ':path => "#{datamapper}/\1"')
14
+ f.puts line
15
+ end
16
+ end
17
+
18
+ end
data/tasks/spec.rake CHANGED
@@ -19,7 +19,4 @@ RCov::VerifyTask.new(:verify_rcov => :rcov) do |rcov|
19
19
  rcov.threshold = 100
20
20
  end
21
21
 
22
- task :spec => :check_dependencies
23
- task :rcov => :check_dependencies
24
-
25
22
  task :default => :spec
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-active_model
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ prerelease: true
5
5
  segments:
6
+ - 1
6
7
  - 0
7
- - 4
8
8
  - 0
9
- version: 0.4.0
9
+ - rc1
10
+ version: 1.0.0.rc1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Martin Gamsjaeger (snusnu)
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-02-23 00:00:00 +01:00
18
+ date: 2010-05-19 00:00:00 +02:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
@@ -25,38 +26,70 @@ dependencies:
25
26
  - - ~>
26
27
  - !ruby/object:Gem::Version
27
28
  segments:
29
+ - 1
30
+ - 0
28
31
  - 0
29
- - 10
30
- version: "0.10"
32
+ - rc1
33
+ version: 1.0.0.rc1
31
34
  type: :runtime
32
35
  version_requirements: *id001
33
36
  - !ruby/object:Gem::Dependency
34
- name: rspec
37
+ name: activemodel
35
38
  prerelease: false
36
39
  requirement: &id002 !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - ">="
41
+ - - ~>
39
42
  - !ruby/object:Gem::Version
40
43
  segments:
41
- - 1
42
- - 2
43
- - 9
44
- version: 1.2.9
45
- type: :development
44
+ - 3
45
+ - 0
46
+ - 0
47
+ - beta3
48
+ version: 3.0.0.beta3
49
+ type: :runtime
46
50
  version_requirements: *id002
47
51
  - !ruby/object:Gem::Dependency
48
- name: yard
52
+ name: dm-validations
49
53
  prerelease: false
50
54
  requirement: &id003 !ruby/object:Gem::Requirement
51
55
  requirements:
52
56
  - - ~>
53
57
  - !ruby/object:Gem::Version
54
58
  segments:
59
+ - 1
60
+ - 0
55
61
  - 0
56
- - 5
57
- version: "0.5"
62
+ - rc1
63
+ version: 1.0.0.rc1
58
64
  type: :development
59
65
  version_requirements: *id003
66
+ - !ruby/object:Gem::Dependency
67
+ name: rspec
68
+ prerelease: false
69
+ requirement: &id004 !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ~>
72
+ - !ruby/object:Gem::Version
73
+ segments:
74
+ - 1
75
+ - 3
76
+ version: "1.3"
77
+ type: :development
78
+ version_requirements: *id004
79
+ - !ruby/object:Gem::Dependency
80
+ name: test-unit
81
+ prerelease: false
82
+ requirement: &id005 !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - "="
85
+ - !ruby/object:Gem::Version
86
+ segments:
87
+ - 1
88
+ - 2
89
+ - 3
90
+ version: 1.2.3
91
+ type: :development
92
+ version_requirements: *id005
60
93
  description: A datamapper plugin for active_model compliance and thus rails 3 compatibility.
61
94
  email: gamsnjaga [a] gmail [d] com
62
95
  executables: []
@@ -76,22 +109,25 @@ files:
76
109
  - README.rdoc
77
110
  - Rakefile
78
111
  - TODO
112
+ - VERSION
79
113
  - dm-active_model.gemspec
80
114
  - lib/dm-active_model.rb
81
115
  - lib/dm-active_model/version.rb
82
- - spec/amo_compliance_spec.rb
116
+ - spec/amo_interface_compliance_spec.rb
117
+ - spec/amo_validation_compliance_spec.rb
83
118
  - spec/dm-active_model_spec.rb
119
+ - spec/lib/amo_lint_extensions.rb
84
120
  - spec/rcov.opts
85
121
  - spec/spec.opts
86
- - spec/spec_helper.rb
87
122
  - tasks/changelog.rake
88
123
  - tasks/ci.rake
124
+ - tasks/local_gemfile.rake
89
125
  - tasks/metrics.rake
90
126
  - tasks/spec.rake
91
127
  - tasks/yard.rake
92
128
  - tasks/yardstick.rake
93
129
  has_rdoc: true
94
- homepage: http://github.com/snusnu/dm-active_model
130
+ homepage: http://github.com/datamapper/dm-active_model
95
131
  licenses: []
96
132
 
97
133
  post_install_message:
@@ -108,11 +144,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
144
  version: "0"
109
145
  required_rubygems_version: !ruby/object:Gem::Requirement
110
146
  requirements:
111
- - - ">="
147
+ - - ">"
112
148
  - !ruby/object:Gem::Version
113
149
  segments:
114
- - 0
115
- version: "0"
150
+ - 1
151
+ - 3
152
+ - 1
153
+ version: 1.3.1
116
154
  requirements: []
117
155
 
118
156
  rubyforge_project:
@@ -121,6 +159,7 @@ signing_key:
121
159
  specification_version: 3
122
160
  summary: active_model compliance for datamapper
123
161
  test_files:
124
- - spec/amo_compliance_spec.rb
162
+ - spec/amo_interface_compliance_spec.rb
163
+ - spec/amo_validation_compliance_spec.rb
125
164
  - spec/dm-active_model_spec.rb
126
- - spec/spec_helper.rb
165
+ - spec/lib/amo_lint_extensions.rb
data/spec/spec_helper.rb DELETED
@@ -1,58 +0,0 @@
1
- begin
2
- # Just in case the bundle was locked
3
- # This shouldn't happen in a dev environment but lets be safe
4
- require File.expand_path('../../.bundle/environment', __FILE__)
5
- rescue LoadError
6
- require 'rubygems'
7
- require 'bundler'
8
- Bundler.setup
9
- end
10
- Bundler.require(:default, :test)
11
-
12
- # Use local dm-core if running from a typical dev checkout.
13
- lib = File.expand_path('../../../dm-core/lib', __FILE__)
14
- $LOAD_PATH.unshift(lib) if File.directory?(lib)
15
- require 'dm-core'
16
-
17
- # Use local active_model if running from a typical dev checkout.
18
- lib = File.expand_path('../../../rails/activemodel/lib', __FILE__)
19
- $LOAD_PATH.unshift(lib) if File.directory?(lib)
20
- require 'active_model/lint'
21
-
22
- require 'dm-active_model'
23
- require 'amo_compliance_spec'
24
-
25
- def load_driver(name, default_uri)
26
- return false if ENV['ADAPTER'] != name.to_s
27
-
28
- begin
29
- DataMapper.setup(name, ENV["#{name.to_s.upcase}_SPEC_URI"] || default_uri)
30
- DataMapper::Repository.adapters[:default] = DataMapper::Repository.adapters[name]
31
- true
32
- rescue LoadError => e
33
- warn "Could not load do_#{name}: #{e}"
34
- false
35
- end
36
- end
37
-
38
- ENV['ADAPTER'] ||= 'sqlite3'
39
-
40
- HAS_SQLITE3 = load_driver(:sqlite3, 'sqlite3::memory:')
41
- HAS_MYSQL = load_driver(:mysql, 'mysql://localhost/dm_core_test')
42
- HAS_POSTGRES = load_driver(:postgres, 'postgres://postgres@localhost/dm_core_test')
43
-
44
-
45
- Spec::Runner.configure do |config|
46
-
47
- config.before(:all) do
48
-
49
- # Support testing with(out)
50
- # dm-validations enabled
51
-
52
- if ENV['USE_DM_VALIDATIONS'] == 'true'
53
- require 'dm-validations'
54
- end
55
-
56
- end
57
-
58
- end