Skip to content

Commit

Permalink
Ensure shared example groups are reset after a run (as example groups…
Browse files Browse the repository at this point in the history
… are).
  • Loading branch information
justinko committed Jan 25, 2012
1 parent b94ec20 commit 8e8fb2b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 7 additions & 7 deletions lib/rspec/core/world.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -22,6 +23,7 @@ def initialize(configuration=RSpec.configuration)

def reset
example_groups.clear
shared_example_groups.clear
end

def filter_manager
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/core/world_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8e8fb2b

Please sign in to comment.