factory_girl 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/CONTRIBUTION_GUIDELINES.rdoc +4 -5
  2. data/README.rdoc +6 -6
  3. data/Rakefile +11 -14
  4. data/lib/factory_girl/attribute.rb +3 -2
  5. data/lib/factory_girl/attribute/dynamic.rb +5 -2
  6. data/lib/factory_girl/proxy/stub.rb +33 -12
  7. data/lib/factory_girl/sequence.rb +3 -0
  8. data/spec/factory_girl/aliases_spec.rb +29 -0
  9. data/spec/factory_girl/attribute/association_spec.rb +25 -0
  10. data/spec/factory_girl/attribute/dynamic_spec.rb +49 -0
  11. data/spec/factory_girl/attribute/static_spec.rb +29 -0
  12. data/spec/factory_girl/attribute_spec.rb +30 -0
  13. data/spec/factory_girl/factory_spec.rb +490 -0
  14. data/spec/factory_girl/proxy/attributes_for_spec.rb +52 -0
  15. data/spec/factory_girl/proxy/build_spec.rb +73 -0
  16. data/spec/factory_girl/proxy/create_spec.rb +83 -0
  17. data/spec/factory_girl/proxy/stub_spec.rb +69 -0
  18. data/spec/factory_girl/proxy_spec.rb +28 -0
  19. data/spec/factory_girl/sequence_spec.rb +66 -0
  20. data/spec/factory_girl/syntax/blueprint_spec.rb +34 -0
  21. data/spec/factory_girl/syntax/generate_spec.rb +57 -0
  22. data/spec/factory_girl/syntax/make_spec.rb +35 -0
  23. data/spec/factory_girl/syntax/sham_spec.rb +35 -0
  24. data/spec/integration_spec.rb +265 -0
  25. data/{test → spec}/models.rb +0 -0
  26. data/{test/test_helper.rb → spec/spec_helper.rb} +12 -5
  27. metadata +44 -42
  28. data/test/aliases_test.rb +0 -29
  29. data/test/association_attribute_test.rb +0 -31
  30. data/test/attribute_test.rb +0 -32
  31. data/test/attributes_for_strategy_test.rb +0 -55
  32. data/test/build_strategy_test.rb +0 -79
  33. data/test/create_strategy_test.rb +0 -90
  34. data/test/dynamic_attribute_test.rb +0 -41
  35. data/test/factory_test.rb +0 -513
  36. data/test/integration_test.rb +0 -235
  37. data/test/sequence_test.rb +0 -76
  38. data/test/static_attribute_test.rb +0 -33
  39. data/test/strategy_test.rb +0 -33
  40. data/test/stub_strategy_test.rb +0 -61
  41. data/test/syntax/blueprint_test.rb +0 -39
  42. data/test/syntax/generate_test.rb +0 -63
  43. data/test/syntax/make_test.rb +0 -39
  44. data/test/syntax/sham_test.rb +0 -40
@@ -1,63 +0,0 @@
1
- require 'test_helper'
2
-
3
- require 'factory_girl/syntax/generate'
4
-
5
- class GenerateSyntaxTest < Test::Unit::TestCase
6
-
7
- context "a factory" do
8
- setup do
9
- Factory.define :user do |factory|
10
- factory.first_name 'Bill'
11
- factory.last_name 'Nye'
12
- factory.email 'science@guys.net'
13
- end
14
- end
15
-
16
- teardown do
17
- Factory.factories.clear
18
- end
19
-
20
- should "not raise an error when generating an invalid instance" do
21
- assert_nothing_raised { User.generate(:first_name => nil) }
22
- end
23
-
24
- should "raise an error when forcefully generating an invalid instance" do
25
- assert_raise ActiveRecord::RecordInvalid do
26
- User.generate!(:first_name => nil)
27
- end
28
- end
29
-
30
- %w(generate generate! spawn).each do |method|
31
- should "yield a generated instance when using #{method} with a block" do
32
- instance = nil
33
- User.send(method) {|instance| }
34
- assert_kind_of User, instance
35
- end
36
-
37
- context "after generating an instance using #{method}" do
38
- setup do
39
- @instance = User.send(method, :last_name => 'Rye')
40
- end
41
-
42
- should "use attributes from the factory" do
43
- assert_equal 'Bill', @instance.first_name
44
- end
45
-
46
- should "use attributes passed to generate" do
47
- assert_equal 'Rye', @instance.last_name
48
- end
49
-
50
- if method == 'spawn'
51
- should "not save the record" do
52
- assert @instance.new_record?
53
- end
54
- else
55
- should "save the record" do
56
- assert !@instance.new_record?
57
- end
58
- end
59
- end
60
- end
61
- end
62
-
63
- end
@@ -1,39 +0,0 @@
1
- require 'test_helper'
2
-
3
- require 'factory_girl/syntax/make'
4
-
5
- class MakeSyntaxTest < Test::Unit::TestCase
6
-
7
- context "a factory" do
8
- setup do
9
- Factory.define :user do |factory|
10
- factory.first_name 'Bill'
11
- factory.last_name 'Nye'
12
- factory.email 'science@guys.net'
13
- end
14
- end
15
-
16
- teardown do
17
- Factory.factories.clear
18
- end
19
-
20
- context "after making an instance" do
21
- setup do
22
- @instance = User.make(:last_name => 'Rye')
23
- end
24
-
25
- should "use attributes from the factory" do
26
- assert_equal 'Bill', @instance.first_name
27
- end
28
-
29
- should "use attributes passed to make" do
30
- assert_equal 'Rye', @instance.last_name
31
- end
32
-
33
- should "save the record" do
34
- assert !@instance.new_record?
35
- end
36
- end
37
- end
38
-
39
- end
@@ -1,40 +0,0 @@
1
- require 'test_helper'
2
-
3
- require 'factory_girl/syntax/sham'
4
-
5
- class ShamSyntaxTest < Test::Unit::TestCase
6
-
7
- context "a factory" do
8
- setup do
9
- Sham.name { "Name" }
10
- Sham.email { "somebody#{rand(5)}@example.com" }
11
-
12
- Factory.define :user do |factory|
13
- factory.first_name { Sham.name }
14
- factory.last_name { Sham.name }
15
- factory.email { Sham.email }
16
- end
17
- end
18
-
19
- teardown do
20
- Factory.factories.clear
21
- Factory.sequences.clear
22
- end
23
-
24
- context "after making an instance" do
25
- setup do
26
- @instance = Factory(:user, :last_name => 'Rye')
27
- end
28
-
29
- should "support a sham called 'name'" do
30
- assert_equal 'Name', @instance.first_name
31
- end
32
-
33
- should "use the sham for the email" do
34
- assert_match /somebody\d@example.com/, @instance.email
35
- end
36
- end
37
- end
38
-
39
- end
40
-