Module: Authograph::RSpecHelpers

Defined in:
lib/authograph/rspec.rb

Instance Method Summary collapse

Instance Method Details

#stub_authograph(_matcher, _signature = nil) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/authograph/rspec.rb', line 3

def stub_authograph(_matcher, _signature = nil)
  if _signature.nil?
    _signature = _matcher
    _matcher = :any
  end

  allow_any_instance_of(Authograph::Signer)
    .to receive(:calc_signature)
    .and_wrap_original do |original, request, secret|
      case _matcher
      when :any
        next _signature
      when Hash
        # TODO
      end

      original.call(request, secret) # fallback to original
    end
end