Skip to content

Commit

Permalink
Deprecate RSpec::Mocks::TestDouble.extend_onto
Browse files Browse the repository at this point in the history
  • Loading branch information
myronmarston committed Feb 23, 2014
1 parent 15213d2 commit ea9ed37
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Changelog.md
@@ -1,6 +1,10 @@
### 2.99.0.rc1 Development
[full changelog](http://github.com/rspec/rspec-mocks/compare/v2.99.0.beta2...2-99-maintenance)

Deprecations:

* Deprecate `RSpec::Mocks::TestDouble.extend_onto`. (Myron Marston)

### 2.99.0.beta2 / 2014-02-17
[full changelog](http://github.com/rspec/rspec-mocks/compare/v2.99.0.beta1...v2.99.0.beta2)

Expand Down
1 change: 1 addition & 0 deletions lib/rspec/mocks/test_double.rb
Expand Up @@ -13,6 +13,7 @@ module TestDouble
# RSpec::Mocks::TestDouble.extend_onto(module, "MyMixin", :foo => "bar")
# module.foo #=> "bar"
def self.extend_onto(object, name=nil, stubs_and_options={})
RSpec.deprecate("`RSpec::Mocks::TestDouble.extend_onto(...)`")
object.extend self
object.send(:__initialize_as_test_double, name, stubs_and_options)
end
Expand Down
7 changes: 7 additions & 0 deletions spec/rspec/mocks/test_double_spec.rb
Expand Up @@ -3,6 +3,8 @@
module RSpec
module Mocks
describe TestDouble do
before { allow_deprecation }

before(:all) do
Module.class_eval do
private
Expand Down Expand Up @@ -31,6 +33,11 @@ def use; end
expect { double.foo }.to raise_error(/Mock "MyDouble" received/)
end

it 'warns when `extend_onto` is used' do
expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, /RSpec::Mocks::TestDouble.extend_onto/)
Module.new { TestDouble.extend_onto(self) }
end

[[:should, :expect], [:expect], [:should]].each do |syntax|
context "with syntax #{syntax.inspect}" do
include_context "with syntax", syntax
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Expand Up @@ -37,7 +37,7 @@ def expect_warn_deprecation_with_call_site(file, line, snippet=//)
end

def allow_deprecation
allow(RSpec.configuration.reporter).to receive(:deprecation)
RSpec::Mocks.allow_message(RSpec.configuration.reporter, :deprecation)
end

def allow_unavoidable_1_8_deprecation
Expand Down

0 comments on commit ea9ed37

Please sign in to comment.