spec/spec_helper.rb in rr-0.8.0 vs spec/spec_helper.rb in rr-0.8.1

- old
+ new

@@ -18,90 +18,90 @@ after(:each) do RR::Space.instance = @original_space end end -module Spec::Example::ExampleMethods - def new_double( - double_injection=double_injection, - double_definition=RR::DoubleDefinitions::DoubleDefinition.new(creator = RR::DoubleDefinitions::DoubleDefinitionCreator.new, subject).with_any_args.any_number_of_times - ) - RR::Double.new( - double_injection, - double_definition - ) - end -end - -module Spec::Example::ExampleGroupMethods - def macro(name, &implementation) - (class << self; self; end).class_eval do - define_method(name, &implementation) +class Spec::ExampleGroup + class << self + def macro(name, &implementation) + (class << self; self; end).class_eval do + define_method(name, &implementation) + end end - end - define_method("normal strategy definition") do - describe "strategy definition" do - attr_reader :strategy_method_name + define_method("normal strategy definition") do + describe "strategy definition" do + attr_reader :strategy_method_name - context "when passed a subject" do - it "returns a DoubleDefinitionCreatorProxy" do - double = call_strategy(subject).foobar - double.should be_instance_of(RR::DoubleDefinitions::DoubleDefinition) + context "when passed a subject" do + it "returns a DoubleDefinitionCreatorProxy" do + double = call_strategy(subject).foobar + double.should be_instance_of(RR::DoubleDefinitions::DoubleDefinition) + end end - end - context "when passed a method name and a definition_eval_block" do - it "raises an ArgumentError" do - lambda do - call_strategy(subject, :foobar) {} - end.should raise_error(ArgumentError, "Cannot pass in a method name and a block") + context "when passed a method name and a definition_eval_block" do + it "raises an ArgumentError" do + lambda do + call_strategy(subject, :foobar) {} + end.should raise_error(ArgumentError, "Cannot pass in a method name and a block") + end end end end - end - define_method("! strategy definition") do - describe "strategy definition" do - attr_reader :strategy_method_name + define_method("! strategy definition") do + describe "strategy definition" do + attr_reader :strategy_method_name - context "when not passed a method_name argument" do - it "returns a DoubleDefinitionCreatorProxy" do - call_strategy.should respond_to(:__subject__) - end + context "when not passed a method_name argument" do + it "returns a DoubleDefinitionCreatorProxy" do + call_strategy.should respond_to(:__subject__) + end - context "when passed a definition_eval_block argument" do - it "calls the definition_eval_block and passes in the DoubleDefinitionCreatorProxy" do - passed_in_proxy = nil - proxy = call_strategy do |proxy| - passed_in_proxy = proxy - end + context "when passed a definition_eval_block argument" do + it "calls the definition_eval_block and passes in the DoubleDefinitionCreatorProxy" do + passed_in_proxy = nil + proxy = call_strategy do |proxy| + passed_in_proxy = proxy + end - passed_in_proxy.should == proxy + passed_in_proxy.should == proxy + end end end - end - context "when passed a method_name argument" do - it "returns a DoubleDefinition" do - double_definition = call_strategy(:foobar) - double_definition.class.should == RR::DoubleDefinitions::DoubleDefinition - end - - describe "the returned DoubleDefinition" do - it "has #subject set to an anonymous Object" do + context "when passed a method_name argument" do + it "returns a DoubleDefinition" do double_definition = call_strategy(:foobar) - double_definition.subject.class.should == Object + double_definition.class.should == RR::DoubleDefinitions::DoubleDefinition end + + describe "the returned DoubleDefinition" do + it "has #subject set to an anonymous Object" do + double_definition = call_strategy(:foobar) + double_definition.subject.class.should == Object + end + end end - end - context "when passed a method name and a definition_eval_block" do - it "raises an ArgumentError" do - lambda do - call_strategy(:foobar) {} - end.should raise_error(ArgumentError, "Cannot pass in a method name and a block") + context "when passed a method name and a definition_eval_block" do + it "raises an ArgumentError" do + lambda do + call_strategy(:foobar) {} + end.should raise_error(ArgumentError, "Cannot pass in a method name and a block") + end end end end end -end \ No newline at end of file + + def new_double( + double_injection=double_injection, + double_definition=RR::DoubleDefinitions::DoubleDefinition.new(creator = RR::DoubleDefinitions::DoubleDefinitionCreator.new, subject).with_any_args.any_number_of_times + ) + RR::Double.new( + double_injection, + double_definition + ) + end +end