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 +1 -0
- data/.travis.yml +6 -0
- data/CHANGELOG +5 -0
- data/Gemfile +0 -1
- data/README.rdoc +2 -0
- data/Rakefile +1 -1
- data/gemfiles/Gemfile.common +4 -6
- data/lib/with_model/dsl.rb +3 -0
- data/lib/with_model/version.rb +1 -1
- data/spec/active_record_behaviors_spec.rb +26 -0
- data/spec/spec_helper.rb +4 -1
- metadata +7 -6
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/CHANGELOG
CHANGED
data/Gemfile
CHANGED
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
data/gemfiles/Gemfile.common
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
source :rubygems
|
2
2
|
|
3
|
-
gem "mixico"
|
4
3
|
gem "rake"
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
data/lib/with_model/dsl.rb
CHANGED
@@ -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
|
data/lib/with_model/version.rb
CHANGED
@@ -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 =>
|
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
|
+
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-
|
13
|
+
date: 2011-11-03 00:00:00.000000000Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
17
|
-
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: *
|
28
|
+
version_requirements: *70265016555940
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: rspec
|
31
|
-
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: *
|
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
|