myronmarston-factory_data_preloader 0.4.0 → 0.4.1
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/README.rdoc +27 -0
- data/VERSION.yml +1 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -55,6 +55,7 @@ Define your data in these files like this:
|
|
55
55
|
|
56
56
|
Finally, use this preloaded data in your tests:
|
57
57
|
|
58
|
+
# test/user_test.rb
|
58
59
|
class UserTest < ActiveSupport::TestCase
|
59
60
|
def test_thom_has_last_name
|
60
61
|
user = FactoryData.users(:thom)
|
@@ -62,6 +63,32 @@ Finally, use this preloaded data in your tests:
|
|
62
63
|
end
|
63
64
|
end
|
64
65
|
|
66
|
+
# test/post_test.rb
|
67
|
+
class PostTest < ActiveSupport::TestCase
|
68
|
+
def test_post_has_body
|
69
|
+
post = FactoryData.posts(:tour)
|
70
|
+
assert_not_nil post.body
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
All factory data is automatically preloaded for all tests. In a large rails application, this can incur a significant performance penalty
|
75
|
+
at the start of each test run. If you want finer grain control over which preloaders run, you can configure it like so:
|
76
|
+
|
77
|
+
# in test_helper.rb
|
78
|
+
FactoryDataPreloader.preload_all = false
|
79
|
+
|
80
|
+
# test/user_test.rb
|
81
|
+
class UserTest < ActiveSupport::TestCase
|
82
|
+
preload_factory_data :users # multiple types can be listed as necessary
|
83
|
+
# test go here...
|
84
|
+
end
|
85
|
+
|
86
|
+
# test/post_test.rb
|
87
|
+
class PostTest < ActiveSupport::TestCase
|
88
|
+
preload_factory_data :posts # dependencies are taken into account, so users will automatically be preloaded as well.
|
89
|
+
# test go here...
|
90
|
+
end
|
91
|
+
|
65
92
|
== Notes, etc.
|
66
93
|
|
67
94
|
* This gem has been tested with Rails 2.2.2 and Rails 2.3.2.
|
data/VERSION.yml
CHANGED