factory_girl 2.6.4 → 3.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. data/.travis.yml +0 -3
  2. data/Appraisals +0 -4
  3. data/Changelog +0 -4
  4. data/Gemfile.lock +7 -4
  5. data/Rakefile +0 -12
  6. data/factory_girl.gemspec +3 -3
  7. data/features/support/env.rb +3 -0
  8. data/gemfiles/3.0.gemfile.lock +8 -4
  9. data/gemfiles/3.1.gemfile.lock +7 -4
  10. data/gemfiles/3.2.gemfile.lock +7 -4
  11. data/lib/factory_girl.rb +0 -1
  12. data/lib/factory_girl/attribute_assigner.rb +2 -2
  13. data/lib/factory_girl/declaration.rb +0 -5
  14. data/lib/factory_girl/definition.rb +1 -1
  15. data/lib/factory_girl/definition_proxy.rb +1 -1
  16. data/lib/factory_girl/errors.rb +1 -1
  17. data/lib/factory_girl/evaluator.rb +2 -5
  18. data/lib/factory_girl/factory.rb +4 -20
  19. data/lib/factory_girl/null_factory.rb +1 -2
  20. data/lib/factory_girl/null_object.rb +3 -15
  21. data/lib/factory_girl/sequence.rb +0 -4
  22. data/lib/factory_girl/step_definitions.rb +1 -1
  23. data/lib/factory_girl/syntax/blueprint.rb +2 -2
  24. data/lib/factory_girl/syntax/default.rb +1 -1
  25. data/lib/factory_girl/syntax/generate.rb +1 -1
  26. data/lib/factory_girl/syntax/make.rb +1 -1
  27. data/lib/factory_girl/syntax/vintage.rb +13 -32
  28. data/lib/factory_girl/trait.rb +1 -1
  29. data/lib/factory_girl/version.rb +1 -1
  30. data/spec/acceptance/aliases_spec.rb +3 -3
  31. data/spec/acceptance/attribute_aliases_spec.rb +5 -5
  32. data/spec/acceptance/attribute_existing_on_object_spec.rb +5 -5
  33. data/spec/acceptance/attributes_for_spec.rb +8 -8
  34. data/spec/acceptance/attributes_from_instance_spec.rb +5 -5
  35. data/spec/acceptance/attributes_ordered_spec.rb +5 -5
  36. data/spec/acceptance/build_list_spec.rb +2 -2
  37. data/spec/acceptance/build_spec.rb +6 -6
  38. data/spec/acceptance/build_stubbed_spec.rb +7 -7
  39. data/spec/acceptance/callbacks_spec.rb +3 -3
  40. data/spec/acceptance/create_list_spec.rb +6 -6
  41. data/spec/acceptance/create_spec.rb +13 -42
  42. data/spec/acceptance/define_child_before_parent_spec.rb +2 -2
  43. data/spec/acceptance/definition_spec.rb +2 -2
  44. data/spec/acceptance/initialize_with_spec.rb +7 -7
  45. data/spec/acceptance/modify_factories_spec.rb +5 -5
  46. data/spec/acceptance/modify_inherited_spec.rb +8 -8
  47. data/spec/acceptance/overrides_spec.rb +4 -4
  48. data/spec/acceptance/parent_spec.rb +3 -3
  49. data/spec/acceptance/stub_spec.rb +12 -41
  50. data/spec/acceptance/syntax/blueprint_spec.rb +6 -3
  51. data/spec/acceptance/syntax/generate_spec.rb +4 -4
  52. data/spec/acceptance/syntax/make_spec.rb +3 -3
  53. data/spec/acceptance/syntax/sham_spec.rb +5 -5
  54. data/spec/acceptance/syntax/vintage_spec.rb +28 -46
  55. data/spec/acceptance/traits_spec.rb +33 -33
  56. data/spec/acceptance/transient_attributes_spec.rb +7 -59
  57. data/spec/factory_girl/aliases_spec.rb +1 -1
  58. data/spec/factory_girl/attribute/association_spec.rb +2 -2
  59. data/spec/factory_girl/attribute/dynamic_spec.rb +2 -2
  60. data/spec/factory_girl/declaration_list_spec.rb +7 -7
  61. data/spec/factory_girl/definition_proxy_spec.rb +6 -6
  62. data/spec/factory_girl/definition_spec.rb +3 -3
  63. data/spec/factory_girl/evaluator_class_definer_spec.rb +5 -5
  64. data/spec/factory_girl/factory_spec.rb +19 -69
  65. data/spec/factory_girl/null_factory_spec.rb +4 -5
  66. data/spec/factory_girl/registry_spec.rb +1 -1
  67. data/spec/factory_girl/sequence_spec.rb +3 -4
  68. data/spec/factory_girl/strategy/attributes_for_spec.rb +2 -2
  69. data/spec/factory_girl/strategy/build_spec.rb +1 -1
  70. data/spec/factory_girl/strategy/create_spec.rb +1 -1
  71. data/spec/factory_girl/strategy/stub_spec.rb +2 -2
  72. data/spec/spec_helper.rb +3 -0
  73. data/spec/support/macros/define_constant.rb +2 -2
  74. data/spec/support/shared_examples/strategy.rb +12 -22
  75. metadata +32 -41
  76. data/gemfiles/2.3.gemfile.lock +0 -72
  77. data/lib/factory_girl/deprecated.rb +0 -18
  78. data/spec/acceptance/default_strategy_spec.rb +0 -24
  79. data/spec/acceptance/nested_attributes_spec.rb +0 -32
  80. data/spec/factory_girl/deprecated_spec.rb +0 -45
data/.travis.yml CHANGED
@@ -1,13 +1,10 @@
1
1
  rvm:
2
- - ree-1.8.7
3
- - 1.8.7
4
2
  - 1.9.2
5
3
  - 1.9.3
6
4
  before_install:
7
5
  - gem update --system
8
6
  script: "bundle exec rake spec:unit spec:acceptance features"
9
7
  gemfile:
10
- - gemfiles/2.3.gemfile
11
8
  - gemfiles/3.0.gemfile
12
9
  - gemfiles/3.1.gemfile
13
10
  - gemfiles/3.2.gemfile
data/Appraisals CHANGED
@@ -1,7 +1,3 @@
1
- appraise "2.3" do
2
- gem "activerecord", "~> 2.3"
3
- end
4
-
5
1
  appraise "3.0" do
6
2
  gem "activerecord", "~> 3.0"
7
3
  end
data/Changelog CHANGED
@@ -1,7 +1,3 @@
1
- 2.6.4 (March 16, 2012)
2
- Do not ignore names of transient attributes
3
- Ensure attributes set on instance are calculated uniquely
4
-
5
1
  2.6.3 (March 9, 2012)
6
2
  Fix issue with traits not being present the first time a factory is accessed
7
3
  Update available Cucumber step definitions to not require a trialing colon
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- factory_girl (2.6.4)
5
- activesupport (>= 2.3.9)
4
+ factory_girl (3.0.0.rc1)
5
+ activesupport (>= 3.0.0)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
@@ -55,7 +55,6 @@ GEM
55
55
  multi_json (1.0.3)
56
56
  rack (1.3.3)
57
57
  rake (0.9.2)
58
- rcov (0.9.10)
59
58
  rdiscount (1.6.8)
60
59
  rspec (2.6.0)
61
60
  rspec-core (~> 2.6.0)
@@ -65,6 +64,10 @@ GEM
65
64
  rspec-expectations (2.6.0)
66
65
  diff-lcs (~> 1.1.2)
67
66
  rspec-mocks (2.6.0)
67
+ simplecov (0.6.1)
68
+ multi_json (~> 1.0)
69
+ simplecov-html (~> 0.5.3)
70
+ simplecov-html (0.5.3)
68
71
  sqlite3 (1.3.4)
69
72
  sqlite3-ruby (1.3.3)
70
73
  sqlite3 (>= 1.3.3)
@@ -85,8 +88,8 @@ DEPENDENCIES
85
88
  cucumber (~> 1.0.0)
86
89
  factory_girl!
87
90
  mocha
88
- rcov
89
91
  rspec (~> 2.0)
92
+ simplecov
90
93
  sqlite3-ruby
91
94
  timecop
92
95
  yard
data/Rakefile CHANGED
@@ -5,7 +5,6 @@ require 'appraisal'
5
5
  require 'yard'
6
6
  require 'rspec/core/rake_task'
7
7
  require 'cucumber/rake/task'
8
- require 'rcov/rcovtask'
9
8
 
10
9
  Bundler::GemHelper.install_tasks
11
10
 
@@ -29,17 +28,6 @@ end
29
28
  desc "Run the unit and acceptance specs"
30
29
  task :spec => ['spec:unit', 'spec:acceptance']
31
30
 
32
- desc 'Performs code coverage on the factory_girl plugin.'
33
- RSpec::Core::RakeTask.new(:rcov) do |task|
34
- task.pattern = 'spec/**/*_spec.rb'
35
- task.rcov = true
36
- task.rspec_opts = "--format progress"
37
- task.rcov_opts = %{--exclude osx\/objc,spec,gems\/ --aggregate coverage/coverage.data}
38
- end
39
-
40
- desc "Clean files generated by rake tasks"
41
- task :clobber => [:clobber_rcov]
42
-
43
31
  Cucumber::Rake::Task.new(:features) do |t|
44
32
  t.fork = true
45
33
  t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')]
data/factory_girl.gemspec CHANGED
@@ -14,19 +14,19 @@ Gem::Specification.new do |s|
14
14
  s.test_files = `git ls-files -- Appraisals {spec,features,gemfiles}/*`.split("\n")
15
15
 
16
16
  s.require_paths = ['lib']
17
- s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
17
+ s.required_ruby_version = Gem::Requirement.new(">= 1.9.2")
18
18
 
19
19
  s.authors = ["Josh Clayton", "Joe Ferris"]
20
20
  s.email = ["jclayton@thoughtbot.com", "jferris@thoughtbot.com"]
21
21
 
22
22
  s.homepage = "https://github.com/thoughtbot/factory_girl"
23
23
 
24
- s.add_dependency("activesupport", ">= 2.3.9")
24
+ s.add_dependency("activesupport", ">= 3.0.0")
25
25
 
26
26
  s.add_development_dependency("rspec", "~> 2.0")
27
27
  s.add_development_dependency("cucumber", "~> 1.0.0")
28
28
  s.add_development_dependency("timecop")
29
- s.add_development_dependency("rcov")
29
+ s.add_development_dependency("simplecov")
30
30
  s.add_development_dependency("aruba")
31
31
  s.add_development_dependency("mocha")
32
32
  s.add_development_dependency("bourne")
@@ -1,5 +1,8 @@
1
1
  PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
2
2
 
3
+ require "simplecov"
4
+ SimpleCov.start
5
+
3
6
  $: << File.join(PROJECT_ROOT, 'lib')
4
7
 
5
8
  require 'active_record'
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: /Users/joshuaclayton/dev/gems/factory_girl
3
3
  specs:
4
- factory_girl (2.6.4)
5
- activesupport (>= 2.3.9)
4
+ factory_girl (3.0.0.rc1)
5
+ activesupport (>= 3.0.0)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
@@ -45,8 +45,8 @@ GEM
45
45
  json (1.5.3)
46
46
  mocha (0.9.8)
47
47
  rake
48
+ multi_json (1.1.0)
48
49
  rake (0.9.2)
49
- rcov (0.9.9)
50
50
  rspec (2.6.0)
51
51
  rspec-core (~> 2.6.0)
52
52
  rspec-expectations (~> 2.6.0)
@@ -55,6 +55,10 @@ GEM
55
55
  rspec-expectations (2.6.0)
56
56
  diff-lcs (~> 1.1.2)
57
57
  rspec-mocks (2.6.0)
58
+ simplecov (0.6.1)
59
+ multi_json (~> 1.0)
60
+ simplecov-html (~> 0.5.3)
61
+ simplecov-html (0.5.3)
58
62
  sqlite3 (1.3.3)
59
63
  sqlite3-ruby (1.3.3)
60
64
  sqlite3 (>= 1.3.3)
@@ -75,8 +79,8 @@ DEPENDENCIES
75
79
  cucumber (~> 1.0.0)
76
80
  factory_girl!
77
81
  mocha
78
- rcov
79
82
  rspec (~> 2.0)
83
+ simplecov
80
84
  sqlite3-ruby
81
85
  timecop
82
86
  yard
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: /Users/joshuaclayton/dev/gems/factory_girl
3
3
  specs:
4
- factory_girl (2.6.4)
5
- activesupport (>= 2.3.9)
4
+ factory_girl (3.0.0.rc1)
5
+ activesupport (>= 3.0.0)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
@@ -55,7 +55,6 @@ GEM
55
55
  multi_json (1.0.3)
56
56
  rack (1.3.2)
57
57
  rake (0.9.2)
58
- rcov (0.9.10)
59
58
  rdiscount (1.6.8)
60
59
  rspec (2.6.0)
61
60
  rspec-core (~> 2.6.0)
@@ -65,6 +64,10 @@ GEM
65
64
  rspec-expectations (2.6.0)
66
65
  diff-lcs (~> 1.1.2)
67
66
  rspec-mocks (2.6.0)
67
+ simplecov (0.6.1)
68
+ multi_json (~> 1.0)
69
+ simplecov-html (~> 0.5.3)
70
+ simplecov-html (0.5.3)
68
71
  sqlite3 (1.3.4)
69
72
  sqlite3-ruby (1.3.3)
70
73
  sqlite3 (>= 1.3.3)
@@ -85,8 +88,8 @@ DEPENDENCIES
85
88
  cucumber (~> 1.0.0)
86
89
  factory_girl!
87
90
  mocha
88
- rcov
89
91
  rspec (~> 2.0)
92
+ simplecov
90
93
  sqlite3-ruby
91
94
  timecop
92
95
  yard
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: /Users/joshuaclayton/dev/gems/factory_girl
3
3
  specs:
4
- factory_girl (2.6.4)
5
- activesupport (>= 2.3.9)
4
+ factory_girl (3.0.0.rc1)
5
+ activesupport (>= 3.0.0)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
@@ -53,7 +53,6 @@ GEM
53
53
  multi_json (1.0.4)
54
54
  rack (1.4.0)
55
55
  rake (0.9.2.2)
56
- rcov (0.9.11)
57
56
  rdiscount (1.6.8)
58
57
  rspec (2.8.0)
59
58
  rspec-core (~> 2.8.0)
@@ -63,6 +62,10 @@ GEM
63
62
  rspec-expectations (2.8.0)
64
63
  diff-lcs (~> 1.1.2)
65
64
  rspec-mocks (2.8.0)
65
+ simplecov (0.6.1)
66
+ multi_json (~> 1.0)
67
+ simplecov-html (~> 0.5.3)
68
+ simplecov-html (0.5.3)
66
69
  sqlite3 (1.3.5)
67
70
  sqlite3-ruby (1.3.3)
68
71
  sqlite3 (>= 1.3.3)
@@ -83,8 +86,8 @@ DEPENDENCIES
83
86
  cucumber (~> 1.0.0)
84
87
  factory_girl!
85
88
  mocha
86
- rcov
87
89
  rspec (~> 2.0)
90
+ simplecov
88
91
  sqlite3-ruby
89
92
  timecop
90
93
  yard
data/lib/factory_girl.rb CHANGED
@@ -24,7 +24,6 @@ require 'factory_girl/definition_proxy'
24
24
  require 'factory_girl/syntax'
25
25
  require 'factory_girl/find_definitions'
26
26
  require 'factory_girl/reload'
27
- require 'factory_girl/deprecated'
28
27
  require 'factory_girl/version'
29
28
 
30
29
  if defined?(Rails) && Rails::VERSION::MAJOR == 2
@@ -37,7 +37,7 @@ module FactoryGirl
37
37
  end
38
38
 
39
39
  def attributes_to_set_on_instance
40
- (attribute_names_to_assign - @attribute_names_assigned).uniq
40
+ attribute_names_to_assign - @attribute_names_assigned
41
41
  end
42
42
 
43
43
  def attributes_to_set_on_hash
@@ -66,7 +66,7 @@ module FactoryGirl
66
66
 
67
67
  def alias_names_to_ignore
68
68
  @attribute_list.reject(&:ignored).map do |attribute|
69
- override_names.map {|override| attribute.name if attribute.alias_for?(override) && attribute.name != override && !ignored_attribute_names.include?(override) }
69
+ override_names.map {|override| attribute.name if attribute.alias_for?(override) && attribute.name != override }
70
70
  end.flatten.compact
71
71
  end
72
72
  end
@@ -12,11 +12,6 @@ module FactoryGirl
12
12
  @ignored = ignored
13
13
  end
14
14
 
15
- def ignore
16
- $stderr.puts "DEPRECATION WARNING: Use ignore block syntax instead of calling #ignore"
17
- @ignored = true
18
- end
19
-
20
15
  def to_attributes
21
16
  build
22
17
  end
@@ -12,7 +12,7 @@ module FactoryGirl
12
12
  @constructor = nil
13
13
  end
14
14
 
15
- delegate :declare_attribute, :to => :declarations
15
+ delegate :declare_attribute, to: :declarations
16
16
 
17
17
  def attributes
18
18
  @attributes ||= declarations.attribute_list
@@ -122,7 +122,7 @@ module FactoryGirl
122
122
  # end
123
123
  #
124
124
  # factory :post do
125
- # association :author, :factory => :user
125
+ # association :author, factory: :user
126
126
  # end
127
127
  #
128
128
  # Arguments:
@@ -8,7 +8,7 @@ module FactoryGirl
8
8
  # Raised when a factory is defined with the same name as a previously-defined factory.
9
9
  class DuplicateDefinitionError < RuntimeError; end
10
10
 
11
- # Raised when calling Factory.sequence from a dynamic attribute block
11
+ # Raised when attempting to register a sequence from a dynamic attribute block
12
12
  class SequenceAbuseError < RuntimeError; end
13
13
 
14
14
  # Raised when defining an invalid attribute:
@@ -31,17 +31,14 @@ module FactoryGirl
31
31
  end
32
32
 
33
33
  def association(factory_name, overrides = {})
34
- build_strategy = if overrides.has_key?(:method)
35
- $stderr.puts "DEPRECATION WARNING: using :method to specify a build strategy is deprecated; use :strategy instead"
36
- overrides[:method]
37
- elsif overrides.has_key?(:strategy)
34
+ build_strategy = if overrides.has_key?(:strategy)
38
35
  overrides[:strategy]
39
36
  else
40
37
  Strategy::Create
41
38
  end
42
39
 
43
40
  build_strategy = StrategyCalculator.new(build_strategy).strategy
44
- runner = FactoryRunner.new(factory_name, build_strategy, [overrides.except(:method, :strategy)])
41
+ runner = FactoryRunner.new(factory_name, build_strategy, [overrides.except(:strategy)])
45
42
  @build_strategy.association(runner)
46
43
  end
47
44
 
@@ -11,18 +11,12 @@ module FactoryGirl
11
11
  @parent = options[:parent]
12
12
  @aliases = options[:aliases] || []
13
13
  @class_name = options[:class]
14
- @default_strategy = options[:default_strategy]
15
14
  @definition = Definition.new(@name, options[:traits] || [])
16
15
  @compiled = false
17
16
  end
18
17
 
19
18
  delegate :add_callback, :declare_attribute, :to_create, :define_trait,
20
- :defined_traits, :inherit_traits, :processing_order, :to => :@definition
21
-
22
- def factory_name
23
- $stderr.puts "DEPRECATION WARNING: factory.factory_name is deprecated; use factory.name instead."
24
- name
25
- end
19
+ :defined_traits, :inherit_traits, :processing_order, to: :@definition
26
20
 
27
21
  def build_class #:nodoc:
28
22
  @build_class ||= if class_name.is_a? Class
@@ -32,10 +26,6 @@ module FactoryGirl
32
26
  end
33
27
  end
34
28
 
35
- def default_strategy #:nodoc:
36
- @default_strategy || parent.default_strategy
37
- end
38
-
39
29
  def run(strategy_class, overrides, &block) #:nodoc:
40
30
  block ||= lambda {|result| result }
41
31
  compile
@@ -60,7 +50,7 @@ module FactoryGirl
60
50
  #
61
51
  # Example:
62
52
  #
63
- # factory :user, :aliases => [:author] do
53
+ # factory :user, aliases: [:author] do
64
54
  # # ...
65
55
  # end
66
56
  #
@@ -71,7 +61,7 @@ module FactoryGirl
71
61
  # association with the same name, this allows associations to be defined
72
62
  # without factories, such as:
73
63
  #
74
- # factory :user, :aliases => [:author] do
64
+ # factory :user, aliases: [:author] do
75
65
  # # ...
76
66
  # end
77
67
  #
@@ -130,13 +120,7 @@ module FactoryGirl
130
120
  private
131
121
 
132
122
  def assert_valid_options(options)
133
- options.assert_valid_keys(:class, :parent, :default_strategy, :aliases, :traits)
134
-
135
- if options[:default_strategy]
136
- Strategy.ensure_strategy_exists!(options[:default_strategy])
137
- $stderr.puts "DEPRECATION WARNING: default_strategy is deprecated."
138
- $stderr.puts "Override to_create if you need to prevent a call to #save!."
139
- end
123
+ options.assert_valid_keys(:class, :parent, :aliases, :traits)
140
124
  end
141
125
 
142
126
  def parent
@@ -6,11 +6,10 @@ module FactoryGirl
6
6
  @definition = Definition.new
7
7
  end
8
8
 
9
- delegate :defined_traits, :callbacks, :attributes, :constructor, :to => :definition
9
+ delegate :defined_traits, :callbacks, :attributes, :constructor, to: :definition
10
10
 
11
11
  def compile; end
12
12
  def class_name; end
13
- def default_strategy; :create; end
14
13
  def evaluator_class; FactoryGirl::Evaluator; end
15
14
  end
16
15
  end
@@ -1,19 +1,7 @@
1
1
  module FactoryGirl
2
- if defined?(::BasicObject)
3
- class NullObject < ::BasicObject
4
- def method_missing(*args)
5
- nil
6
- end
7
- end
8
- else
9
- class NullObject
10
- instance_methods.each do |m|
11
- undef_method(m) if m.to_s !~ /(?:^__|^nil\?$|^send$|^object_id$)/
12
- end
13
-
14
- def method_missing(*args)
15
- nil
16
- end
2
+ class NullObject < ::BasicObject
3
+ def method_missing(*args)
4
+ nil
17
5
  end
18
6
  end
19
7
  end