Permalink
Browse files

Fixed ordering of missed method names

  • Loading branch information...
1 parent 81108f0 commit b48d777bd013127efd1104351c0edfbcedd92693 @kaiwren kaiwren committed Mar 29, 2011
Showing with 8 additions and 8 deletions.
  1. +2 −2 lib/rspec/mocks/any_instance.rb
  2. +6 −6 spec/rspec/mocks/any_instance_spec.rb
@@ -161,7 +161,7 @@ def instance_that_received(method_name)
def verify
if @expectation_set && !each_expectation_fulfilled_at_least_once?
- raise RSpec::Mocks::MockExpectationError, "Exactly one instance should have received the following message(s) but didn't: #{methods_with_uninvoked_expectations.join(', ')}"
+ raise RSpec::Mocks::MockExpectationError, "Exactly one instance should have received the following message(s) but didn't: #{methods_with_uninvoked_expectations.sort.join(', ')}"
end
end
@@ -177,7 +177,7 @@ def has_expectation?(method_name)
end
def methods_with_uninvoked_expectations
- @message_chains.map{|method_name, chain| method_name if chain.is_a?(ExpectationChain) && !chain.expectation_fulfilled_at_least_once? }.compact
+ @message_chains.map{|method_name, chain| method_name.to_s if chain.is_a?(ExpectationChain) && !chain.expectation_fulfilled_at_least_once? }.compact
end
def received_message_for_a_method_with_an_expectation!(method_name)
@@ -152,7 +152,7 @@ class RSpec::SampleRspecTestClass;end
let(:foo_expectation_error_message) { 'Exactly one instance should have received the following message(s) but didn\'t: foo' }
let(:existing_method_expectation_error_message) { 'Exactly one instance should have received the following message(s) but didn\'t: existing_method' }
- context "when an expectation is set on a method does not exist" do
+ context "and an expectation is set on a method which does not exist" do
it "returns the expected value" do
klass.any_instance.should_receive(:foo).and_return(1)
klass.new.foo(1).should eq(1)
@@ -166,7 +166,7 @@ class RSpec::SampleRspecTestClass;end
end.to raise_error(RSpec::Mocks::MockExpectationError, foo_expectation_error_message)
end
- context "number of instances" do
+ context "when dealing with different numbers of instances" do
it "fails if no instance is created" do
expect do
klass.any_instance.should_receive(:foo).and_return(1)
@@ -179,7 +179,7 @@ class RSpec::SampleRspecTestClass;end
klass.any_instance.should_receive(:foo)
klass.any_instance.should_receive(:bar)
klass.rspec_verify
- end.to raise_error(RSpec::Mocks::MockExpectationError, 'Exactly one instance should have received the following message(s) but didn\'t: foo, bar')
+ end.to raise_error(RSpec::Mocks::MockExpectationError, 'Exactly one instance should have received the following message(s) but didn\'t: bar, foo')
end
context "after any one instance has received a message" do
@@ -203,7 +203,7 @@ class RSpec::SampleRspecTestClass;end
end
end
- context "when an expectation is set on a method that exists" do
+ context "and an expectation is set on a method that exists" do
it "returns the expected value" do
klass.any_instance.should_receive(:existing_method).and_return(1)
klass.new.existing_method(1).should eq(1)
@@ -217,7 +217,7 @@ class RSpec::SampleRspecTestClass;end
end.to raise_error(RSpec::Mocks::MockExpectationError, existing_method_expectation_error_message)
end
- context "number of instances" do
+ context "when dealing with different numbers of instances" do
it "fails if no instance is created" do
expect do
klass.any_instance.should_receive(:existing_method)
@@ -230,7 +230,7 @@ class RSpec::SampleRspecTestClass;end
klass.any_instance.should_receive(:existing_method)
klass.any_instance.should_receive(:another_existing_method)
klass.rspec_verify
- end.to raise_error(RSpec::Mocks::MockExpectationError, 'Exactly one instance should have received the following message(s) but didn\'t: existing_method, another_existing_method')
+ end.to raise_error(RSpec::Mocks::MockExpectationError, 'Exactly one instance should have received the following message(s) but didn\'t: another_existing_method, existing_method')
end
context "after any one instance has received a message" do

0 comments on commit b48d777

Please sign in to comment.