Sha256: bf4bd03dc19a98f0e711d4593ad70ff55cc2dbf17b30fdb4c15f5008263186ce

Contents?: true

Size: 1.45 KB

Versions: 15

Compression:

Stored size: 1.45 KB

Contents

unless Opal::RSpec::Compatibility.multiple_module_include_super_works_right?
  module ::RSpec::Mocks::TestDouble
    # With multiple modules included in a class, Opal doesn't let module 2 (VerifyingDouble) invoke super from module 1 (TestDouble)
    def call_method_missing(message, *args, &block)
      proxy = __mock_proxy
      proxy.record_message_received(message, *args, &block)

      if proxy.null_object?
        case message
          when :to_int then
            return 0
          when :to_a, :to_ary then
            return nil
          when :to_str then
            return to_s
          else
            return self
        end
      end

      # Defined private and protected methods will still trigger `method_missing`
      # when called publicly. We want ruby's method visibility error to get raised,
      # so we simply delegate to `super` in that case.
      # ...well, we would delegate to `super`, but there's a JRuby
      # bug, so we raise our own visibility error instead:
      # https://github.com/jruby/jruby/issues/1398
      visibility = proxy.visibility_for(message)
      if visibility == :private || visibility == :protected
        ErrorGenerator.new(self, @name).raise_non_public_error(
            message, visibility
        )
      end

      # Required wrapping doubles in an Array on Ruby 1.9.2
      raise NoMethodError if [:to_a, :to_ary].include? message
      proxy.raise_unexpected_message_error(message, *args)
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
opal-rspec-0.8.0 lib-opal/opal/rspec/fixes/rspec/mocks/test_double.rb
opal-rspec-0.8.0.alpha3 lib-opal/opal/rspec/fixes/rspec/mocks/test_double.rb
opal-rspec-0.8.0.alpha2 lib-opal/opal/rspec/fixes/rspec/mocks/test_double.rb
opal-rspec-0.8.0.alpha1 lib-opal/opal/rspec/fixes/rspec/mocks/test_double.rb
opal-rspec-0.7.1 lib-opal/opal/rspec/fixes/rspec/mocks/test_double.rb
opal-rspec-0.7.0 lib-opal/opal/rspec/fixes/rspec/mocks/test_double.rb
opal-rspec-0.6.2 opal/opal/rspec/fixes/rspec/mocks/test_double.rb
opal-rspec-0.7.0.rc.2 lib-opal/opal/rspec/fixes/rspec/mocks/test_double.rb
opal-rspec-0.7.0.rc.1 lib-opal/opal/rspec/fixes/rspec/mocks/test_double.rb
opal-rspec-0.6.1 opal/opal/rspec/fixes/rspec/mocks/test_double.rb
opal-rspec-0.6.0 opal/opal/rspec/fixes/rspec/mocks/test_double.rb
opal-rspec-0.6.0.beta1 opal/opal/rspec/fixes/rspec/mocks/test_double.rb
opal-connect-rspec-0.5.0 opal/opal/rspec/fixes/rspec/mocks/test_double.rb
opal-rspec-0.5.0 opal/opal/rspec/fixes/rspec/mocks/test_double.rb
opal-rspec-0.5.0.beta3 opal/opal/rspec/fixes/rspec/mocks/test_double.rb