with_model 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -5,3 +5,4 @@ pkg/*
5
5
  .rvmrc
6
6
  doc
7
7
  gemfiles/**/Gemfile.lock
8
+ *.rbc
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - rbx-2.0
5
+ - ree
6
+ script: "rake spec"
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ ### 0.2.5
2
+
3
+ Clear Active Record 3.x associations class cache between specs to clean up test
4
+ pollution.
5
+
1
6
  ### 0.2.4
2
7
 
3
8
  Active Record 3.1 compatible.
data/Gemfile CHANGED
@@ -2,4 +2,3 @@ puts <<-MESSAGE
2
2
  This project uses multiple Gemfiles in subdirectories of ./gemfiles.
3
3
  The rake tasks automatically install these bundles as necessary. See rake -T.
4
4
  MESSAGE
5
- exit 1
data/README.rdoc CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  * http://github.com/casecommons/with_model/
4
4
 
5
+ {<img src="https://secure.travis-ci.org/Casecommons/with_model.png" />}[http://travis-ci.org/Casecommons/with_model]
6
+
5
7
  == DESCRIPTION
6
8
 
7
9
  +with_model+ dynamically builds an ActiveRecord model (with table) within an RSpec context. Outside of the context, the model is no longer present.
data/Rakefile CHANGED
@@ -38,7 +38,7 @@ end
38
38
  namespace "doc" do
39
39
  desc "Generate README and preview in browser"
40
40
  task "readme" do
41
- sh "rdoc -c utf8 README.rdoc && open doc/files/README_rdoc.html"
41
+ sh "rdoc -c utf8 README.rdoc && open doc/README_rdoc.html"
42
42
  end
43
43
  end
44
44
 
@@ -1,9 +1,7 @@
1
1
  source :rubygems
2
2
 
3
- gem "mixico"
4
3
  gem "rake"
5
-
6
- group :test do
7
- gem "autotest"
8
- gem "sqlite3"
9
- end
4
+ gem "ZenTest" unless ENV["TRAVIS"]
5
+ gem "mixico", :platforms => :mri
6
+ gem "sqlite3", :platforms => :ruby
7
+ gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
@@ -48,6 +48,9 @@ module WithModel
48
48
  model._with_model_deconstructor if model.respond_to?(:_with_model_deconstructor)
49
49
  Object.send(:remove_const, const_name)
50
50
  Object.const_set(const_name, original_const_value) if original_const_defined
51
+ if defined?(ActiveSupport::Dependencies::Reference)
52
+ ActiveSupport::Dependencies::Reference.clear!
53
+ end
51
54
  end
52
55
  end
53
56
  end
@@ -1,3 +1,3 @@
1
1
  module WithModel
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
@@ -101,4 +101,30 @@ describe "ActiveRecord behaviors" do
101
101
  end
102
102
  end
103
103
  end
104
+
105
+ context "with an association" do
106
+ with_model :Province do
107
+ table do |t|
108
+ t.belongs_to :country
109
+ end
110
+ model do
111
+ belongs_to :country
112
+ end
113
+ end
114
+
115
+ with_model :Country do
116
+ end
117
+
118
+ context "in earlier examples" do
119
+ it "should work as normal" do
120
+ Province.create!(:country => Country.create!)
121
+ end
122
+ end
123
+
124
+ context "in later examples" do
125
+ it "should not hold a reference to earlier example groups' classes" do
126
+ Province.reflect_on_association(:country).klass.should == Country
127
+ end
128
+ end
129
+ end
104
130
  end
data/spec/spec_helper.rb CHANGED
@@ -13,9 +13,12 @@ else
13
13
  end
14
14
  end
15
15
 
16
+ jruby = RUBY_PLATFORM =~ /\bjava\b/
17
+ adapter = jruby ? "jdbcsqlite3" : "sqlite3"
18
+
16
19
  # WithModel requires ActiveRecord::Base.connection to be established.
17
20
  # If ActiveRecord already has a connection, as in a Rails app, this is unnecessary.
18
- ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ":memory:")
21
+ ActiveRecord::Base.establish_connection(:adapter => adapter, :database => ":memory:")
19
22
 
20
23
  # For readme_spec.rb
21
24
  module SomeModule; end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: with_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-09-02 00:00:00.000000000Z
13
+ date: 2011-11-03 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
17
- requirement: &2168918400 !ruby/object:Gem::Requirement
17
+ requirement: &70265016555940 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -25,10 +25,10 @@ dependencies:
25
25
  version: 4.0.0
26
26
  type: :runtime
27
27
  prerelease: false
28
- version_requirements: *2168918400
28
+ version_requirements: *70265016555940
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: rspec
31
- requirement: &2168917640 !ruby/object:Gem::Requirement
31
+ requirement: &70265016555180 !ruby/object:Gem::Requirement
32
32
  none: false
33
33
  requirements:
34
34
  - - <
@@ -36,7 +36,7 @@ dependencies:
36
36
  version: '3'
37
37
  type: :runtime
38
38
  prerelease: false
39
- version_requirements: *2168917640
39
+ version_requirements: *70265016555180
40
40
  description: Dynamically build a model within an Rspec context
41
41
  email:
42
42
  - casecommons-dev@googlegroups.com
@@ -48,6 +48,7 @@ files:
48
48
  - .autotest
49
49
  - .gitignore
50
50
  - .rspec
51
+ - .travis.yml
51
52
  - CHANGELOG
52
53
  - Gemfile
53
54
  - LICENSE