rr 0.3.3 → 0.3.4
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/CHANGES +3 -0
 - data/README +5 -0
 - data/Rakefile +1 -1
 - data/examples/rr/double/double_register_scenario_example.rb +1 -1
 - data/examples/rr/double/double_verify_example.rb +1 -1
 - data/examples/rr/expectations/times_called_expectation/times_called_expectation_example.rb +0 -5
 - data/examples/rr/expectations/times_called_expectation/times_called_expectation_integer_example.rb +2 -1
 - data/examples/rr/expectations/times_called_expectation/times_called_expectation_proc_example.rb +2 -2
 - data/examples/rr/expectations/times_called_expectation/times_called_expectation_range_example.rb +2 -1
 - data/examples/rr/extensions/instance_methods_creator_example.rb +54 -9
 - data/examples/rr/scenario_creator_example.rb +32 -42
 - data/examples/rr/scenario_definition_example.rb +503 -0
 - data/examples/rr/scenario_example.rb +48 -32
 - data/examples/rr/scenario_method_proxy_example.rb +2 -2
 - data/examples/rr/space/space_verify_example.rb +3 -3
 - data/lib/rr.rb +4 -0
 - data/lib/rr/expectations/times_called_expectation.rb +4 -5
 - data/lib/rr/extensions/instance_methods.rb +16 -0
 - data/lib/rr/scenario.rb +60 -82
 - data/lib/rr/scenario_creator.rb +67 -56
 - data/lib/rr/scenario_definition.rb +277 -0
 - data/lib/rr/scenario_definition_builder.rb +43 -0
 - data/lib/rr/space.rb +7 -2
 - metadata +5 -2
 
    
        data/CHANGES
    CHANGED
    
    
    
        data/README
    CHANGED
    
    
    
        data/Rakefile
    CHANGED
    
    
| 
         @@ -14,7 +14,7 @@ describe Double, "#register_scenario" do 
     | 
|
| 
       14 
14 
     | 
    
         
             
              end
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
              it "adds the scenario to the scenarios list" do
         
     | 
| 
       17 
     | 
    
         
            -
                scenario = Scenario.new(@space, @double)
         
     | 
| 
      
 17 
     | 
    
         
            +
                scenario = Scenario.new(@space, @double, @space.scenario_definition)
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
                @double.scenarios.should_not include(scenario)
         
     | 
| 
       20 
20 
     | 
    
         
             
                @double.register_scenario scenario
         
     | 
| 
         @@ -11,7 +11,7 @@ describe Double, "#verify" do 
     | 
|
| 
       11 
11 
     | 
    
         
             
              end
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
              it "verifies each scenario was met" do
         
     | 
| 
       14 
     | 
    
         
            -
                scenario = Scenario.new(@space, @double)
         
     | 
| 
      
 14 
     | 
    
         
            +
                scenario = Scenario.new(@space, @double, @space.scenario_definition)
         
     | 
| 
       15 
15 
     | 
    
         
             
                @double.register_scenario scenario
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
                scenario.with(1).once.returns {nil}
         
     | 
| 
         @@ -3,11 +3,6 @@ require "examples/example_helper" 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module RR
         
     | 
| 
       4 
4 
     | 
    
         
             
            module Expectations
         
     | 
| 
       5 
5 
     | 
    
         
             
            describe TimesCalledExpectation, ".new" do
         
     | 
| 
       6 
     | 
    
         
            -
              it "doesn't accept both an argument and a block" do
         
     | 
| 
       7 
     | 
    
         
            -
                proc do
         
     | 
| 
       8 
     | 
    
         
            -
                  TimesCalledExpectation.new(2) {|value| value == 2}
         
     | 
| 
       9 
     | 
    
         
            -
                end.should raise_error(ArgumentError, "Cannot pass in both an argument and a block")
         
     | 
| 
       10 
     | 
    
         
            -
              end
         
     | 
| 
       11 
6 
     | 
    
         
             
            end
         
     | 
| 
       12 
7 
     | 
    
         
             
            end
         
     | 
| 
       13 
8 
     | 
    
         
             
            end
         
     | 
    
        data/examples/rr/expectations/times_called_expectation/times_called_expectation_integer_example.rb
    CHANGED
    
    | 
         @@ -6,7 +6,8 @@ module Expectations 
     | 
|
| 
       6 
6 
     | 
    
         
             
                it_should_behave_like "RR::Expectations::TimesCalledExpectation"
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                before do
         
     | 
| 
       9 
     | 
    
         
            -
                  @ 
     | 
| 
      
 9 
     | 
    
         
            +
                  @matcher = TimesCalledMatchers::IntegerMatcher.new(2)
         
     | 
| 
      
 10 
     | 
    
         
            +
                  @expectation = TimesCalledExpectation.new(@matcher)
         
     | 
| 
       10 
11 
     | 
    
         
             
                  @expected_line = __LINE__ - 1
         
     | 
| 
       11 
12 
     | 
    
         
             
                end
         
     | 
| 
       12 
13 
     | 
    
         
             
              end
         
     | 
    
        data/examples/rr/expectations/times_called_expectation/times_called_expectation_proc_example.rb
    CHANGED
    
    | 
         @@ -6,12 +6,12 @@ module Expectations 
     | 
|
| 
       6 
6 
     | 
    
         
             
                it_should_behave_like "RR::Expectations::TimesCalledExpectation"
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                before do
         
     | 
| 
       9 
     | 
    
         
            -
                  @ 
     | 
| 
      
 9 
     | 
    
         
            +
                  @matcher = TimesCalledMatchers::ProcMatcher.new(proc {|value| value == 2})
         
     | 
| 
      
 10 
     | 
    
         
            +
                  @expectation = TimesCalledExpectation.new(@matcher)
         
     | 
| 
       10 
11 
     | 
    
         
             
                  @expected_line = __LINE__ - 1
         
     | 
| 
       11 
12 
     | 
    
         
             
                end
         
     | 
| 
       12 
13 
     | 
    
         
             
              end
         
     | 
| 
       13 
14 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
15 
     | 
    
         
             
              describe TimesCalledExpectation, "#verify" do
         
     | 
| 
       16 
16 
     | 
    
         
             
                it_should_behave_like "RR::Expectations::TimesCalledExpectation with ProcMatcher"
         
     | 
| 
       17 
17 
     | 
    
         | 
    
        data/examples/rr/expectations/times_called_expectation/times_called_expectation_range_example.rb
    CHANGED
    
    | 
         @@ -6,7 +6,8 @@ module Expectations 
     | 
|
| 
       6 
6 
     | 
    
         
             
                it_should_behave_like "RR::Expectations::TimesCalledExpectation"
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                before do
         
     | 
| 
       9 
     | 
    
         
            -
                  @ 
     | 
| 
      
 9 
     | 
    
         
            +
                  @matcher = TimesCalledMatchers::RangeMatcher.new(1..2)
         
     | 
| 
      
 10 
     | 
    
         
            +
                  @expectation = TimesCalledExpectation.new(@matcher)
         
     | 
| 
       10 
11 
     | 
    
         
             
                  @expected_line = __LINE__ - 1
         
     | 
| 
       11 
12 
     | 
    
         
             
                end
         
     | 
| 
       12 
13 
     | 
    
         
             
              end
         
     | 
| 
         @@ -41,13 +41,12 @@ module Extensions 
     | 
|
| 
       41 
41 
     | 
    
         
             
                end
         
     | 
| 
       42 
42 
     | 
    
         | 
| 
       43 
43 
     | 
    
         
             
                def create_scenario_with_method_name(scenario)
         
     | 
| 
       44 
     | 
    
         
            -
                  method_name = scenario.method_name
         
     | 
| 
       45 
44 
     | 
    
         
             
                  scenario.with(1, 2) {:baz}
         
     | 
| 
       46 
45 
     | 
    
         
             
                  scenario.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(1)
         
     | 
| 
       47 
46 
     | 
    
         
             
                  scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
         
     | 
| 
       48 
47 
     | 
    
         
             
                  scenario.argument_expectation.expected_arguments.should == [1, 2]
         
     | 
| 
       49 
48 
     | 
    
         | 
| 
       50 
     | 
    
         
            -
                  @subject. 
     | 
| 
      
 49 
     | 
    
         
            +
                  @subject.foobar(1, 2).should == :baz
         
     | 
| 
       51 
50 
     | 
    
         
             
                end
         
     | 
| 
       52 
51 
     | 
    
         | 
| 
       53 
52 
     | 
    
         
             
                def create_mock_call_chain(creator)
         
     | 
| 
         @@ -99,11 +98,10 @@ module Extensions 
     | 
|
| 
       99 
98 
     | 
    
         
             
                end
         
     | 
| 
       100 
99 
     | 
    
         | 
| 
       101 
100 
     | 
    
         
             
                def create_scenario_with_method_name(scenario)
         
     | 
| 
       102 
     | 
    
         
            -
                  method_name = scenario.method_name
         
     | 
| 
       103 
101 
     | 
    
         
             
                  scenario.with(1, 2) {:baz}
         
     | 
| 
       104 
102 
     | 
    
         
             
                  scenario.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
         
     | 
| 
       105 
103 
     | 
    
         
             
                  scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
         
     | 
| 
       106 
     | 
    
         
            -
                  @subject. 
     | 
| 
      
 104 
     | 
    
         
            +
                  @subject.foobar(1, 2).should == :baz
         
     | 
| 
       107 
105 
     | 
    
         
             
                end
         
     | 
| 
       108 
106 
     | 
    
         | 
| 
       109 
107 
     | 
    
         
             
                def create_stub_call_chain(creator)
         
     | 
| 
         @@ -169,13 +167,12 @@ module Extensions 
     | 
|
| 
       169 
167 
     | 
    
         
             
                end
         
     | 
| 
       170 
168 
     | 
    
         | 
| 
       171 
169 
     | 
    
         
             
                def create_scenario_with_method_name(scenario)
         
     | 
| 
       172 
     | 
    
         
            -
                  method_name = scenario.method_name
         
     | 
| 
       173 
170 
     | 
    
         
             
                  scenario.with(1, 2)
         
     | 
| 
       174 
171 
     | 
    
         
             
                  scenario.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(1)
         
     | 
| 
       175 
172 
     | 
    
         
             
                  scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
         
     | 
| 
       176 
173 
     | 
    
         
             
                  scenario.argument_expectation.expected_arguments.should == [1, 2]
         
     | 
| 
       177 
174 
     | 
    
         | 
| 
       178 
     | 
    
         
            -
                  @subject. 
     | 
| 
      
 175 
     | 
    
         
            +
                  @subject.foobar(1, 2).should == :original_value
         
     | 
| 
       179 
176 
     | 
    
         
             
                end
         
     | 
| 
       180 
177 
     | 
    
         | 
| 
       181 
178 
     | 
    
         
             
                def create_mock_probe_call_chain(creator)
         
     | 
| 
         @@ -227,7 +224,6 @@ module Extensions 
     | 
|
| 
       227 
224 
     | 
    
         
             
                end
         
     | 
| 
       228 
225 
     | 
    
         | 
| 
       229 
226 
     | 
    
         
             
                def create_scenario_with_method_name(scenario)
         
     | 
| 
       230 
     | 
    
         
            -
                  method_name = scenario.method_name
         
     | 
| 
       231 
227 
     | 
    
         
             
                  scenario.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
         
     | 
| 
       232 
228 
     | 
    
         
             
                  scenario.argument_expectation.class.should == RR::Expectations::AnyArgumentExpectation
         
     | 
| 
       233 
229 
     | 
    
         | 
| 
         @@ -288,14 +284,13 @@ module Extensions 
     | 
|
| 
       288 
284 
     | 
    
         
             
                end
         
     | 
| 
       289 
285 
     | 
    
         | 
| 
       290 
286 
     | 
    
         
             
                def create_scenario_with_method_name(scenario)
         
     | 
| 
       291 
     | 
    
         
            -
                  method_name = scenario.method_name
         
     | 
| 
       292 
287 
     | 
    
         
             
                  scenario.with(1, 2)
         
     | 
| 
       293 
288 
     | 
    
         
             
                  scenario.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(0)
         
     | 
| 
       294 
289 
     | 
    
         
             
                  scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
         
     | 
| 
       295 
290 
     | 
    
         
             
                  scenario.argument_expectation.expected_arguments.should == [1, 2]
         
     | 
| 
       296 
291 
     | 
    
         | 
| 
       297 
292 
     | 
    
         
             
                  proc do
         
     | 
| 
       298 
     | 
    
         
            -
                    @subject. 
     | 
| 
      
 293 
     | 
    
         
            +
                    @subject.foobar(1, 2)
         
     | 
| 
       299 
294 
     | 
    
         
             
                  end.should raise_error(Errors::TimesCalledError)
         
     | 
| 
       300 
295 
     | 
    
         
             
                  reset
         
     | 
| 
       301 
296 
     | 
    
         
             
                  nil
         
     | 
| 
         @@ -314,5 +309,55 @@ module Extensions 
     | 
|
| 
       314 
309 
     | 
    
         
             
                  nil
         
     | 
| 
       315 
310 
     | 
    
         
             
                end
         
     | 
| 
       316 
311 
     | 
    
         
             
              end
         
     | 
| 
      
 312 
     | 
    
         
            +
             
     | 
| 
      
 313 
     | 
    
         
            +
              describe ScenarioCreator, "#instance_of and #mock" do
         
     | 
| 
      
 314 
     | 
    
         
            +
                before do
         
     | 
| 
      
 315 
     | 
    
         
            +
                  @klass = Class.new
         
     | 
| 
      
 316 
     | 
    
         
            +
                end
         
     | 
| 
      
 317 
     | 
    
         
            +
             
     | 
| 
      
 318 
     | 
    
         
            +
                it "returns a ScenarioCreator when passed no arguments" do
         
     | 
| 
      
 319 
     | 
    
         
            +
                  instance_of.instance_of.should be_instance_of(ScenarioCreator)
         
     | 
| 
      
 320 
     | 
    
         
            +
                end
         
     | 
| 
      
 321 
     | 
    
         
            +
             
     | 
| 
      
 322 
     | 
    
         
            +
                it "sets up the RR instance_of call chain" do
         
     | 
| 
      
 323 
     | 
    
         
            +
                  should create_instance_of_call_chain(instance_of.mock(@klass))
         
     | 
| 
      
 324 
     | 
    
         
            +
                end
         
     | 
| 
      
 325 
     | 
    
         
            +
             
     | 
| 
      
 326 
     | 
    
         
            +
                it "#rr_instance_of sets up the RR instance_of call chain" do
         
     | 
| 
      
 327 
     | 
    
         
            +
                  should create_instance_of_call_chain(rr_instance_of.mock(@klass))
         
     | 
| 
      
 328 
     | 
    
         
            +
                end
         
     | 
| 
      
 329 
     | 
    
         
            +
             
     | 
| 
      
 330 
     | 
    
         
            +
                it "creates a instance_of Scenario for method when passed a second argument" do
         
     | 
| 
      
 331 
     | 
    
         
            +
                  should create_scenario_with_method_name(instance_of.mock(@klass, :foobar))
         
     | 
| 
      
 332 
     | 
    
         
            +
                end
         
     | 
| 
      
 333 
     | 
    
         
            +
             
     | 
| 
      
 334 
     | 
    
         
            +
                it "creates a instance_of Scenario for method when passed a second argument with rr_instance_of" do
         
     | 
| 
      
 335 
     | 
    
         
            +
                  should create_scenario_with_method_name(rr_instance_of.mock(@klass, :foobar))
         
     | 
| 
      
 336 
     | 
    
         
            +
                end
         
     | 
| 
      
 337 
     | 
    
         
            +
             
     | 
| 
      
 338 
     | 
    
         
            +
                it "raises error if passed a method name and a block" do
         
     | 
| 
      
 339 
     | 
    
         
            +
                  proc do
         
     | 
| 
      
 340 
     | 
    
         
            +
                    instance_of.mock(@klass, :foobar) {}
         
     | 
| 
      
 341 
     | 
    
         
            +
                  end.should raise_error(ArgumentError, "Cannot pass in a method name and a block")
         
     | 
| 
      
 342 
     | 
    
         
            +
                end
         
     | 
| 
      
 343 
     | 
    
         
            +
             
     | 
| 
      
 344 
     | 
    
         
            +
                def create_scenario_with_method_name(scenario)
         
     | 
| 
      
 345 
     | 
    
         
            +
                  scenario.with(1, 2) {:baz}
         
     | 
| 
      
 346 
     | 
    
         
            +
                  scenario.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(1)
         
     | 
| 
      
 347 
     | 
    
         
            +
                  scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
         
     | 
| 
      
 348 
     | 
    
         
            +
                  scenario.argument_expectation.expected_arguments.should == [1, 2]
         
     | 
| 
      
 349 
     | 
    
         
            +
             
     | 
| 
      
 350 
     | 
    
         
            +
                  @klass.new.foobar(1, 2).should == :baz
         
     | 
| 
      
 351 
     | 
    
         
            +
                end
         
     | 
| 
      
 352 
     | 
    
         
            +
             
     | 
| 
      
 353 
     | 
    
         
            +
                def create_instance_of_call_chain(creator)
         
     | 
| 
      
 354 
     | 
    
         
            +
                  scenario = creator.foobar(1, 2) {:baz}
         
     | 
| 
      
 355 
     | 
    
         
            +
                  scenario.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(1)
         
     | 
| 
      
 356 
     | 
    
         
            +
                  scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
         
     | 
| 
      
 357 
     | 
    
         
            +
                  scenario.argument_expectation.expected_arguments.should == [1, 2]
         
     | 
| 
      
 358 
     | 
    
         
            +
             
     | 
| 
      
 359 
     | 
    
         
            +
                  @klass.new.foobar(1, 2).should == :baz
         
     | 
| 
      
 360 
     | 
    
         
            +
                end
         
     | 
| 
      
 361 
     | 
    
         
            +
              end
         
     | 
| 
       317 
362 
     | 
    
         
             
            end
         
     | 
| 
       318 
363 
     | 
    
         
             
            end
         
     | 
| 
         @@ -18,12 +18,12 @@ describe ScenarioCreator, " strategy definition", :shared => true do 
     | 
|
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
              it "returns a ScenarioMethodProxy when passed a subject" do
         
     | 
| 
       20 
20 
     | 
    
         
             
                scenario = @creator.__send__(@method_name, @subject).foobar
         
     | 
| 
       21 
     | 
    
         
            -
                scenario.should be_instance_of( 
     | 
| 
      
 21 
     | 
    
         
            +
                scenario.should be_instance_of(ScenarioDefinition)
         
     | 
| 
       22 
22 
     | 
    
         
             
              end
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
24 
     | 
    
         
             
              it "returns a ScenarioMethodProxy when passed Kernel" do
         
     | 
| 
       25 
25 
     | 
    
         
             
                scenario = @creator.__send__(@method_name, Kernel).foobar
         
     | 
| 
       26 
     | 
    
         
            -
                scenario.should be_instance_of( 
     | 
| 
      
 26 
     | 
    
         
            +
                scenario.should be_instance_of(ScenarioDefinition)
         
     | 
| 
       27 
27 
     | 
    
         
             
              end
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
29 
     | 
    
         
             
              it "raises error if passed a method name and a block" do
         
     | 
| 
         @@ -81,13 +81,12 @@ describe ScenarioCreator, "#mock" do 
     | 
|
| 
       81 
81 
     | 
    
         
             
              end
         
     | 
| 
       82 
82 
     | 
    
         | 
| 
       83 
83 
     | 
    
         
             
              def create_scenario_with_method_name(scenario)
         
     | 
| 
       84 
     | 
    
         
            -
                method_name = scenario.method_name
         
     | 
| 
       85 
84 
     | 
    
         
             
                scenario.with(1, 2) {:baz}
         
     | 
| 
       86 
85 
     | 
    
         
             
                scenario.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(1)
         
     | 
| 
       87 
86 
     | 
    
         
             
                scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
         
     | 
| 
       88 
87 
     | 
    
         
             
                scenario.argument_expectation.expected_arguments.should == [1, 2]
         
     | 
| 
       89 
88 
     | 
    
         | 
| 
       90 
     | 
    
         
            -
                @subject. 
     | 
| 
      
 89 
     | 
    
         
            +
                @subject.foobar(1, 2).should == :baz
         
     | 
| 
       91 
90 
     | 
    
         
             
              end
         
     | 
| 
       92 
91 
     | 
    
         | 
| 
       93 
92 
     | 
    
         
             
              def create_mock_call_chain(creator)
         
     | 
| 
         @@ -116,11 +115,10 @@ describe ScenarioCreator, "#stub" do 
     | 
|
| 
       116 
115 
     | 
    
         
             
              end
         
     | 
| 
       117 
116 
     | 
    
         | 
| 
       118 
117 
     | 
    
         
             
              def create_scenario_with_method_name(scenario)
         
     | 
| 
       119 
     | 
    
         
            -
                method_name = scenario.method_name
         
     | 
| 
       120 
118 
     | 
    
         
             
                scenario.with(1, 2) {:baz}
         
     | 
| 
       121 
119 
     | 
    
         
             
                scenario.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
         
     | 
| 
       122 
120 
     | 
    
         
             
                scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
         
     | 
| 
       123 
     | 
    
         
            -
                @subject. 
     | 
| 
      
 121 
     | 
    
         
            +
                @subject.foobar(1, 2).should == :baz
         
     | 
| 
       124 
122 
     | 
    
         
             
              end
         
     | 
| 
       125 
123 
     | 
    
         | 
| 
       126 
124 
     | 
    
         
             
              def create_stub_call_chain(creator)
         
     | 
| 
         @@ -181,14 +179,13 @@ describe ScenarioCreator, "#do_not_call" do 
     | 
|
| 
       181 
179 
     | 
    
         
             
              end
         
     | 
| 
       182 
180 
     | 
    
         | 
| 
       183 
181 
     | 
    
         
             
              def create_scenario_with_method_name(scenario)
         
     | 
| 
       184 
     | 
    
         
            -
                method_name = scenario.method_name
         
     | 
| 
       185 
182 
     | 
    
         
             
                scenario.with(1, 2)
         
     | 
| 
       186 
183 
     | 
    
         
             
                scenario.times_matcher.should == TimesCalledMatchers::IntegerMatcher.new(0)
         
     | 
| 
       187 
184 
     | 
    
         
             
                scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
         
     | 
| 
       188 
185 
     | 
    
         
             
                scenario.argument_expectation.expected_arguments.should == [1, 2]
         
     | 
| 
       189 
186 
     | 
    
         | 
| 
       190 
187 
     | 
    
         
             
                proc do
         
     | 
| 
       191 
     | 
    
         
            -
                  @subject. 
     | 
| 
      
 188 
     | 
    
         
            +
                  @subject.foobar(1, 2)
         
     | 
| 
       192 
189 
     | 
    
         
             
                end.should raise_error(Errors::TimesCalledError)
         
     | 
| 
       193 
190 
     | 
    
         
             
                reset
         
     | 
| 
       194 
191 
     | 
    
         
             
                nil
         
     | 
| 
         @@ -248,26 +245,28 @@ end 
     | 
|
| 
       248 
245 
     | 
    
         
             
            describe ScenarioCreator, "#instance_of" do
         
     | 
| 
       249 
246 
     | 
    
         
             
              it_should_behave_like "RR::ScenarioCreator"
         
     | 
| 
       250 
247 
     | 
    
         | 
| 
       251 
     | 
    
         
            -
              it "raises an error when not passed a class"  
     | 
| 
       252 
     | 
    
         
            -
             
     | 
| 
       253 
     | 
    
         
            -
             
     | 
| 
       254 
     | 
    
         
            -
             
     | 
| 
       255 
     | 
    
         
            -
             
     | 
| 
       256 
     | 
    
         
            -
             
     | 
| 
       257 
     | 
    
         
            -
              it "sets up the RR probe call chain"  
     | 
| 
       258 
     | 
    
         
            -
             
     | 
| 
       259 
     | 
    
         
            -
             
     | 
| 
       260 
     | 
    
         
            -
             
     | 
| 
       261 
     | 
    
         
            -
             
     | 
| 
       262 
     | 
    
         
            -
             
     | 
| 
       263 
     | 
    
         
            -
             
     | 
| 
       264 
     | 
    
         
            -
             
     | 
| 
       265 
     | 
    
         
            -
             
     | 
| 
       266 
     | 
    
         
            -
             
     | 
| 
       267 
     | 
    
         
            -
             
     | 
| 
       268 
     | 
    
         
            -
             
     | 
| 
       269 
     | 
    
         
            -
             
     | 
| 
       270 
     | 
    
         
            -
             
     | 
| 
      
 248 
     | 
    
         
            +
              it "raises an error when not passed a class" do
         
     | 
| 
      
 249 
     | 
    
         
            +
                proc do
         
     | 
| 
      
 250 
     | 
    
         
            +
                  @creator.instance_of(Object.new)
         
     | 
| 
      
 251 
     | 
    
         
            +
                end.should raise_error(ArgumentError, "instance_of only accepts class objects")
         
     | 
| 
      
 252 
     | 
    
         
            +
              end
         
     | 
| 
      
 253 
     | 
    
         
            +
             
     | 
| 
      
 254 
     | 
    
         
            +
              it "sets up the RR probe call chain" do
         
     | 
| 
      
 255 
     | 
    
         
            +
                klass = Class.new
         
     | 
| 
      
 256 
     | 
    
         
            +
                scenario = @creator.stub.instance_of(klass).foobar(1, 2) {:baz}
         
     | 
| 
      
 257 
     | 
    
         
            +
                scenario.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
         
     | 
| 
      
 258 
     | 
    
         
            +
                scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
         
     | 
| 
      
 259 
     | 
    
         
            +
                klass.new.foobar(1, 2).should == :baz
         
     | 
| 
      
 260 
     | 
    
         
            +
              end
         
     | 
| 
      
 261 
     | 
    
         
            +
             
     | 
| 
      
 262 
     | 
    
         
            +
              it "creates a probe Scenario for method when passed a second argument" do
         
     | 
| 
      
 263 
     | 
    
         
            +
                klass = Class.new
         
     | 
| 
      
 264 
     | 
    
         
            +
                scenario = @creator.stub.instance_of(klass, :foobar)
         
     | 
| 
      
 265 
     | 
    
         
            +
                scenario.with(1, 2) {:baz}
         
     | 
| 
      
 266 
     | 
    
         
            +
                scenario.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
         
     | 
| 
      
 267 
     | 
    
         
            +
                scenario.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
         
     | 
| 
      
 268 
     | 
    
         
            +
                klass.new.foobar(1, 2).should == :baz
         
     | 
| 
      
 269 
     | 
    
         
            +
              end
         
     | 
| 
       271 
270 
     | 
    
         
             
            end
         
     | 
| 
       272 
271 
     | 
    
         | 
| 
       273 
272 
     | 
    
         
             
            describe ScenarioCreator, "#create! using no strategy" do
         
     | 
| 
         @@ -283,17 +282,8 @@ describe ScenarioCreator, "#create! using no strategy" do 
     | 
|
| 
       283 
282 
     | 
    
         
             
              end
         
     | 
| 
       284 
283 
     | 
    
         
             
            end
         
     | 
| 
       285 
284 
     | 
    
         | 
| 
       286 
     | 
    
         
            -
            describe ScenarioCreator, "#create!", :shared => true do
         
     | 
| 
       287 
     | 
    
         
            -
              it_should_behave_like "RR::ScenarioCreator"
         
     | 
| 
       288 
     | 
    
         
            -
             
     | 
| 
       289 
     | 
    
         
            -
              it "initializes creator with passed in object" do
         
     | 
| 
       290 
     | 
    
         
            -
                @creator.create!(@subject, :foobar)
         
     | 
| 
       291 
     | 
    
         
            -
                @creator.subject.should === @subject
         
     | 
| 
       292 
     | 
    
         
            -
              end
         
     | 
| 
       293 
     | 
    
         
            -
            end
         
     | 
| 
       294 
     | 
    
         
            -
             
     | 
| 
       295 
285 
     | 
    
         
             
            describe ScenarioCreator, "#create! using mock strategy" do
         
     | 
| 
       296 
     | 
    
         
            -
              it_should_behave_like "RR::ScenarioCreator 
     | 
| 
      
 286 
     | 
    
         
            +
              it_should_behave_like "RR::ScenarioCreator"
         
     | 
| 
       297 
287 
     | 
    
         | 
| 
       298 
288 
     | 
    
         
             
              before do
         
     | 
| 
       299 
289 
     | 
    
         
             
                @creator.mock
         
     | 
| 
         @@ -309,7 +299,7 @@ describe ScenarioCreator, "#create! using mock strategy" do 
     | 
|
| 
       309 
299 
     | 
    
         
             
            end
         
     | 
| 
       310 
300 
     | 
    
         | 
| 
       311 
301 
     | 
    
         
             
            describe ScenarioCreator, "#create! using stub strategy" do
         
     | 
| 
       312 
     | 
    
         
            -
              it_should_behave_like "RR::ScenarioCreator 
     | 
| 
      
 302 
     | 
    
         
            +
              it_should_behave_like "RR::ScenarioCreator"
         
     | 
| 
       313 
303 
     | 
    
         | 
| 
       314 
304 
     | 
    
         
             
              before do
         
     | 
| 
       315 
305 
     | 
    
         
             
                @creator.stub
         
     | 
| 
         @@ -331,7 +321,7 @@ describe ScenarioCreator, "#create! using stub strategy" do 
     | 
|
| 
       331 
321 
     | 
    
         
             
            end
         
     | 
| 
       332 
322 
     | 
    
         | 
| 
       333 
323 
     | 
    
         
             
            describe ScenarioCreator, "#create! using do_not_call strategy" do
         
     | 
| 
       334 
     | 
    
         
            -
              it_should_behave_like "RR::ScenarioCreator 
     | 
| 
      
 324 
     | 
    
         
            +
              it_should_behave_like "RR::ScenarioCreator"
         
     | 
| 
       335 
325 
     | 
    
         | 
| 
       336 
326 
     | 
    
         
             
              before do
         
     | 
| 
       337 
327 
     | 
    
         
             
                @creator.do_not_call
         
     | 
| 
         @@ -357,7 +347,7 @@ describe ScenarioCreator, "#create! using do_not_call strategy" do 
     | 
|
| 
       357 
347 
     | 
    
         
             
            end
         
     | 
| 
       358 
348 
     | 
    
         | 
| 
       359 
349 
     | 
    
         
             
            describe ScenarioCreator, "#create! using mock strategy with probe" do
         
     | 
| 
       360 
     | 
    
         
            -
              it_should_behave_like "RR::ScenarioCreator 
     | 
| 
      
 350 
     | 
    
         
            +
              it_should_behave_like "RR::ScenarioCreator"
         
     | 
| 
       361 
351 
     | 
    
         | 
| 
       362 
352 
     | 
    
         
             
              before do
         
     | 
| 
       363 
353 
     | 
    
         
             
                @creator.mock
         
     | 
| 
         @@ -389,7 +379,7 @@ describe ScenarioCreator, "#create! using mock strategy with probe" do 
     | 
|
| 
       389 
379 
     | 
    
         
             
            end
         
     | 
| 
       390 
380 
     | 
    
         | 
| 
       391 
381 
     | 
    
         
             
            describe ScenarioCreator, "#create! using stub strategy with probe" do
         
     | 
| 
       392 
     | 
    
         
            -
              it_should_behave_like "RR::ScenarioCreator 
     | 
| 
      
 382 
     | 
    
         
            +
              it_should_behave_like "RR::ScenarioCreator"
         
     | 
| 
       393 
383 
     | 
    
         | 
| 
       394 
384 
     | 
    
         
             
              before do
         
     | 
| 
       395 
385 
     | 
    
         
             
                @creator.stub
         
     | 
| 
         @@ -0,0 +1,503 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "examples/example_helper"
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module RR
         
     | 
| 
      
 4 
     | 
    
         
            +
            describe ScenarioDefinition, :shared => true do
         
     | 
| 
      
 5 
     | 
    
         
            +
              before do
         
     | 
| 
      
 6 
     | 
    
         
            +
                @space = Space.new
         
     | 
| 
      
 7 
     | 
    
         
            +
                @object = Object.new
         
     | 
| 
      
 8 
     | 
    
         
            +
                def @object.foobar(a, b)
         
     | 
| 
      
 9 
     | 
    
         
            +
                  [b, a]
         
     | 
| 
      
 10 
     | 
    
         
            +
                end
         
     | 
| 
      
 11 
     | 
    
         
            +
                @double = @space.double(@object, :foobar)
         
     | 
| 
      
 12 
     | 
    
         
            +
                @scenario = @space.scenario(@double)
         
     | 
| 
      
 13 
     | 
    
         
            +
                @definition = @scenario.definition
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            describe ScenarioDefinition, "#with" do
         
     | 
| 
      
 18 
     | 
    
         
            +
              it_should_behave_like "RR::ScenarioDefinition"
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              it "returns ScenarioDefinition" do
         
     | 
| 
      
 21 
     | 
    
         
            +
                @definition.with(1).should === @definition
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              it "sets an ArgumentEqualityExpectation" do
         
     | 
| 
      
 25 
     | 
    
         
            +
                @definition.with(1)
         
     | 
| 
      
 26 
     | 
    
         
            +
                @definition.should be_exact_match(1)
         
     | 
| 
      
 27 
     | 
    
         
            +
                @definition.should_not be_exact_match(2)
         
     | 
| 
      
 28 
     | 
    
         
            +
              end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
              it "sets return value when block passed in" do
         
     | 
| 
      
 31 
     | 
    
         
            +
                @definition.with(1) {:return_value}
         
     | 
| 
      
 32 
     | 
    
         
            +
                @object.foobar(1).should == :return_value
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
      
 34 
     | 
    
         
            +
            end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            describe ScenarioDefinition, "#with_any_args" do
         
     | 
| 
      
 37 
     | 
    
         
            +
              it_should_behave_like "RR::ScenarioDefinition"
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
              before do
         
     | 
| 
      
 40 
     | 
    
         
            +
                @definition.with_any_args {:return_value}
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
              it "returns ScenarioDefinition" do
         
     | 
| 
      
 44 
     | 
    
         
            +
                @definition.with_no_args.should === @definition
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
              it "sets an AnyArgumentExpectation" do
         
     | 
| 
      
 48 
     | 
    
         
            +
                @definition.should_not be_exact_match(1)
         
     | 
| 
      
 49 
     | 
    
         
            +
                @definition.should be_wildcard_match(1)
         
     | 
| 
      
 50 
     | 
    
         
            +
              end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
              it "sets return value when block passed in" do
         
     | 
| 
      
 53 
     | 
    
         
            +
                @object.foobar(:anything).should == :return_value
         
     | 
| 
      
 54 
     | 
    
         
            +
              end
         
     | 
| 
      
 55 
     | 
    
         
            +
            end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
            describe ScenarioDefinition, "#with_no_args" do
         
     | 
| 
      
 58 
     | 
    
         
            +
              it_should_behave_like "RR::ScenarioDefinition"
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
              before do
         
     | 
| 
      
 61 
     | 
    
         
            +
                @definition.with_no_args {:return_value}
         
     | 
| 
      
 62 
     | 
    
         
            +
              end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
              it "returns ScenarioDefinition" do
         
     | 
| 
      
 65 
     | 
    
         
            +
                @definition.with_no_args.should === @definition
         
     | 
| 
      
 66 
     | 
    
         
            +
              end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
              it "sets an ArgumentEqualityExpectation with no arguments" do
         
     | 
| 
      
 69 
     | 
    
         
            +
                @definition.argument_expectation.should == Expectations::ArgumentEqualityExpectation.new()
         
     | 
| 
      
 70 
     | 
    
         
            +
              end
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
              it "sets return value when block passed in" do
         
     | 
| 
      
 73 
     | 
    
         
            +
                @object.foobar().should == :return_value
         
     | 
| 
      
 74 
     | 
    
         
            +
              end
         
     | 
| 
      
 75 
     | 
    
         
            +
            end
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
            describe ScenarioDefinition, "#never" do
         
     | 
| 
      
 78 
     | 
    
         
            +
              it_should_behave_like "RR::ScenarioDefinition"
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
              it "returns ScenarioDefinition" do
         
     | 
| 
      
 81 
     | 
    
         
            +
                @definition.never.should === @definition
         
     | 
| 
      
 82 
     | 
    
         
            +
              end
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
              it "sets up a Times Called Expectation with 0" do
         
     | 
| 
      
 85 
     | 
    
         
            +
                @definition.with_any_args
         
     | 
| 
      
 86 
     | 
    
         
            +
                @definition.never
         
     | 
| 
      
 87 
     | 
    
         
            +
                proc {@object.foobar}.should raise_error(Errors::TimesCalledError)
         
     | 
| 
      
 88 
     | 
    
         
            +
              end
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
              it "sets return value when block passed in" do
         
     | 
| 
      
 91 
     | 
    
         
            +
                @definition.with_any_args.never
         
     | 
| 
      
 92 
     | 
    
         
            +
                proc {@object.foobar}.should raise_error(Errors::TimesCalledError)
         
     | 
| 
      
 93 
     | 
    
         
            +
              end
         
     | 
| 
      
 94 
     | 
    
         
            +
            end
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
            describe ScenarioDefinition, "#once" do
         
     | 
| 
      
 97 
     | 
    
         
            +
              it_should_behave_like "RR::ScenarioDefinition"
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
              it "returns ScenarioDefinition" do
         
     | 
| 
      
 100 
     | 
    
         
            +
                @definition.once.should === @definition
         
     | 
| 
      
 101 
     | 
    
         
            +
              end
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
              it "sets up a Times Called Expectation with 1" do
         
     | 
| 
      
 104 
     | 
    
         
            +
                @definition.once.with_any_args
         
     | 
| 
      
 105 
     | 
    
         
            +
                @object.foobar
         
     | 
| 
      
 106 
     | 
    
         
            +
                proc {@object.foobar}.should raise_error(Errors::TimesCalledError)
         
     | 
| 
      
 107 
     | 
    
         
            +
              end
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
              it "sets return value when block passed in" do
         
     | 
| 
      
 110 
     | 
    
         
            +
                @definition.with_any_args.once {:return_value}
         
     | 
| 
      
 111 
     | 
    
         
            +
                @object.foobar.should == :return_value
         
     | 
| 
      
 112 
     | 
    
         
            +
              end
         
     | 
| 
      
 113 
     | 
    
         
            +
            end
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
            describe ScenarioDefinition, "#twice" do
         
     | 
| 
      
 116 
     | 
    
         
            +
              it_should_behave_like "RR::ScenarioDefinition"
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
              it "returns ScenarioDefinition" do
         
     | 
| 
      
 119 
     | 
    
         
            +
                @definition.twice.should === @definition
         
     | 
| 
      
 120 
     | 
    
         
            +
              end
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
              it "sets up a Times Called Expectation with 2" do
         
     | 
| 
      
 123 
     | 
    
         
            +
                @definition.twice.with_any_args
         
     | 
| 
      
 124 
     | 
    
         
            +
                @object.foobar
         
     | 
| 
      
 125 
     | 
    
         
            +
                @object.foobar
         
     | 
| 
      
 126 
     | 
    
         
            +
                proc {@object.foobar}.should raise_error(Errors::TimesCalledError)
         
     | 
| 
      
 127 
     | 
    
         
            +
              end
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
              it "sets return value when block passed in" do
         
     | 
| 
      
 130 
     | 
    
         
            +
                @definition.with_any_args.twice {:return_value}
         
     | 
| 
      
 131 
     | 
    
         
            +
                @object.foobar.should == :return_value
         
     | 
| 
      
 132 
     | 
    
         
            +
              end
         
     | 
| 
      
 133 
     | 
    
         
            +
            end
         
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
      
 135 
     | 
    
         
            +
            describe ScenarioDefinition, "#at_least" do
         
     | 
| 
      
 136 
     | 
    
         
            +
              it_should_behave_like "RR::ScenarioDefinition"
         
     | 
| 
      
 137 
     | 
    
         
            +
             
     | 
| 
      
 138 
     | 
    
         
            +
              it "returns ScenarioDefinition" do
         
     | 
| 
      
 139 
     | 
    
         
            +
                @definition.with_any_args.at_least(2).should === @definition
         
     | 
| 
      
 140 
     | 
    
         
            +
              end
         
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
      
 142 
     | 
    
         
            +
              it "sets up a Times Called Expectation with 1" do
         
     | 
| 
      
 143 
     | 
    
         
            +
                @definition.at_least(2)
         
     | 
| 
      
 144 
     | 
    
         
            +
                @definition.times_matcher.should == TimesCalledMatchers::AtLeastMatcher.new(2)
         
     | 
| 
      
 145 
     | 
    
         
            +
              end
         
     | 
| 
      
 146 
     | 
    
         
            +
             
     | 
| 
      
 147 
     | 
    
         
            +
              it "sets return value when block passed in" do
         
     | 
| 
      
 148 
     | 
    
         
            +
                @definition.with_any_args.at_least(2) {:return_value}
         
     | 
| 
      
 149 
     | 
    
         
            +
                @object.foobar.should == :return_value
         
     | 
| 
      
 150 
     | 
    
         
            +
              end
         
     | 
| 
      
 151 
     | 
    
         
            +
            end
         
     | 
| 
      
 152 
     | 
    
         
            +
             
     | 
| 
      
 153 
     | 
    
         
            +
            describe ScenarioDefinition, "#at_most" do
         
     | 
| 
      
 154 
     | 
    
         
            +
              it_should_behave_like "RR::ScenarioDefinition"
         
     | 
| 
      
 155 
     | 
    
         
            +
             
     | 
| 
      
 156 
     | 
    
         
            +
              it "returns ScenarioDefinition" do
         
     | 
| 
      
 157 
     | 
    
         
            +
                @definition.with_any_args.at_most(2).should === @definition
         
     | 
| 
      
 158 
     | 
    
         
            +
              end
         
     | 
| 
      
 159 
     | 
    
         
            +
             
     | 
| 
      
 160 
     | 
    
         
            +
              it "sets up a Times Called Expectation with 1" do
         
     | 
| 
      
 161 
     | 
    
         
            +
                @definition.at_most(2).with_any_args
         
     | 
| 
      
 162 
     | 
    
         
            +
                @object.foobar
         
     | 
| 
      
 163 
     | 
    
         
            +
                @object.foobar
         
     | 
| 
      
 164 
     | 
    
         
            +
                proc do
         
     | 
| 
      
 165 
     | 
    
         
            +
                  @object.foobar
         
     | 
| 
      
 166 
     | 
    
         
            +
                end.should raise_error(
         
     | 
| 
      
 167 
     | 
    
         
            +
                  Errors::TimesCalledError,
         
     | 
| 
      
 168 
     | 
    
         
            +
                  "Called 3 times.\nExpected at most 2 times."
         
     | 
| 
      
 169 
     | 
    
         
            +
                )
         
     | 
| 
      
 170 
     | 
    
         
            +
              end
         
     | 
| 
      
 171 
     | 
    
         
            +
             
     | 
| 
      
 172 
     | 
    
         
            +
              it "sets return value when block passed in" do
         
     | 
| 
      
 173 
     | 
    
         
            +
                @definition.with_any_args.at_most(2) {:return_value}
         
     | 
| 
      
 174 
     | 
    
         
            +
                @object.foobar.should == :return_value
         
     | 
| 
      
 175 
     | 
    
         
            +
              end
         
     | 
| 
      
 176 
     | 
    
         
            +
            end
         
     | 
| 
      
 177 
     | 
    
         
            +
             
     | 
| 
      
 178 
     | 
    
         
            +
            describe ScenarioDefinition, "#times" do
         
     | 
| 
      
 179 
     | 
    
         
            +
              it_should_behave_like "RR::ScenarioDefinition"
         
     | 
| 
      
 180 
     | 
    
         
            +
             
     | 
| 
      
 181 
     | 
    
         
            +
              it "returns ScenarioDefinition" do
         
     | 
| 
      
 182 
     | 
    
         
            +
                @definition.times(3).should === @definition
         
     | 
| 
      
 183 
     | 
    
         
            +
              end
         
     | 
| 
      
 184 
     | 
    
         
            +
             
     | 
| 
      
 185 
     | 
    
         
            +
              it "sets up a Times Called Expectation with passed in times" do
         
     | 
| 
      
 186 
     | 
    
         
            +
                @definition.times(3).with_any_args
         
     | 
| 
      
 187 
     | 
    
         
            +
                @object.foobar
         
     | 
| 
      
 188 
     | 
    
         
            +
                @object.foobar
         
     | 
| 
      
 189 
     | 
    
         
            +
                @object.foobar
         
     | 
| 
      
 190 
     | 
    
         
            +
                proc {@object.foobar}.should raise_error(Errors::TimesCalledError)
         
     | 
| 
      
 191 
     | 
    
         
            +
              end
         
     | 
| 
      
 192 
     | 
    
         
            +
             
     | 
| 
      
 193 
     | 
    
         
            +
              it "sets return value when block passed in" do
         
     | 
| 
      
 194 
     | 
    
         
            +
                @definition.with_any_args.times(3) {:return_value}
         
     | 
| 
      
 195 
     | 
    
         
            +
                @object.foobar.should == :return_value
         
     | 
| 
      
 196 
     | 
    
         
            +
              end
         
     | 
| 
      
 197 
     | 
    
         
            +
            end
         
     | 
| 
      
 198 
     | 
    
         
            +
             
     | 
| 
      
 199 
     | 
    
         
            +
            describe ScenarioDefinition, "#any_number_of_times" do
         
     | 
| 
      
 200 
     | 
    
         
            +
              it_should_behave_like "RR::ScenarioDefinition"
         
     | 
| 
      
 201 
     | 
    
         
            +
             
     | 
| 
      
 202 
     | 
    
         
            +
              it "returns ScenarioDefinition" do
         
     | 
| 
      
 203 
     | 
    
         
            +
                @definition.any_number_of_times.should === @definition
         
     | 
| 
      
 204 
     | 
    
         
            +
              end
         
     | 
| 
      
 205 
     | 
    
         
            +
             
     | 
| 
      
 206 
     | 
    
         
            +
              it "sets up a Times Called Expectation with AnyTimes matcher" do
         
     | 
| 
      
 207 
     | 
    
         
            +
                @definition.any_number_of_times
         
     | 
| 
      
 208 
     | 
    
         
            +
                @definition.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
         
     | 
| 
      
 209 
     | 
    
         
            +
              end
         
     | 
| 
      
 210 
     | 
    
         
            +
             
     | 
| 
      
 211 
     | 
    
         
            +
              it "sets return value when block passed in" do
         
     | 
| 
      
 212 
     | 
    
         
            +
                @definition.with_any_args.any_number_of_times {:return_value}
         
     | 
| 
      
 213 
     | 
    
         
            +
                @object.foobar.should == :return_value
         
     | 
| 
      
 214 
     | 
    
         
            +
              end
         
     | 
| 
      
 215 
     | 
    
         
            +
            end
         
     | 
| 
      
 216 
     | 
    
         
            +
             
     | 
| 
      
 217 
     | 
    
         
            +
            describe ScenarioDefinition, "#ordered" do
         
     | 
| 
      
 218 
     | 
    
         
            +
              it_should_behave_like "RR::ScenarioDefinition"
         
     | 
| 
      
 219 
     | 
    
         
            +
             
     | 
| 
      
 220 
     | 
    
         
            +
              it "adds itself to the ordered scenarios list" do
         
     | 
| 
      
 221 
     | 
    
         
            +
                @definition.ordered
         
     | 
| 
      
 222 
     | 
    
         
            +
                @space.ordered_scenarios.should include(@scenario)
         
     | 
| 
      
 223 
     | 
    
         
            +
              end
         
     | 
| 
      
 224 
     | 
    
         
            +
             
     | 
| 
      
 225 
     | 
    
         
            +
              it "does not double add itself" do
         
     | 
| 
      
 226 
     | 
    
         
            +
                @definition.ordered
         
     | 
| 
      
 227 
     | 
    
         
            +
                @definition.ordered
         
     | 
| 
      
 228 
     | 
    
         
            +
                @space.ordered_scenarios.should == [@scenario]
         
     | 
| 
      
 229 
     | 
    
         
            +
              end
         
     | 
| 
      
 230 
     | 
    
         
            +
             
     | 
| 
      
 231 
     | 
    
         
            +
              it "sets ordered? to true" do
         
     | 
| 
      
 232 
     | 
    
         
            +
                @definition.ordered
         
     | 
| 
      
 233 
     | 
    
         
            +
                @definition.should be_ordered
         
     | 
| 
      
 234 
     | 
    
         
            +
              end
         
     | 
| 
      
 235 
     | 
    
         
            +
             
     | 
| 
      
 236 
     | 
    
         
            +
              it "sets return value when block passed in" do
         
     | 
| 
      
 237 
     | 
    
         
            +
                @definition.with_any_args.once.ordered {:return_value}
         
     | 
| 
      
 238 
     | 
    
         
            +
                @object.foobar.should == :return_value
         
     | 
| 
      
 239 
     | 
    
         
            +
              end
         
     | 
| 
      
 240 
     | 
    
         
            +
             
     | 
| 
      
 241 
     | 
    
         
            +
              it "raises error when there is no Scenario" do
         
     | 
| 
      
 242 
     | 
    
         
            +
                @definition.scenario = nil
         
     | 
| 
      
 243 
     | 
    
         
            +
                proc do
         
     | 
| 
      
 244 
     | 
    
         
            +
                  @definition.ordered
         
     | 
| 
      
 245 
     | 
    
         
            +
                end.should raise_error(
         
     | 
| 
      
 246 
     | 
    
         
            +
                  Errors::ScenarioDefinitionError,
         
     | 
| 
      
 247 
     | 
    
         
            +
                  "Scenario Definitions must have a dedicated Scenario to be ordered. " <<
         
     | 
| 
      
 248 
     | 
    
         
            +
                  "For example, using instance_of does not allow ordered to be used. " <<
         
     | 
| 
      
 249 
     | 
    
         
            +
                  "probe the class's #new method instead."
         
     | 
| 
      
 250 
     | 
    
         
            +
                )
         
     | 
| 
      
 251 
     | 
    
         
            +
              end
         
     | 
| 
      
 252 
     | 
    
         
            +
            end
         
     | 
| 
      
 253 
     | 
    
         
            +
             
     | 
| 
      
 254 
     | 
    
         
            +
            describe ScenarioDefinition, "#ordered?" do
         
     | 
| 
      
 255 
     | 
    
         
            +
              it_should_behave_like "RR::ScenarioDefinition"
         
     | 
| 
      
 256 
     | 
    
         
            +
             
     | 
| 
      
 257 
     | 
    
         
            +
              it "defaults to false" do
         
     | 
| 
      
 258 
     | 
    
         
            +
                @definition.should_not be_ordered
         
     | 
| 
      
 259 
     | 
    
         
            +
              end
         
     | 
| 
      
 260 
     | 
    
         
            +
            end
         
     | 
| 
      
 261 
     | 
    
         
            +
             
     | 
| 
      
 262 
     | 
    
         
            +
            describe ScenarioDefinition, "#yields" do
         
     | 
| 
      
 263 
     | 
    
         
            +
              it_should_behave_like "RR::ScenarioDefinition"
         
     | 
| 
      
 264 
     | 
    
         
            +
             
     | 
| 
      
 265 
     | 
    
         
            +
              it "returns ScenarioDefinition" do
         
     | 
| 
      
 266 
     | 
    
         
            +
                @definition.yields(:baz).should === @definition
         
     | 
| 
      
 267 
     | 
    
         
            +
              end
         
     | 
| 
      
 268 
     | 
    
         
            +
             
     | 
| 
      
 269 
     | 
    
         
            +
              it "yields the passed in argument to the call block when there is no returns value set" do
         
     | 
| 
      
 270 
     | 
    
         
            +
                @definition.with_any_args.yields(:baz)
         
     | 
| 
      
 271 
     | 
    
         
            +
                passed_in_block_arg = nil
         
     | 
| 
      
 272 
     | 
    
         
            +
                @object.foobar {|arg| passed_in_block_arg = arg}.should == nil
         
     | 
| 
      
 273 
     | 
    
         
            +
                passed_in_block_arg.should == :baz
         
     | 
| 
      
 274 
     | 
    
         
            +
              end
         
     | 
| 
      
 275 
     | 
    
         
            +
             
     | 
| 
      
 276 
     | 
    
         
            +
              it "yields the passed in argument to the call block when there is a no returns value set" do
         
     | 
| 
      
 277 
     | 
    
         
            +
                @definition.with_any_args.yields(:baz).returns(:return_value)
         
     | 
| 
      
 278 
     | 
    
         
            +
             
     | 
| 
      
 279 
     | 
    
         
            +
                passed_in_block_arg = nil
         
     | 
| 
      
 280 
     | 
    
         
            +
                @object.foobar {|arg| passed_in_block_arg = arg}.should == :return_value
         
     | 
| 
      
 281 
     | 
    
         
            +
                passed_in_block_arg.should == :baz
         
     | 
| 
      
 282 
     | 
    
         
            +
              end
         
     | 
| 
      
 283 
     | 
    
         
            +
             
     | 
| 
      
 284 
     | 
    
         
            +
              it "sets return value when block passed in" do
         
     | 
| 
      
 285 
     | 
    
         
            +
                @definition.with_any_args.yields {:return_value}
         
     | 
| 
      
 286 
     | 
    
         
            +
                @object.foobar {}.should == :return_value
         
     | 
| 
      
 287 
     | 
    
         
            +
              end
         
     | 
| 
      
 288 
     | 
    
         
            +
            end
         
     | 
| 
      
 289 
     | 
    
         
            +
             
     | 
| 
      
 290 
     | 
    
         
            +
            describe ScenarioDefinition, "#after_call" do
         
     | 
| 
      
 291 
     | 
    
         
            +
              it_should_behave_like "RR::ScenarioDefinition"
         
     | 
| 
      
 292 
     | 
    
         
            +
             
     | 
| 
      
 293 
     | 
    
         
            +
              it "returns ScenarioDefinition" do
         
     | 
| 
      
 294 
     | 
    
         
            +
                @definition.after_call {}.should === @definition
         
     | 
| 
      
 295 
     | 
    
         
            +
              end
         
     | 
| 
      
 296 
     | 
    
         
            +
             
     | 
| 
      
 297 
     | 
    
         
            +
              it "sends return value of Scenario implementation to after_call" do
         
     | 
| 
      
 298 
     | 
    
         
            +
                return_value = {}
         
     | 
| 
      
 299 
     | 
    
         
            +
                @definition.with_any_args.returns(return_value).after_call do |value|
         
     | 
| 
      
 300 
     | 
    
         
            +
                  value[:foo] = :bar
         
     | 
| 
      
 301 
     | 
    
         
            +
                  value
         
     | 
| 
      
 302 
     | 
    
         
            +
                end
         
     | 
| 
      
 303 
     | 
    
         
            +
             
     | 
| 
      
 304 
     | 
    
         
            +
                actual_value = @object.foobar
         
     | 
| 
      
 305 
     | 
    
         
            +
                actual_value.should === return_value
         
     | 
| 
      
 306 
     | 
    
         
            +
                actual_value.should == {:foo => :bar}
         
     | 
| 
      
 307 
     | 
    
         
            +
              end
         
     | 
| 
      
 308 
     | 
    
         
            +
             
     | 
| 
      
 309 
     | 
    
         
            +
              it "receives the return value in the after_call callback" do
         
     | 
| 
      
 310 
     | 
    
         
            +
                return_value = :returns_value
         
     | 
| 
      
 311 
     | 
    
         
            +
                @definition.with_any_args.returns(return_value).after_call do |value|
         
     | 
| 
      
 312 
     | 
    
         
            +
                  :after_call_value
         
     | 
| 
      
 313 
     | 
    
         
            +
                end
         
     | 
| 
      
 314 
     | 
    
         
            +
             
     | 
| 
      
 315 
     | 
    
         
            +
                actual_value = @object.foobar
         
     | 
| 
      
 316 
     | 
    
         
            +
                actual_value.should == :after_call_value
         
     | 
| 
      
 317 
     | 
    
         
            +
              end
         
     | 
| 
      
 318 
     | 
    
         
            +
             
     | 
| 
      
 319 
     | 
    
         
            +
              it "allows after_call to mock the return value" do
         
     | 
| 
      
 320 
     | 
    
         
            +
                return_value = Object.new
         
     | 
| 
      
 321 
     | 
    
         
            +
                @definition.with_any_args.returns(return_value).after_call do |value|
         
     | 
| 
      
 322 
     | 
    
         
            +
                  mock(value).inner_method(1) {:baz}
         
     | 
| 
      
 323 
     | 
    
         
            +
                  value
         
     | 
| 
      
 324 
     | 
    
         
            +
                end
         
     | 
| 
      
 325 
     | 
    
         
            +
             
     | 
| 
      
 326 
     | 
    
         
            +
                @object.foobar.inner_method(1).should == :baz
         
     | 
| 
      
 327 
     | 
    
         
            +
              end
         
     | 
| 
      
 328 
     | 
    
         
            +
             
     | 
| 
      
 329 
     | 
    
         
            +
              it "raises an error when not passed a block" do
         
     | 
| 
      
 330 
     | 
    
         
            +
                proc do
         
     | 
| 
      
 331 
     | 
    
         
            +
                  @definition.after_call
         
     | 
| 
      
 332 
     | 
    
         
            +
                end.should raise_error(ArgumentError, "after_call expects a block")
         
     | 
| 
      
 333 
     | 
    
         
            +
              end
         
     | 
| 
      
 334 
     | 
    
         
            +
            end
         
     | 
| 
      
 335 
     | 
    
         
            +
             
     | 
| 
      
 336 
     | 
    
         
            +
            describe ScenarioDefinition, "#returns" do
         
     | 
| 
      
 337 
     | 
    
         
            +
              it_should_behave_like "RR::ScenarioDefinition"
         
     | 
| 
      
 338 
     | 
    
         
            +
             
     | 
| 
      
 339 
     | 
    
         
            +
              it "returns ScenarioDefinition" do
         
     | 
| 
      
 340 
     | 
    
         
            +
                @definition.returns {:baz}.should === @definition
         
     | 
| 
      
 341 
     | 
    
         
            +
                @definition.returns(:baz).should === @definition
         
     | 
| 
      
 342 
     | 
    
         
            +
              end
         
     | 
| 
      
 343 
     | 
    
         
            +
             
     | 
| 
      
 344 
     | 
    
         
            +
              it "sets the value of the method when passed a block" do
         
     | 
| 
      
 345 
     | 
    
         
            +
                @definition.with_any_args.returns {:baz}
         
     | 
| 
      
 346 
     | 
    
         
            +
                @object.foobar.should == :baz
         
     | 
| 
      
 347 
     | 
    
         
            +
              end
         
     | 
| 
      
 348 
     | 
    
         
            +
             
     | 
| 
      
 349 
     | 
    
         
            +
              it "sets the value of the method when passed an argument" do
         
     | 
| 
      
 350 
     | 
    
         
            +
                @definition.returns(:baz).with_no_args
         
     | 
| 
      
 351 
     | 
    
         
            +
                @object.foobar.should == :baz
         
     | 
| 
      
 352 
     | 
    
         
            +
              end
         
     | 
| 
      
 353 
     | 
    
         
            +
             
     | 
| 
      
 354 
     | 
    
         
            +
              it "returns false when passed false" do
         
     | 
| 
      
 355 
     | 
    
         
            +
                @definition.returns(false).with_any_args
         
     | 
| 
      
 356 
     | 
    
         
            +
                @object.foobar.should == false
         
     | 
| 
      
 357 
     | 
    
         
            +
              end
         
     | 
| 
      
 358 
     | 
    
         
            +
             
     | 
| 
      
 359 
     | 
    
         
            +
              it "raises an error when both argument and block is passed in" do
         
     | 
| 
      
 360 
     | 
    
         
            +
                proc do
         
     | 
| 
      
 361 
     | 
    
         
            +
                  @definition.returns(:baz) {:another}
         
     | 
| 
      
 362 
     | 
    
         
            +
                end.should raise_error(ArgumentError, "returns cannot accept both an argument and a block")
         
     | 
| 
      
 363 
     | 
    
         
            +
              end
         
     | 
| 
      
 364 
     | 
    
         
            +
            end
         
     | 
| 
      
 365 
     | 
    
         
            +
             
     | 
| 
      
 366 
     | 
    
         
            +
            describe ScenarioDefinition, "#implemented_by" do
         
     | 
| 
      
 367 
     | 
    
         
            +
              it_should_behave_like "RR::ScenarioDefinition"
         
     | 
| 
      
 368 
     | 
    
         
            +
             
     | 
| 
      
 369 
     | 
    
         
            +
              it "returns the ScenarioDefinition" do
         
     | 
| 
      
 370 
     | 
    
         
            +
                @definition.implemented_by(proc{:baz}).should === @definition
         
     | 
| 
      
 371 
     | 
    
         
            +
              end
         
     | 
| 
      
 372 
     | 
    
         
            +
             
     | 
| 
      
 373 
     | 
    
         
            +
              it "sets the implementation to the passed in proc" do
         
     | 
| 
      
 374 
     | 
    
         
            +
                @definition.implemented_by(proc{:baz}).with_no_args
         
     | 
| 
      
 375 
     | 
    
         
            +
                @object.foobar.should == :baz
         
     | 
| 
      
 376 
     | 
    
         
            +
              end
         
     | 
| 
      
 377 
     | 
    
         
            +
             
     | 
| 
      
 378 
     | 
    
         
            +
              it "sets the implementation to the passed in method" do
         
     | 
| 
      
 379 
     | 
    
         
            +
                def @object.foobar(a, b)
         
     | 
| 
      
 380 
     | 
    
         
            +
                  [b, a]
         
     | 
| 
      
 381 
     | 
    
         
            +
                end
         
     | 
| 
      
 382 
     | 
    
         
            +
                @definition.implemented_by(@object.method(:foobar))
         
     | 
| 
      
 383 
     | 
    
         
            +
                @object.foobar(1, 2).should == [2, 1]
         
     | 
| 
      
 384 
     | 
    
         
            +
              end
         
     | 
| 
      
 385 
     | 
    
         
            +
            end
         
     | 
| 
      
 386 
     | 
    
         
            +
             
     | 
| 
      
 387 
     | 
    
         
            +
            describe ScenarioDefinition, "#implemented_by_original_method" do
         
     | 
| 
      
 388 
     | 
    
         
            +
              it_should_behave_like "RR::ScenarioDefinition"
         
     | 
| 
      
 389 
     | 
    
         
            +
             
     | 
| 
      
 390 
     | 
    
         
            +
              it "returns the ScenarioDefinition object" do
         
     | 
| 
      
 391 
     | 
    
         
            +
                @definition.implemented_by_original_method.should === @definition
         
     | 
| 
      
 392 
     | 
    
         
            +
              end
         
     | 
| 
      
 393 
     | 
    
         
            +
             
     | 
| 
      
 394 
     | 
    
         
            +
              it "sets the implementation to the original method" do
         
     | 
| 
      
 395 
     | 
    
         
            +
                @definition.implemented_by_original_method.with_any_args
         
     | 
| 
      
 396 
     | 
    
         
            +
                @object.foobar(1, 2).should == [2, 1]
         
     | 
| 
      
 397 
     | 
    
         
            +
              end
         
     | 
| 
      
 398 
     | 
    
         
            +
             
     | 
| 
      
 399 
     | 
    
         
            +
              it "calls method_missing when original_method does not exist" do
         
     | 
| 
      
 400 
     | 
    
         
            +
                class << @object
         
     | 
| 
      
 401 
     | 
    
         
            +
                  def method_missing(method_name, *args, &block)
         
     | 
| 
      
 402 
     | 
    
         
            +
                    "method_missing for #{method_name}(#{args.inspect})"
         
     | 
| 
      
 403 
     | 
    
         
            +
                  end
         
     | 
| 
      
 404 
     | 
    
         
            +
                end
         
     | 
| 
      
 405 
     | 
    
         
            +
                double = @space.double(@object, :does_not_exist)
         
     | 
| 
      
 406 
     | 
    
         
            +
                scenario = @space.scenario(double)
         
     | 
| 
      
 407 
     | 
    
         
            +
                scenario.with_any_args
         
     | 
| 
      
 408 
     | 
    
         
            +
                scenario.implemented_by_original_method
         
     | 
| 
      
 409 
     | 
    
         
            +
             
     | 
| 
      
 410 
     | 
    
         
            +
                return_value = @object.does_not_exist(1, 2)
         
     | 
| 
      
 411 
     | 
    
         
            +
                return_value.should == "method_missing for does_not_exist([1, 2])"
         
     | 
| 
      
 412 
     | 
    
         
            +
              end
         
     | 
| 
      
 413 
     | 
    
         
            +
            end
         
     | 
| 
      
 414 
     | 
    
         
            +
             
     | 
| 
      
 415 
     | 
    
         
            +
            describe ScenarioDefinition, "#exact_match?" do
         
     | 
| 
      
 416 
     | 
    
         
            +
              it_should_behave_like "RR::ScenarioDefinition"
         
     | 
| 
      
 417 
     | 
    
         
            +
             
     | 
| 
      
 418 
     | 
    
         
            +
              it "returns false when no expectation set" do
         
     | 
| 
      
 419 
     | 
    
         
            +
                @definition.should_not be_exact_match()
         
     | 
| 
      
 420 
     | 
    
         
            +
                @definition.should_not be_exact_match(nil)
         
     | 
| 
      
 421 
     | 
    
         
            +
                @definition.should_not be_exact_match(Object.new)
         
     | 
| 
      
 422 
     | 
    
         
            +
                @definition.should_not be_exact_match(1, 2, 3)
         
     | 
| 
      
 423 
     | 
    
         
            +
              end
         
     | 
| 
      
 424 
     | 
    
         
            +
             
     | 
| 
      
 425 
     | 
    
         
            +
              it "returns false when arguments are not an exact match" do
         
     | 
| 
      
 426 
     | 
    
         
            +
                @definition.with(1, 2, 3)
         
     | 
| 
      
 427 
     | 
    
         
            +
                @definition.should_not be_exact_match(1, 2)
         
     | 
| 
      
 428 
     | 
    
         
            +
                @definition.should_not be_exact_match(1)
         
     | 
| 
      
 429 
     | 
    
         
            +
                @definition.should_not be_exact_match()
         
     | 
| 
      
 430 
     | 
    
         
            +
                @definition.should_not be_exact_match("does not match")
         
     | 
| 
      
 431 
     | 
    
         
            +
              end
         
     | 
| 
      
 432 
     | 
    
         
            +
             
     | 
| 
      
 433 
     | 
    
         
            +
              it "returns true when arguments are an exact match" do
         
     | 
| 
      
 434 
     | 
    
         
            +
                @definition.with(1, 2, 3)
         
     | 
| 
      
 435 
     | 
    
         
            +
                @definition.should be_exact_match(1, 2, 3)
         
     | 
| 
      
 436 
     | 
    
         
            +
              end
         
     | 
| 
      
 437 
     | 
    
         
            +
            end
         
     | 
| 
      
 438 
     | 
    
         
            +
             
     | 
| 
      
 439 
     | 
    
         
            +
            describe ScenarioDefinition, "#wildcard_match?" do
         
     | 
| 
      
 440 
     | 
    
         
            +
              it_should_behave_like "RR::ScenarioDefinition"
         
     | 
| 
      
 441 
     | 
    
         
            +
             
     | 
| 
      
 442 
     | 
    
         
            +
              it "returns false when no expectation set" do
         
     | 
| 
      
 443 
     | 
    
         
            +
                @definition.should_not be_wildcard_match()
         
     | 
| 
      
 444 
     | 
    
         
            +
                @definition.should_not be_wildcard_match(nil)
         
     | 
| 
      
 445 
     | 
    
         
            +
                @definition.should_not be_wildcard_match(Object.new)
         
     | 
| 
      
 446 
     | 
    
         
            +
                @definition.should_not be_wildcard_match(1, 2, 3)
         
     | 
| 
      
 447 
     | 
    
         
            +
              end
         
     | 
| 
      
 448 
     | 
    
         
            +
             
     | 
| 
      
 449 
     | 
    
         
            +
              it "returns true when arguments are an exact match" do
         
     | 
| 
      
 450 
     | 
    
         
            +
                @definition.with(1, 2, 3)
         
     | 
| 
      
 451 
     | 
    
         
            +
                @definition.should be_wildcard_match(1, 2, 3)
         
     | 
| 
      
 452 
     | 
    
         
            +
                @definition.should_not be_wildcard_match(1, 2)
         
     | 
| 
      
 453 
     | 
    
         
            +
                @definition.should_not be_wildcard_match(1)
         
     | 
| 
      
 454 
     | 
    
         
            +
                @definition.should_not be_wildcard_match()
         
     | 
| 
      
 455 
     | 
    
         
            +
                @definition.should_not be_wildcard_match("does not match")
         
     | 
| 
      
 456 
     | 
    
         
            +
              end
         
     | 
| 
      
 457 
     | 
    
         
            +
             
     | 
| 
      
 458 
     | 
    
         
            +
              it "returns true when with_any_args" do
         
     | 
| 
      
 459 
     | 
    
         
            +
                @definition.with_any_args
         
     | 
| 
      
 460 
     | 
    
         
            +
             
     | 
| 
      
 461 
     | 
    
         
            +
                @definition.should be_wildcard_match(1, 2, 3)
         
     | 
| 
      
 462 
     | 
    
         
            +
                @definition.should be_wildcard_match(1, 2)
         
     | 
| 
      
 463 
     | 
    
         
            +
                @definition.should be_wildcard_match(1)
         
     | 
| 
      
 464 
     | 
    
         
            +
                @definition.should be_wildcard_match()
         
     | 
| 
      
 465 
     | 
    
         
            +
                @definition.should be_wildcard_match("does not match")
         
     | 
| 
      
 466 
     | 
    
         
            +
              end
         
     | 
| 
      
 467 
     | 
    
         
            +
            end
         
     | 
| 
      
 468 
     | 
    
         
            +
             
     | 
| 
      
 469 
     | 
    
         
            +
            describe ScenarioDefinition, "#terminal?" do
         
     | 
| 
      
 470 
     | 
    
         
            +
              it_should_behave_like "RR::ScenarioDefinition"
         
     | 
| 
      
 471 
     | 
    
         
            +
             
     | 
| 
      
 472 
     | 
    
         
            +
              it "returns true when times_matcher's terminal? is true" do
         
     | 
| 
      
 473 
     | 
    
         
            +
                @definition.once
         
     | 
| 
      
 474 
     | 
    
         
            +
                @definition.times_matcher.should be_terminal
         
     | 
| 
      
 475 
     | 
    
         
            +
                @definition.should be_terminal
         
     | 
| 
      
 476 
     | 
    
         
            +
              end
         
     | 
| 
      
 477 
     | 
    
         
            +
             
     | 
| 
      
 478 
     | 
    
         
            +
              it "returns false when times_matcher's terminal? is false" do
         
     | 
| 
      
 479 
     | 
    
         
            +
                @definition.any_number_of_times
         
     | 
| 
      
 480 
     | 
    
         
            +
                @definition.times_matcher.should_not be_terminal
         
     | 
| 
      
 481 
     | 
    
         
            +
                @definition.should_not be_terminal
         
     | 
| 
      
 482 
     | 
    
         
            +
              end
         
     | 
| 
      
 483 
     | 
    
         
            +
             
     | 
| 
      
 484 
     | 
    
         
            +
              it "returns false when there is not times_matcher" do
         
     | 
| 
      
 485 
     | 
    
         
            +
                @definition.times_matcher.should be_nil
         
     | 
| 
      
 486 
     | 
    
         
            +
                @definition.should_not be_terminal
         
     | 
| 
      
 487 
     | 
    
         
            +
              end
         
     | 
| 
      
 488 
     | 
    
         
            +
            end
         
     | 
| 
      
 489 
     | 
    
         
            +
             
     | 
| 
      
 490 
     | 
    
         
            +
            describe ScenarioDefinition, "#expected_arguments" do
         
     | 
| 
      
 491 
     | 
    
         
            +
              it_should_behave_like "RR::ScenarioDefinition"
         
     | 
| 
      
 492 
     | 
    
         
            +
             
     | 
| 
      
 493 
     | 
    
         
            +
              it "returns argument expectation's expected_arguments when there is a argument expectation" do
         
     | 
| 
      
 494 
     | 
    
         
            +
                @definition.with(1, 2)
         
     | 
| 
      
 495 
     | 
    
         
            +
                @definition.expected_arguments.should == [1, 2]
         
     | 
| 
      
 496 
     | 
    
         
            +
              end
         
     | 
| 
      
 497 
     | 
    
         
            +
             
     | 
| 
      
 498 
     | 
    
         
            +
              it "returns an empty array when there is no argument expectation" do
         
     | 
| 
      
 499 
     | 
    
         
            +
                @definition.argument_expectation.should be_nil
         
     | 
| 
      
 500 
     | 
    
         
            +
                @definition.expected_arguments.should == []
         
     | 
| 
      
 501 
     | 
    
         
            +
              end
         
     | 
| 
      
 502 
     | 
    
         
            +
            end
         
     | 
| 
      
 503 
     | 
    
         
            +
            end
         
     |