Sha256: 5d2e6381415423464ed3b0883d31369505b3b202d3a1d29fa959b5e45e14bbd5

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

require 'rails_helper'

describe Samsara::Context do

  let(:celebrity_params) do
    { first_name: "Neil", last_name: "Harris" }
  end

  let(:params) do
    { celebrity: celebrity_params, controller: "celebrities", action: "create" }
  end

  let(:event_attributes) do
    { method: "POST", url: "/celebrities", params: params }
  end

  let(:event) do
    Samsara::HttpRequest.new(event_attributes)
  end

  let(:context_attributes) do
    { environment_name: "test", application_name: "Dummy", event: event }
  end

  before { Samsara::Context.create context_attributes }
  subject { Samsara::Context.first }

  describe "#event_attributes" do
    it "is serialized using the Samsara::Serializer" do
      allow(Samsara::Serializer).to receive(:dump).with(any_args)
      expect(Samsara::Serializer).to receive(:dump).with(event_attributes)
      subject.event_attributes = event_attributes
    end

    it "is deserialized using the Samsara::Serializer" do
      allow(Samsara::Serializer).to receive(:load).with(any_args)
      expect(Samsara::Serializer).to receive(:load).with(event_attributes.to_json)
      subject.event_attributes
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
samsara-0.0.3 spec/context_spec.rb
samsara-0.0.2 spec/context_spec.rb