Skip to content

Commit

Permalink
Added specs for expectations
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiwren committed Oct 15, 2011
1 parent 74c5df8 commit b27da00
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/rspec/mocks/any_instance_spec.rb
Expand Up @@ -698,6 +698,26 @@ class RSpec::SampleRspecTestClass;end
end

context "with expectations" do
context "private methods" do
before :each do
klass.any_instance.should_receive(:private_method).and_return(:something)
klass.new.private_method
space.verify_all
end

it "cleans up the backed up method" do
klass.method_defined?(:__existing_method_without_any_instance__).should be_false
end

it "restores a stubbed private method after the spec is run" do
klass.private_method_defined?(:private_method).should be_true
end

it "ensures that the restored method behaves as it originally did" do
klass.new.send(:private_method).should eq(:private_method_return_value)
end
end

context "ensures that the subsequent specs do not see expectations set in previous specs" do
context "when the instance created after the expectation is set" do
it "first spec" do
Expand Down

0 comments on commit b27da00

Please sign in to comment.