Skip to content
Browse files

rename some things in a spec

  • Loading branch information...
1 parent 6732d62 commit d4b983c5f663589b24abb8f9f53872ae357827ff @dchelimsky dchelimsky committed May 4, 2012
Showing with 48 additions and 50 deletions.
  1. +48 −50 spec/rspec/mocks/at_least_spec.rb
View
98 spec/rspec/mocks/at_least_spec.rb
@@ -3,100 +3,98 @@
module RSpec
module Mocks
describe "at_least" do
- before(:each) do
- @mock = RSpec::Mocks::Mock.new("test mock")
- end
+ before(:each) { @double = double }
it "fails if method is never called" do
- @mock.should_receive(:random_call).at_least(4).times
- lambda do
- @mock.rspec_verify
+ @double.should_receive(:do_something).at_least(4).times
+ lambda do
+ @double.rspec_verify
end.should raise_error(RSpec::Mocks::MockExpectationError)
end
it "fails when called less than n times" do
- @mock.should_receive(:random_call).at_least(4).times
- @mock.random_call
- @mock.random_call
- @mock.random_call
+ @double.should_receive(:do_something).at_least(4).times
+ @double.do_something
+ @double.do_something
+ @double.do_something
lambda do
- @mock.rspec_verify
+ @double.rspec_verify
end.should raise_error(RSpec::Mocks::MockExpectationError)
end
it "fails when at least once method is never called" do
- @mock.should_receive(:random_call).at_least(:once)
+ @double.should_receive(:do_something).at_least(:once)
lambda do
- @mock.rspec_verify
+ @double.rspec_verify
end.should raise_error(RSpec::Mocks::MockExpectationError)
end
it "fails when at least twice method is called once" do
- @mock.should_receive(:random_call).at_least(:twice)
- @mock.random_call
+ @double.should_receive(:do_something).at_least(:twice)
+ @double.do_something
lambda do
- @mock.rspec_verify
+ @double.rspec_verify
end.should raise_error(RSpec::Mocks::MockExpectationError)
end
it "fails when at least twice method is never called" do
- @mock.should_receive(:random_call).at_least(:twice)
+ @double.should_receive(:do_something).at_least(:twice)
lambda do
- @mock.rspec_verify
+ @double.rspec_verify
end.should raise_error(RSpec::Mocks::MockExpectationError)
end
it "passes when at least n times method is called exactly n times" do
- @mock.should_receive(:random_call).at_least(4).times
- @mock.random_call
- @mock.random_call
- @mock.random_call
- @mock.random_call
- @mock.rspec_verify
+ @double.should_receive(:do_something).at_least(4).times
+ @double.do_something
+ @double.do_something
+ @double.do_something
+ @double.do_something
+ @double.rspec_verify
end
it "passes when at least n times method is called n plus 1 times" do
- @mock.should_receive(:random_call).at_least(4).times
- @mock.random_call
- @mock.random_call
- @mock.random_call
- @mock.random_call
- @mock.random_call
- @mock.rspec_verify
+ @double.should_receive(:do_something).at_least(4).times
+ @double.do_something
+ @double.do_something
+ @double.do_something
+ @double.do_something
+ @double.do_something
+ @double.rspec_verify
end
it "passes when at least once method is called once" do
- @mock.should_receive(:random_call).at_least(:once)
- @mock.random_call
- @mock.rspec_verify
+ @double.should_receive(:do_something).at_least(:once)
+ @double.do_something
+ @double.rspec_verify
end
it "passes when at least once method is called twice" do
- @mock.should_receive(:random_call).at_least(:once)
- @mock.random_call
- @mock.random_call
- @mock.rspec_verify
+ @double.should_receive(:do_something).at_least(:once)
+ @double.do_something
+ @double.do_something
+ @double.rspec_verify
end
it "passes when at least twice method is called three times" do
- @mock.should_receive(:random_call).at_least(:twice)
- @mock.random_call
- @mock.random_call
- @mock.random_call
- @mock.rspec_verify
+ @double.should_receive(:do_something).at_least(:twice)
+ @double.do_something
+ @double.do_something
+ @double.do_something
+ @double.rspec_verify
end
it "passes when at least twice method is called twice" do
- @mock.should_receive(:random_call).at_least(:twice)
- @mock.random_call
- @mock.random_call
- @mock.rspec_verify
+ @double.should_receive(:do_something).at_least(:twice)
+ @double.do_something
+ @double.do_something
+ @double.rspec_verify
end
it "returns the value given by a block when the at least once method is called" do
- @mock.should_receive(:to_s).at_least(:once) { "testing" }
- @mock.to_s.should eq "testing"
- @mock.rspec_verify
+ @double.should_receive(:to_s).at_least(:once) { "testing" }
+ @double.to_s.should eq "testing"
+ @double.rspec_verify
end
end
end

0 comments on commit d4b983c

Please sign in to comment.
Something went wrong with that request. Please try again.