Sha256: f83da15484ec6b25de15953bd23740196afa58c5c2a7d64a3f1c58d0170f7e70
Contents?: true
Size: 912 Bytes
Versions: 6
Compression:
Stored size: 912 Bytes
Contents
class StripeModelCallbacks::EventMockerService attr_reader :args, :name, :scope def initialize(args:, name:, scope:) @args = args @name = name @scope = scope bypass_event_signature(payload) post_event end private def bypass_event_signature(payload) event = Stripe::Event.construct_from(payload) scope.expect(Stripe::Webhook).to scope.receive(:construct_event).and_return(event) end def first_part @first_part ||= name.split(".").first end def fixture_path @fixture_path ||= "#{File.dirname(__FILE__)}/../../../lib/stripe_model_callbacks/fixtures/stripe_events/#{first_part}/#{name}.json" end def payload file_content = File.read(fixture_path) data = JSON.parse(file_content, symbolize_names: true) data.deep_merge!(args) if args data end def post_event scope.post("/stripe-events", params: JSON.generate(payload)) end end
Version data entries
6 entries across 6 versions & 1 rubygems