Permalink
Browse files

clear expectation_ordering rather than creating a new one for each ex…

…ample
  • Loading branch information...
1 parent 3f94b50 commit c8b9948417605f6f416288dd3457c7995d340532 @dchelimsky dchelimsky committed Feb 8, 2012
Showing with 12 additions and 5 deletions.
  1. +10 −2 lib/rspec/mocks/order_group.rb
  2. +1 −1 lib/rspec/mocks/space.rb
  3. +1 −2 spec/rspec/mocks/mock_space_spec.rb
@@ -22,11 +22,19 @@ def consume
end
# @private
- def handle_order_constraint expectation
- return unless @ordering.include? expectation
+ def handle_order_constraint(expectation)
+ return unless @ordering.include?(expectation)
return consume if ready_for?(expectation)
expectation.raise_out_of_order_error
end
+
+ def clear
+ @ordering.clear
+ end
+
+ def empty?
+ @ordering.empty?
+ end
end
end
end
View
@@ -17,7 +17,7 @@ def reset_all
mock.rspec_reset
end
mocks.clear
- @expectation_ordering = nil
+ expectation_ordering.clear
end
def expectation_ordering
@@ -43,9 +43,8 @@ def reset?
@space.instance_eval { mocks.empty? }.should be_true
end
it "resets the ordering" do
- OrderGroup.should_receive(:new)
@space.reset_all
- @space.expectation_ordering
+ @space.expectation_ordering.should be_empty
end
it "only adds an instance once" do
@space.add(m1 = double("mock1"))

0 comments on commit c8b9948

Please sign in to comment.