factory_girl 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -188,7 +188,7 @@ And it's also possible to define an in-line sequence that is only used in
188
188
  a particular factory:
189
189
 
190
190
  Factory.define :user do |f|
191
- f.sequence :email {|n| "person#{n}@example.com" }
191
+ f.sequence(:email) {|n| "person#{n}@example.com" }
192
192
  end
193
193
 
194
194
  == Alternate Syntaxes
data/Rakefile CHANGED
@@ -28,7 +28,7 @@ desc 'Generate documentation for the factory_girl plugin.'
28
28
  Rake::RDocTask.new(:rdoc) do |rdoc|
29
29
  rdoc.rdoc_dir = 'rdoc'
30
30
  rdoc.title = 'Factory Girl'
31
- rdoc.options << '--line-numbers' << '--inline-source' << "--main" << "README.rdoc"
31
+ rdoc.options << '--line-numbers' << "--main" << "README.rdoc"
32
32
  rdoc.rdoc_files.include('README.rdoc')
33
33
  rdoc.rdoc_files.include('CONTRIBUTION_GUIDELINES.rdoc')
34
34
  rdoc.rdoc_files.include('lib/**/*.rb')
@@ -45,7 +45,7 @@ spec = Gem::Specification.new do |s|
45
45
  s.summary = %q{factory_girl provides a framework and DSL for defining and
46
46
  using model instance factories.}
47
47
  s.description = %q{factory_girl provides a framework and DSL for defining and
48
- using factories - less error-prone, more explicit, and
48
+ using factories - less error-prone, more explicit, and
49
49
  all-around easier to work with than fixtures.}
50
50
 
51
51
  s.files = FileList['[A-Z]*', 'lib/**/*.rb', 'test/**/*.rb']
@@ -54,7 +54,7 @@ spec = Gem::Specification.new do |s|
54
54
 
55
55
  s.has_rdoc = true
56
56
  s.extra_rdoc_files = ["README.rdoc"]
57
- s.rdoc_options = ['--line-numbers', '--inline-source', "--main", "README.rdoc"]
57
+ s.rdoc_options = ['--line-numbers', "--main", "README.rdoc"]
58
58
 
59
59
  s.authors = ["Joe Ferris"]
60
60
  s.email = %q{jferris@thoughtbot.com}
@@ -70,7 +70,7 @@ class Factory
70
70
  end
71
71
 
72
72
  def inherit_from(parent) #:nodoc:
73
- @options[:class] = parent.class_name
73
+ @options[:class] ||= parent.class_name
74
74
  parent.attributes.each do |attribute|
75
75
  unless attribute_defined?(attribute.name)
76
76
  @attributes << attribute.clone
@@ -10,7 +10,7 @@ class Factory
10
10
  end
11
11
 
12
12
  def set(attribute, value)
13
- unless @mock.respond_to?("attribute=")
13
+ unless @mock.respond_to?("#{attribute}=")
14
14
  class << @mock; self end.send(:attr_accessor, attribute)
15
15
  end
16
16
  @mock.send("#{attribute}=", value)
data/test/factory_test.rb CHANGED
@@ -413,6 +413,13 @@ factory = Factory.new(:post)
413
413
  child = Factory.define(:child, :parent => :object) {}
414
414
  assert_equal @parent.build_class, child.build_class
415
415
  end
416
+
417
+ should 'create a new factory while overriding the parent class' do
418
+ class Other; end
419
+
420
+ child = Factory.define(:child, :parent => :object, :class => Other) {}
421
+ assert_equal Other, child.build_class
422
+ end
416
423
 
417
424
  should 'create a new factory with attributes of the parent' do
418
425
  child = Factory.define(:child, :parent => :object) {}
@@ -35,6 +35,15 @@ class StubProxyTest < Test::Unit::TestCase
35
35
  assert_kind_of Object, @proxy.result
36
36
  end
37
37
 
38
+ context "setting an attribute" do
39
+ should "define attributes even if attribute= is defined" do
40
+ @proxy.set('attribute', nil)
41
+ assert_nothing_raised do
42
+ @proxy.set('age', 18)
43
+ end
44
+ end
45
+ end
46
+
38
47
  context "after setting an attribute" do
39
48
  setup do
40
49
  @proxy.set(:attribute, 'value')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factory_girl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Ferris
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-17 00:00:00 -05:00
12
+ date: 2009-04-09 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15