spec/conglomerate_spec.rb in conglomerate-0.8.1 vs spec/conglomerate_spec.rb in conglomerate-0.9.0

- old
+ new

@@ -32,10 +32,14 @@ query :search, :data => :id do search_items_url end + command :populate, :data => :id, :prompt => "test 123" do + populate_items_url + end + template :repeats, :prompt => "true|false" end class ConglomerateExtraTestSerializer include Conglomerate.serializer @@ -68,10 +72,11 @@ request = double("Request", :original_url => "https://example.com/items") double( "Context", :request => request, :search_items_url => "https://example.com/items/search", + :populate_items_url => "https://example.com/items/populate", ).tap do |context| allow(context).to receive(:item_url).with(1) { "https://example.com/items/1" } allow(context).to receive(:event_url).with(2) { @@ -134,9 +139,30 @@ expect(test_collection["queries"]).to match_array( [ { "href" => "https://example.com/items/search", "rel" => "search", + "data" => [ + {"name" => "id", "value" => ""} + ] + } + ] + ) + end + end + + describe "#command" do + it "doesn't include any command templates if none are provided" do + expect(null_collection.keys).to_not include("commands") + end + + 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" => ""} ] } ]