factory_loader 0.1.1 → 0.1.2
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/lib/factory_loader.rb +3 -3
- data/spec/factory_loader_spec.rb +12 -3
- metadata +1 -1
data/lib/factory_loader.rb
CHANGED
@@ -75,7 +75,7 @@ require 'find'
|
|
75
75
|
# * Dave Crosby at Atomic Object
|
76
76
|
# * Ryan Fogle at Atomic Object
|
77
77
|
class FactoryLoader
|
78
|
-
VERSION = "0.1.
|
78
|
+
VERSION = "0.1.2"
|
79
79
|
|
80
80
|
# Constructs a FactoryLoader. The passed in factory_paths are searched recursively.
|
81
81
|
def initialize(*factory_paths)
|
@@ -110,8 +110,8 @@ class FactoryLoader
|
|
110
110
|
unless Object.const_defined?(factory_name)
|
111
111
|
eval <<-CODE
|
112
112
|
class ::#{factory_name}
|
113
|
-
def create(options
|
114
|
-
#{object_name}.new options
|
113
|
+
def create(*options)
|
114
|
+
#{object_name}.new *options
|
115
115
|
end
|
116
116
|
end
|
117
117
|
CODE
|
data/spec/factory_loader_spec.rb
CHANGED
@@ -57,11 +57,20 @@ describe FactoryLoader, "#load" do
|
|
57
57
|
::Dog.stub!(:new).and_return(@object)
|
58
58
|
end
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
60
|
+
describe "when constructor arguments are supplied" do
|
61
|
+
it "creates a presenter passing along any options" do
|
62
|
+
::Dog.should_receive(:new).with(:foo => :bar)
|
63
|
+
::DogFactory.new.create(:foo => :bar)
|
64
|
+
end
|
63
65
|
end
|
64
66
|
|
67
|
+
describe "when constructor arguments are not supplied" do
|
68
|
+
it "creates a presenter passing along no options" do
|
69
|
+
::Dog.should_receive(:new).with
|
70
|
+
::DogFactory.new.create
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
65
74
|
it "returns the newly created presenter" do
|
66
75
|
::DogFactory.new.create.should == @object
|
67
76
|
end
|