Skip to content

Commit

Permalink
clean up some specs
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed Jan 30, 2012
1 parent 1f28dcd commit 5897343
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions spec/rspec/mocks/mock_spec.rb
Expand Up @@ -187,28 +187,18 @@ def @mock.method_with_default_argument(arg={}); end

it "fails right away when method defined as never is received" do
@mock.should_receive(:not_expected).never
expect { @mock.not_expected }.to raise_error(
RSpec::Mocks::MockExpectationError,
%Q|(Double "test double").not_expected(no args)\n expected: 0 times\n received: 1 time|
)
end

it "eventually fails when method defined as never is received" do
@mock.should_receive(:not_expected).never
expect { @mock.not_expected }.to raise_error(
RSpec::Mocks::MockExpectationError,
%Q|(Double "test double").not_expected(no args)\n expected: 0 times\n received: 1 time|
expect { @mock.not_expected }.
to raise_error(RSpec::Mocks::MockExpectationError,
%Q|(Double "test double").not_expected(no args)\n expected: 0 times\n received: 1 time|
)
end

it "raises when told to" do
@mock.should_receive(:something).and_raise(RuntimeError)
lambda do
@mock.something
end.should raise_error(RuntimeError)
expect { @mock.something }.to raise_error(RuntimeError)
end

it "raises passed an Exception instance" do
it "raises instance of submitted Exception" do
error = RuntimeError.new("error message")
@mock.should_receive(:something).and_raise(error)
lambda {
Expand All @@ -228,7 +218,7 @@ def initialize(i_take_an_argument)
}.should raise_error(ArgumentError, /^'and_raise' can only accept an Exception class if an instance/)
end

it "raises RuntimeError with passed message" do
it "raises RuntimeError with submitted message" do
@mock.should_receive(:something).and_raise("error message")
lambda {
@mock.something
Expand Down

0 comments on commit 5897343

Please sign in to comment.