Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of warnings from rspec-core's library and spec code. #909

Merged
merged 7 commits into from May 16, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Changelog.md
Expand Up @@ -60,6 +60,7 @@ Bug fixes
doc string has been provided (David Chelimsky).
* Fix the memoized methods (`let` and `subject`) leaking `define_method`
as a `public` method. (Thomas Holmes and Jon Rowe) (#873)
* Silence warnings coming from the test suite. (Pete Higgins)

Deprecations

Expand Down
1 change: 1 addition & 0 deletions lib/rspec/core/memoized_helpers.rb
Expand Up @@ -139,6 +139,7 @@ def preserve_accessed_lets

@example_group_instance.class.class_eval do
hash.each do |key, value|
undef_method(key) if method_defined?(key)
define_method(key) { value }
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/core/example_group_spec.rb
Expand Up @@ -906,7 +906,7 @@ def define_and_run_group(define_outer_example = false)

it "sets RSpec.wants_to_quit flag if encountering an exception in before(:all)" do
group.before(:all) { raise "error in before all" }
example = group.example("equality") { expect(1).to eq(2) }
group.example("equality") { expect(1).to eq(2) }
expect(group.run).to be_false
expect(RSpec.wants_to_quit).to be_true
end
Expand Down
4 changes: 2 additions & 2 deletions spec/rspec/core/example_spec.rb
Expand Up @@ -8,7 +8,7 @@
end

let(:example_instance) do
example_group.example('example description')
example_group.example('example description') { }
end

it_behaves_like "metadata hash builder" do
Expand All @@ -28,7 +28,7 @@ def capture_stdout
end

it 'can be pretty printed' do
output = capture_stdout { pp example_instance }
output = ignoring_warnings { capture_stdout { pp example_instance } }
expect(output).to include("RSpec::Core::Example")
end

Expand Down
6 changes: 3 additions & 3 deletions spec/rspec/core/formatters/base_text_formatter_spec.rb
Expand Up @@ -55,7 +55,7 @@ def run_all_and_dump_failures
exception_without_message = Exception.new()
exception_without_message.stub(:message) { nil }
group.example("example name") { raise exception_without_message }
expect { run_all_and_dump_failures }.not_to raise_error(NoMethodError)
expect { run_all_and_dump_failures }.not_to raise_error
end

it "preserves ancestry" do
Expand All @@ -70,7 +70,7 @@ def run_all_and_dump_failures
gonzo_exception = RuntimeError.new
gonzo_exception.stub(:message) { gonzo_exception }
group.example("example name") { raise gonzo_exception }
expect { run_all_and_dump_failures }.not_to raise_error(NoMethodError)
expect { run_all_and_dump_failures }.not_to raise_error
end
end

Expand Down Expand Up @@ -218,7 +218,7 @@ def run_all_and_dump_pending
exception_without_message = Exception.new()
exception_without_message.stub(:message) { nil }
group.example("example name") { pending { raise exception_without_message } }
expect { run_all_and_dump_pending }.not_to raise_error(NoMethodError)
expect { run_all_and_dump_pending }.not_to raise_error
end
end

Expand Down
10 changes: 9 additions & 1 deletion spec/support/helper_methods.rb
Expand Up @@ -3,9 +3,17 @@ def relative_path(path)
RSpec::Core::Metadata.relative_path(path)
end

def ignoring_warnings
original = $VERBOSE
$VERBOSE = nil
result = yield
$VERBOSE = original
result
end

def safely
Thread.new do
$SAFE = 3
ignoring_warnings { $SAFE = 3 }
yield
end.join

Expand Down