Permalink
Browse files

Ensure shared example groups are reset after a run (as example groups…

… are).
  • Loading branch information...
1 parent b94ec20 commit 8e8fb2b3af4422327e676d4e1c344268357f3536 @justinko justinko committed Jan 25, 2012
Showing with 9 additions and 8 deletions.
  1. +1 −0 Changelog.md
  2. +7 −7 lib/rspec/core/world.rb
  3. +1 −1 spec/rspec/core/world_spec.rb
View
@@ -5,6 +5,7 @@ Bug fixes
* Restore `--full_backtrace` option
* Ensure that values passed to `config.filter_run` are respected when running
over DRb (using spork).
+* Ensure shared example groups are reset after a run (as example groups are).
### 2.8.0 / 2012-01-04
View
@@ -4,12 +4,13 @@ class World
include RSpec::Core::Hooks
- attr_reader :example_groups, :filtered_examples, :wants_to_quit
- attr_writer :wants_to_quit
+ attr_reader :example_groups, :shared_example_groups, :filtered_examples
+ attr_accessor :wants_to_quit
def initialize(configuration=RSpec.configuration)
@configuration = configuration
@example_groups = [].extend(Extensions::Ordered)
+ @shared_example_groups = {}
@filtered_examples = Hash.new { |hash,group|
hash[group] = begin
examples = group.examples.dup
@@ -22,6 +23,7 @@ def initialize(configuration=RSpec.configuration)
def reset
example_groups.clear
+ shared_example_groups.clear
end
def filter_manager
@@ -45,12 +47,10 @@ def configure_group(group)
@configuration.configure_group(group)
end
- def shared_example_groups
- @shared_example_groups ||= {}
- end
-
def example_count
- example_groups.collect {|g| g.descendants}.flatten.inject(0) { |sum, g| sum += g.filtered_examples.size }
+ example_groups.collect {|g| g.descendants}.flatten.inject(0) do |sum, g|
+ sum += g.filtered_examples.size
+ end
end
def preceding_declaration_line(filter_line)
@@ -64,7 +64,7 @@ module RSpec::Core
context "with two exaples and the second example is registre first" do
let(:second_group_declaration_line) { second_group.metadata[:example_group][:line_number] }
- before do
+ before do
world.register(second_group)
world.register(group)
end

0 comments on commit 8e8fb2b

Please sign in to comment.