0
@@ -148,8 +148,8 @@ describe ObjectDaddy, 'recording the registration of a generator method' do
0
-describe ObjectDaddy, "when spawning a class instance" do
0
+describe ObjectDaddy, 'when registering exemplars' do
0
@class = Class.new(OpenStruct)
0
@class.send(:include, ObjectDaddy)
0
@file_path = File.join(File.dirname(__FILE__), 'tmp')
0
@@ -158,44 +158,97 @@ describe ObjectDaddy, "when spawning a class instance" do
0
@class.stubs(:name).returns('Widget')
0
- it "should register exemplars for the target class on the first attempt" do
0
- @class.expects(:gather_exemplars)
0
- it "should not register exemplars for the target class after the first attempt" do
0
- @class.expects(:gather_exemplars).never
0
- it "should look for exemplars for the target class in the standard exemplar path" do
0
- @class.expects(:exemplar_path).returns(@file_path)
0
- it "should look for an exemplar for the target class, based on the class's name" do
0
- @class.expects(:name).returns('Widget')
0
+ describe 'before exemplars have been registered' do
0
+ @class.stubs(:exemplars_generated).returns(false)
0
+ it "should look for exemplars for the target class in the standard exemplar path" do
0
+ @class.expects(:exemplar_path).returns(@file_path)
0
+ @class.gather_exemplars
0
+ it "should look for an exemplar for the target class, based on the class's name" do
0
+ @class.expects(:name).returns('Widget')
0
+ @class.gather_exemplars
0
+ it "should register any generators found in the exemplar for the target class" do
0
+ # we are using the concrete Widget class here because otherwise it's difficult to have our exemplar file work in our class
0
+ # a dummy class, useful for testing the actual loading of exemplar files
0
+ Widget = Class.new(OpenStruct) { include ObjectDaddy }
0
+ File.open(@file_name, 'w') {|f| f.puts "class Widget\ngenerator_for :foo\nend\n"}
0
+ Widget.stubs(:exemplar_path).returns(@file_path)
0
+ Widget.expects(:generator_for)
0
+ Widget.gather_exemplars
0
+ # clean up test data file
0
+ File.unlink(@file_name) if File.exists?(@file_name)
0
+ it 'should record that exemplars have been registered' do
0
+ @class.expects(:exemplars_generated=).with(true)
0
+ @class.gather_exemplars
0
- it "should register any generators found in the exemplar for the target class" do
0
- # we are using the concrete Widget class here because otherwise it's difficult to have our exemplar file work in our class
0
- # a dummy class, useful for testing the actual loading of exemplar files
0
- Widget = Class.new(OpenStruct) { include ObjectDaddy }
0
- File.open(@file_name, 'w') {|f| f.puts "class Widget\ngenerator_for :foo\nend\n"}
0
- Widget.stubs(:exemplar_path).returns(@file_path)
0
- Widget.expects(:generator_for)
0
- # clean up test data file
0
- File.unlink(@file_name) if File.exists?(@file_name)
0
+ describe 'after exemplars have been registered' do
0
+ @class.stubs(:exemplars_generated).returns(true)
0
+ it "should not look for exemplars for the target class in the standard exemplar path" do
0
+ @class.expects(:exemplar_path).never
0
+ @class.gather_exemplars
0
+ it "should not look for an exemplar for the target class, based on the class's name" do
0
+ @class.expects(:name).never
0
+ @class.gather_exemplars
0
+ it 'should register no generators' do
0
+ # we are using the concrete Widget class here because otherwise it's difficult to have our exemplar file work in our class
0
+ # a dummy class, useful for testing the actual loading of exemplar files
0
+ Widget = Class.new(OpenStruct) { include ObjectDaddy }
0
+ File.open(@file_name, 'w') {|f| f.puts "class Widget\ngenerator_for :foo\nend\n"}
0
+ Widget.stubs(:exemplar_path).returns(@file_path)
0
+ Widget.stubs(:exemplars_generated).returns(true)
0
+ Widget.expects(:generator_for).never
0
+ Widget.gather_exemplars
0
+ # clean up test data file
0
+ File.unlink(@file_name) if File.exists?(@file_name)
0
+ it 'should not record that exemplars have been registered' do
0
+ @class.expects(:exemplars_generated=).never
0
+ @class.gather_exemplars
0
it "should register no generators if no exemplar for the target class is available" do
0
@class.expects(:generator_for).never
0
+ @class.gather_exemplars
0
+describe ObjectDaddy, "when spawning a class instance" do
0
+ @class = Class.new(OpenStruct)
0
+ @class.send(:include, ObjectDaddy)
0
+ @file_path = File.join(File.dirname(__FILE__), 'tmp')
0
+ @file_name = File.join(@file_path, 'widget_exemplar.rb')
0
+ @class.stubs(:exemplar_path).returns(@file_path)
0
+ @class.stubs(:name).returns('Widget')
0
+ it "should register exemplars for the target class" do
0
+ @class.expects(:gather_exemplars)