lawrencepit-machinery 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +7 -5
- data/lib/machinery/active_record.rb +4 -4
- metadata +4 -3
data/README.markdown
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Machinery
|
2
2
|
=========
|
3
3
|
|
4
|
-
*Machinery to create object graphs.*
|
4
|
+
*Machinery to create object graphs and speed up tests.*
|
5
5
|
|
6
6
|
Machinery helps to create object graphs for use in tests without needing
|
7
7
|
fixtures, using pure ruby style. These object graphs are easily re-usable
|
@@ -13,7 +13,7 @@ a before(:all) instead of a before(:each), and at the end of the tests
|
|
13
13
|
all activerecord objects created in the before(:all) will be cleaned up
|
14
14
|
automatically.
|
15
15
|
|
16
|
-
Machinery
|
16
|
+
Machinery works with plain ruby objects and currently supports ActiveRecord.
|
17
17
|
A DataMapper abstraction should be too easy.
|
18
18
|
|
19
19
|
|
@@ -111,8 +111,9 @@ ship_spec example above) then the instances will be created for you exactly once
|
|
111
111
|
They will automatically be removed from the database after all the tests have run.
|
112
112
|
Any instance variables declared within a scenario will be cloned before each test.
|
113
113
|
If you make sure you use +use_transactional_fixtures+ then this means:
|
114
|
+
|
114
115
|
* speedy tests, because instances are created exactly once for all tests
|
115
|
-
* you can mess around with the instance variables any way you like within a test method as before each test they will always be in exactly the same state.
|
116
|
+
* you can mess around with the instance variables any way you like within a test method as before each test they will always be in exactly the same initial state.
|
116
117
|
|
117
118
|
A special case is when you use an anonymous +scenario+ with a block, specified at the
|
118
119
|
top of your tests (as in the second ship_spec example above). It will behave as if it's
|
@@ -189,8 +190,9 @@ Written by [Lawrence Pit](http://lawrencepit.com).
|
|
189
190
|
Thanks to
|
190
191
|
[Machinist](http://github.com/notahat/machinist),
|
191
192
|
[ModelStubbing](http://github.com/technoweenie/model_stubbing),
|
192
|
-
[
|
193
|
-
[FixtureScenarios](http://errtheblog.com/posts/61-fixin-fixtures)
|
193
|
+
[FactoryGirl](http://github.com/thoughtbot/factory_girl),
|
194
|
+
[FixtureScenarios](http://errtheblog.com/posts/61-fixin-fixtures) and
|
195
|
+
[Hornsby](http://github.com/lachie/hornsby)
|
194
196
|
for inspiration.
|
195
197
|
|
196
198
|
After using model_stubbing on a relatively large project for over a year I decided
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module Machinery
|
2
2
|
module ActiveRecord
|
3
3
|
@@toys = []
|
4
|
-
@@
|
4
|
+
@@recording_level = 0
|
5
5
|
|
6
6
|
def self.record
|
7
|
-
@@
|
7
|
+
@@recording_level = @@recording_level + 1
|
8
8
|
yield
|
9
|
-
@@
|
9
|
+
@@recording_level = @@recording_level - 1
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.clear
|
@@ -21,7 +21,7 @@ module Machinery
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.created(obj)
|
24
|
-
@@toys << obj if @@
|
24
|
+
@@toys << obj if @@recording_level > 0
|
25
25
|
end
|
26
26
|
|
27
27
|
module Extensions
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lawrencepit-machinery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lawrence Pit
|
@@ -28,6 +28,7 @@ files:
|
|
28
28
|
- lib/machinery/active_record.rb
|
29
29
|
has_rdoc: false
|
30
30
|
homepage: http://github.com/lawrencepit/machinery
|
31
|
+
licenses:
|
31
32
|
post_install_message:
|
32
33
|
rdoc_options: []
|
33
34
|
|
@@ -48,9 +49,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
48
49
|
requirements: []
|
49
50
|
|
50
51
|
rubyforge_project:
|
51
|
-
rubygems_version: 1.
|
52
|
+
rubygems_version: 1.3.5
|
52
53
|
signing_key:
|
53
54
|
specification_version: 2
|
54
|
-
summary: Machinery to create object graphs.
|
55
|
+
summary: Machinery to create object graphs and speed up tests.
|
55
56
|
test_files: []
|
56
57
|
|