Permalink
Browse files

Spec for RSpec::Core::World#reset

  • Loading branch information...
1 parent 04d77ec commit 5c73b8cfb3ea4e6a52431b2410ff1945692c9b33 @justinko justinko committed Jan 30, 2012
Showing with 15 additions and 0 deletions.
  1. +15 −0 spec/rspec/core/world_spec.rb
@@ -9,6 +9,21 @@ module RSpec::Core
let(:configuration) { RSpec::Core::Configuration.new }
let(:world) { RSpec::Core::World.new(configuration) }
+ describe '#reset' do
+ before do
+ world.example_groups << :example_group
+ world.shared_example_groups[:shared] = :example_group
+ end
+
+ it 'clears #example_groups and #shared_example_groups' do
+ world.example_groups.should_not be_empty
+ world.shared_example_groups.should_not be_empty
+ world.reset
+ world.example_groups.should be_empty
+ world.shared_example_groups.should be_empty
+ end
+ end
+
describe "#example_groups" do
it "contains all registered example groups" do
group = RSpec::Core::ExampleGroup.describe("group"){}

2 comments on commit 5c73b8c

Contributor

justinko replied Jan 30, 2012

@dchelimsky the behavior of this method is to "empty" out the example groups and shared example groups. Now, would you typically set an expectation that .clear is passed to example_groups and shared_example_groups? I ask because what I just committed is basically verifying that Ruby's clear method works...which seems unnecessary. It's always kind of tough to decide if you should mock if the implementation code is so trivial.

Owner

dchelimsky replied Jan 30, 2012

I wouldn't mock here either, but I would also omit the before and the first two lines of the example: 8ecae7d

Please sign in to comment.