Skip to content

Commit

Permalink
Clear formatters rather than creating new array object, and split exa…
Browse files Browse the repository at this point in the history
…mple for config.reset

- #435
  • Loading branch information
dchelimsky committed Aug 7, 2011
1 parent 371fc52 commit af6f886
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
(Arthur Gunn) (Arthur Gunn)
* Friendly error message when shared context cannot be found (Sławosz * Friendly error message when shared context cannot be found (Sławosz
Sławiński) Sławiński)
* Clear formatters when resetting config (John Bintz)


* Bug fixes * Bug fixes
* Only eval `let` block once even if it returns `nil` (Adam Meehan) * Only eval `let` block once even if it returns `nil` (Adam Meehan)
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/core/configuration.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def initialize


def reset def reset
@reporter = nil @reporter = nil
@formatters = [] @formatters.clear if @formatters
end end


# :call-seq: # :call-seq:
Expand Down
11 changes: 8 additions & 3 deletions spec/rspec/core/configuration_spec.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -887,9 +887,14 @@ def metadata_hash(*args)
end end


describe "#reset" do describe "#reset" do
it "resets the reporter and formatters" do it "clears the reporter" do
config.reporter config.reporter.should_not be_nil
config.formatters.should_not be_empty config.reset
config.instance_variable_get("@reporter").should be_nil
end

it "clears the formatters" do
config.add_formatter "doc"
config.reset config.reset
config.formatters.should be_empty config.formatters.should be_empty
end end
Expand Down

0 comments on commit af6f886

Please sign in to comment.