modelfactory 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.9.1 2009-06-04
2
+ * Error was being raised when nil is passed to create, fixed.
3
+ * Corrected API documentation in README.txt.
4
+
1
5
  == 0.9.0 2009-06-04
2
6
  * More API changes
3
7
  * Built-in counters for generating values
data/README.txt CHANGED
@@ -17,7 +17,7 @@ opaque ActiveRecord objects whose contents are unimportant.
17
17
 
18
18
  require 'modelfactory'
19
19
 
20
- ModelFactory.configuration do
20
+ ModelFactory.configure do
21
21
  default(User) do
22
22
  name { "Factory User" }
23
23
  email { "user@factory.ws" }
@@ -73,7 +73,7 @@ keeps a counter for each type that increments when each new instance is
73
73
  created. This counter is passed to model initialization blocks to make it
74
74
  easier to generate unique values:
75
75
 
76
- ModelFactory.configuration do
76
+ ModelFactory.configure do
77
77
  default(User) do
78
78
  name {|i| "Factory User #{i}" }
79
79
  email {|i| "user#{i}@factory.ws" }
@@ -85,7 +85,7 @@ easier to generate unique values:
85
85
 
86
86
  It's possible to configure named factories:
87
87
 
88
- ModelFactory.configuration do
88
+ ModelFactory.configure do
89
89
  admin(User) do
90
90
  name {|i| "Admin User #{i}" }
91
91
  admin { true }
@@ -34,13 +34,13 @@ module ModelFactory # :nodoc:
34
34
  @counter += 1
35
35
  end
36
36
 
37
- def new_named(name, opt = {}, &block)
37
+ def new_named(name, opt, &block)
38
38
  instance = @class.new
39
39
  InstanceBuilder.new(instance, opt, next_counter, &@options[name])
40
40
  instance
41
41
  end
42
42
 
43
- def create_named(name, opt = {}, &block)
43
+ def create_named(name, opt, &block)
44
44
  instance = new_named(name, opt, &block)
45
45
  instance.save!
46
46
  instance.reload
@@ -52,7 +52,7 @@ module ModelFactory # :nodoc:
52
52
  class InstanceBuilder # :nodoc:
53
53
  def initialize(instance, params, counter, &block)
54
54
  @instance = instance
55
- @params = params
55
+ @params = params || {}
56
56
  @counter = counter
57
57
  @params.each { |attr, value| @instance.send "#{attr}=", value }
58
58
  instance_eval(&block) if block_given?
@@ -2,7 +2,7 @@ module ModelFactory #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 9
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -15,6 +15,10 @@ class ModelFactoryTest < Test::Unit::TestCase
15
15
  assert_raises(ActiveRecord::RecordInvalid) { StrictWidget.factory.create }
16
16
  end
17
17
 
18
+ should "not raise on nil params" do
19
+ assert_nothing_raised { Widget.factory.create(nil) }
20
+ end
21
+
18
22
  context "with a specified default" do
19
23
  setup do
20
24
  ModelFactory.configure do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modelfactory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Balthrop