Sha256: 907a2745fe731e682935c3e3f6db52eb4efd1ce68e349f93775e1d8bc9acae10

Contents?: true

Size: 702 Bytes

Versions: 1

Compression:

Stored size: 702 Bytes

Contents

require File.expand_path("../spec_helper", __dir__)

RSpec.describe SearchFlip::JSON do
  describe ".generate" do
    it "delegates to Oj" do
      allow(Oj).to receive(:dump)

      payload = { key: "value" }

      described_class.generate(payload)

      expect(Oj).to have_received(:dump).with(payload, mode: :custom, use_to_json: true)
    end

    it "generates json" do
      expect(described_class.generate(key: "value")).to eq('{"key":"value"}')
    end
  end

  describe ".parse" do
    it "delegates to Oj" do
      allow(Oj).to receive(:load)

      payload = '{"key":"value"}'

      described_class.parse(payload)

      expect(Oj).to have_received(:load).with(payload)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
search_flip-4.0.0.beta spec/search_flip/json_spec.rb