Sha256: f0ccb18a6cb4e1d44caad191173bc92cf93bfc9e5cf9ca49a9ddcab7c3562dc0

Contents?: true

Size: 1.09 KB

Versions: 7

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'

describe Alephant::Broker::PostRequest do
  subject { Alephant::Broker::PostRequest }

  describe "#components" do
    it "returns hash of component parts + sub components" do
      components = [{
        "component" => "qux",
        "options"   => { "variant" => "cor" }
      }]

      env = (Struct.new(:path, :data)).new("/foo/bar", {
        'batch_id'    => :foobar,
        'components'  => components
      })

      hash = {
        :batch_id     => :foobar,
        :type         => "foo",
        :component_id => "bar",
        :components   => components
      }

      RequestStore
        .stub(:store)
        .and_return({
          :env => env
        })

      instance = subject.new
      expect(instance.components).to eq(hash)
    end
  end

  describe "#set_component(id, options)" do
    it "sets instance attribute values" do
      subject
        .any_instance
        .stub(:initialize)

      instance = subject.new
      instance.set_component(:foo, :bar)

      expect(instance.component_id).to eq(:foo)
      expect(instance.options).to eq(:bar)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
alephant-broker-0.1.6 spec/post_request_spec.rb
alephant-broker-0.1.5 spec/post_request_spec.rb
alephant-broker-0.1.4 spec/post_request_spec.rb
alephant-broker-0.1.3 spec/post_request_spec.rb
alephant-broker-0.1.2 spec/post_request_spec.rb
alephant-broker-0.1.1 spec/post_request_spec.rb
alephant-broker-0.1.0 spec/post_request_spec.rb