Class: RSpec::Mocks::Space
- Inherits:
-
Object
- Object
- RSpec::Mocks::Space
- Defined in:
- opal/opal/rspec/fixes/rspec/mocks/space.rb
Overview
Opal does not support ObjectSpace, so force object id's
Constant Summary collapse
- OPAL_NON_MOCKABLE_TYPES =
[:String, :Number, :Numeric]
Instance Method Summary collapse
- #id_for(object) ⇒ Object
-
#proxy_not_found_for(id, object) ⇒ Object
originally had an alternate impl here due to Opal::RSpec::Compatibility.module_case_works_right?, now also doing checks.
Instance Method Details
#id_for(object) ⇒ Object
5 6 7 |
# File 'opal/opal/rspec/fixes/rspec/mocks/space.rb', line 5 def id_for(object) object.__id__ end |
#proxy_not_found_for(id, object) ⇒ Object
originally had an alternate impl here due to Opal::RSpec::Compatibility.module_case_works_right?, now also doing checks
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'opal/opal/rspec/fixes/rspec/mocks/space.rb', line 10 def proxy_not_found_for(id, object) raise "#{object.class} #{object} cannot be used for mocking in Opal!" if OPAL_NON_MOCKABLE_TYPES.include?(object.class.name) # case when SomeClass wasn't working properly includes_test_double = [ InstanceVerifyingDouble, ObjectVerifyingDouble, ClassVerifyingDouble, Double ] proxies[id] = if object.is_a?(NilClass) ProxyForNil.new(@expectation_ordering) elsif includes_test_double.any? { |klass| object.is_a? klass } object.__build_mock_proxy_unless_expired(@expectation_ordering) elsif object.is_a?(Class) if RSpec::Mocks.configuration.verify_partial_doubles? VerifyingPartialClassDoubleProxy.new(self, object, @expectation_ordering) else PartialClassDoubleProxy.new(self, object, @expectation_ordering) end else if RSpec::Mocks.configuration.verify_partial_doubles? VerifyingPartialDoubleProxy.new(object, @expectation_ordering) else PartialDoubleProxy.new(object, @expectation_ordering) end end end |