Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 0928c69

Browse files
committed
Merge pull request #1104 from palfvin/2-99-its
Deprecate 'its' in favor of rspec-its gem as part of #1083
2 parents ccc3a73 + a6df4eb commit 0928c69

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Deprecations
2929
RSpec 3 will not support having this option set to `false` (Myron Marston).
3030
* Deprecate accessing a `let` or `subject` declaration in
3131
a `after(:all)` hook. (Myron Marston, Jon Rowe)
32+
* Deprecate built-in `its` usage in favor of `rspec-it` gem due to planned
33+
removal in RSpec 3 (Peter Alfvin)
3234

3335
### 2.14.5 / 2013-08-13
3436
[full changelog](http://github.com/rspec/rspec-core/compare/v2.14.4...v2.14.5)

lib/rspec/core/memoized_helpers.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ def subject!(name=nil, &block)
455455
# its(:age) { should eq(25) }
456456
# end
457457
def its(attribute, &block)
458+
RSpec.deprecate('Use of rspec-core\'s "its" method', :replacement => 'rspec-its gem')
458459
describe(attribute) do
459460
if Array === attribute
460461
let(:__its_subject) { subject[*attribute] }

spec/rspec/core/memoized_helpers_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,12 @@ def not_ok?; false; end
348348
end
349349

350350
describe "#its" do
351+
352+
it "should issue deprecation warning" do
353+
expect_deprecation_with_call_site(__FILE__, __LINE__+1, '"its" method')
354+
RSpec::Core::ExampleGroup.its(nil) {}
355+
end
356+
351357
subject do
352358
Class.new do
353359
def initialize

spec/support/helper_methods.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ def safely
2323
end
2424
end
2525

26-
def expect_deprecation_with_call_site(file, line)
26+
def expect_deprecation_with_call_site(file, line, deprecated = //)
2727
expect(RSpec.configuration.reporter).to receive(:deprecation) do |options|
2828
expect(options[:call_site]).to include([file, line].join(':'))
29+
expect(options[:deprecated]).to match(deprecated)
2930
end
3031
end
3132

0 commit comments

Comments
 (0)