Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Don't patch Psych.dump unless Psych is loaded and responds to #dump.

This fixes errors with running the specs on 1.9.2 w/o psych support compiled in.
  • Loading branch information...
commit 4b6774d23698c38a5171329447ada5b72072af04 1 parent 8ce0c12
@myronmarston myronmarston authored
Showing with 16 additions and 14 deletions.
  1. +16 −14 lib/rspec/mocks/extensions/psych.rb
View
30 lib/rspec/mocks/extensions/psych.rb
@@ -1,21 +1,23 @@
-module Psych
- class << self
- def dump_with_mocks(object, *args)
- return dump_without_mocks(object, *args) unless object.instance_variable_defined?(:@mock_proxy)
+if defined?(Psych) && Psych.respond_to?(:dump)
+ module Psych
+ class << self
+ def dump_with_mocks(object, *args)
+ return dump_without_mocks(object, *args) unless object.instance_variable_defined?(:@mock_proxy)
- mp = object.instance_variable_get(:@mock_proxy)
- return dump_without_mocks(object, *args) unless mp.is_a?(::RSpec::Mocks::Proxy)
+ mp = object.instance_variable_get(:@mock_proxy)
+ return dump_without_mocks(object, *args) unless mp.is_a?(::RSpec::Mocks::Proxy)
- object.send(:remove_instance_variable, :@mock_proxy)
+ object.send(:remove_instance_variable, :@mock_proxy)
- begin
- dump_without_mocks(object, *args)
- ensure
- object.instance_variable_set(:@mock_proxy,mp)
+ begin
+ dump_without_mocks(object, *args)
+ ensure
+ object.instance_variable_set(:@mock_proxy,mp)
+ end
end
- end
- alias_method :dump_without_mocks, :dump
- alias_method :dump, :dump_with_mocks
+ alias_method :dump_without_mocks, :dump
+ alias_method :dump, :dump_with_mocks
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.