Sha256: 8bdd43b5a2c8f484361293d5e56b4654b0a09a1594f6a8b1f78affc078485af7

Contents?: true

Size: 1.15 KB

Versions: 8

Compression:

Stored size: 1.15 KB

Contents

require_relative "spec_helper"
require_relative "../lib/conglomerate"
require_relative "../lib/conglomerate/ext/commands"

class CommandExtTestSerializer
  include Conglomerate::RootBuilder.serializer

  collection do
    command :populate do
      prompt { "test 123" }
      href { populate_items_url }
      datum :id
    end
  end
end

describe "Conglomerate Command Ext" do
  let(:object) do
    double(
      "Object",
      :id => 1
    )
  end

  let(:context) do
    double(
      "Context",
      :populate_items_url => "https://example.com/items/populate"
    )
  end

  let(:test_serializer) do
    CommandExtTestSerializer.new(object, :context => context).serialize
  end

  let(:test_collection) do
    test_serializer["collection"]
  end

  context "#command" do
    it "adds a command template to the collection" do
      expect(test_collection["commands"]).to match_array(
        [
          {
            "href" => "https://example.com/items/populate",
            "rel" => "populate",
            "prompt" => "test 123",
            "data" => [
              {"name" => "id", "value" => nil}
            ]
          }
        ]
      )
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
conglomerate-0.16.0 spec/command_ext_spec.rb
conglomerate-0.15.0 spec/command_ext_spec.rb
conglomerate-0.14.0 spec/command_ext_spec.rb
conglomerate-0.13.0 spec/command_ext_spec.rb
conglomerate-0.12.1 spec/command_ext_spec.rb
conglomerate-0.12.0 spec/command_ext_spec.rb
conglomerate-0.11.1 spec/command_ext_spec.rb
conglomerate-0.11.0 spec/command_ext_spec.rb