Skip to content

Commit

Permalink
Merge pull request #1667 from rspec/tweak_inner_symbol_deprecation
Browse files Browse the repository at this point in the history
Tweak deprecation message for symbol descriptions.
  • Loading branch information
JonRowe committed Aug 19, 2014
2 parents 30f58d3 + 0f6ce5b commit 00eceeb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
7 changes: 7 additions & 0 deletions Changelog.md
@@ -1,3 +1,10 @@
### 2.99.2 development
[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.99.1...master)

Enhancements:

* Tweak deprecation warning for `Symbol` descriptions. (Jon Rowe, #1667)

### 2.99.1 / 2014-06-19
[Full Changelog](http://github.com/rspec/rspec-core/compare/v2.99.0...v2.99.1)

Expand Down
5 changes: 3 additions & 2 deletions lib/rspec/core/example_group.rb
Expand Up @@ -350,8 +350,9 @@ def warning
<<-EOS.gsub(/^\s+\|/, '')
|The semantics of `describe <a #{arg.class.name}>` are changing in RSpec 3. In RSpec 2,
|this would be treated as metadata, but as the first `describe` argument,
|this will be treated as the described object in RSpec 3. If you want this
|to be treated as metadata, pass a description as the first argument.
|this will be treated as the described object (affecting the value of
|`described_class`) in RSpec 3. If you want this to be treated as metadata,
|pass a description as the first argument.
|(Example group defined at #{call_site})
EOS
end
Expand Down
15 changes: 14 additions & 1 deletion spec/rspec/core/example_group_spec.rb
Expand Up @@ -344,7 +344,7 @@ def capture_deprecation_options
warn_opts
end

it "prints a deprecation warning since the semantics are changing in RSpec 3" do
it "prints a deprecation warning since the semantics of an inner described_class are changing in RSpec 3" do
warn_opts = capture_deprecation_options do
ExampleGroup.describe(String) do
describe Array do
Expand All @@ -357,6 +357,19 @@ def capture_deprecation_options
expect(warn_opts[:message]).to include("described_class")
end

it "prints a deprecation warning since the semantics of an inner described symbol are changing in RSpec 3" do
warn_opts = capture_deprecation_options do
ExampleGroup.describe(String) do
describe :method do
example { described_class }
end
end.run
end

expect(warn_opts[:message]).to include("#{__FILE__}:#{__LINE__ - 6}")
expect(warn_opts[:message]).to include("described_class")
end

it "prints a deprecation even when `described_class` has already been referenced in the outer group" do
warn_opts = capture_deprecation_options do
outer_dc = inner_dc = nil
Expand Down

0 comments on commit 00eceeb

Please sign in to comment.