Sha256: 7e3f4f6c0d01848ef3779b54b5e367366a68b018864019604892d2bb6c8924b3

Contents?: true

Size: 769 Bytes

Versions: 11

Compression:

Stored size: 769 Bytes

Contents

# frozen_string_literal: true

require 'active_support/all'

require File.expand_path('../shark/rspec/helpers', __dir__)

class SharkSpec
  extend Shark::RSpec::Helpers

  class << self
    def method_missing(name, *args, &block)
      if name.match(/^stub_/)
        fake_service(name).setup
      elsif name.match(/^unstub_/)
        fake_service(name).reset
      else
        super
      end
    end

    def respond_to_missing?(name, _include_private)
      if name.match(/^stub_/)
        true
      elsif name.match(/^unstub_/)
        true
      else
        super
      end
    end

    protected

    def fake_service(method)
      service = method.to_s.gsub(/(un)?stub_/, '').camelize
      Module.const_get("Shark::RSpec::Fake#{service}")
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
bima-shark-sdk-3.1.1 lib/bima-shark-sdk/rspec.rb
bima-shark-sdk-2.5.0 lib/bima-shark-sdk/rspec.rb
bima-shark-sdk-3.1.0 lib/bima-shark-sdk/rspec.rb
bima-shark-sdk-3.0.0 lib/bima-shark-sdk/rspec.rb
bima-shark-sdk-2.4.4 lib/bima-shark-sdk/rspec.rb
bima-shark-sdk-2.4.3 lib/bima-shark-sdk/rspec.rb
bima-shark-sdk-2.4.2 lib/bima-shark-sdk/rspec.rb
bima-shark-sdk-2.4.1 lib/bima-shark-sdk/rspec.rb
bima-shark-sdk-2.4.0 lib/bima-shark-sdk/rspec.rb
bima-shark-sdk-2.3.1 lib/bima-shark-sdk/rspec.rb
bima-shark-sdk-2.3.0 lib/bima-shark-sdk/rspec.rb