Sha256: 464dc4ec4794d4565fdf17d0231b45d0392c83a649e1c9ede0547c4119933e76

Contents?: true

Size: 717 Bytes

Versions: 3

Compression:

Stored size: 717 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, mode: :compat)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
search_flip-4.0.0.beta3 spec/search_flip/json_spec.rb
search_flip-4.0.0.beta2 spec/search_flip/json_spec.rb
search_flip-4.0.0.beta1 spec/search_flip/json_spec.rb