Skip to content

Commit

Permalink
clear expectation_ordering rather than creating a new one for each ex…
Browse files Browse the repository at this point in the history
…ample
  • Loading branch information
dchelimsky committed Feb 8, 2012
1 parent 3f94b50 commit c8b9948
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
12 changes: 10 additions & 2 deletions lib/rspec/mocks/order_group.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/rspec/mocks/space.rb
Expand Up @@ -17,7 +17,7 @@ def reset_all
mock.rspec_reset
end
mocks.clear
@expectation_ordering = nil
expectation_ordering.clear
end

def expectation_ordering
Expand Down
3 changes: 1 addition & 2 deletions spec/rspec/mocks/mock_space_spec.rb
Expand Up @@ -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"))
Expand Down

0 comments on commit c8b9948

Please sign in to comment.