* Specs for FuctionCaller * Fix accepting nil values from AWS lambda * Specs for the black_box #2524 * Spec for BlackBox#comment_quality_score * Remove vcr cassette usage from the CouponGenerator spec
21 lines
672 B
Ruby
21 lines
672 B
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe FunctionCaller do
|
|
let(:payload) { { user_id: 1, name: "hello" } }
|
|
let(:dummy_client) { double }
|
|
let(:result) { OpenStruct.new(payload: [{ body: { message: "hi" }.to_json }.to_json]) }
|
|
|
|
before do
|
|
allow(dummy_client).to receive(:invoke).and_return(result)
|
|
end
|
|
|
|
it "calls the aws_lambda_client" do
|
|
described_class.call("some_function", payload, dummy_client)
|
|
expect(dummy_client).to have_received(:invoke).with(function_name: "some_function", payload: payload)
|
|
end
|
|
|
|
it "returns parsed value" do
|
|
value = described_class.call("some_function", payload, dummy_client)
|
|
expect(value).to eq("hi")
|
|
end
|
|
end
|