spec/conglomerate_spec.rb in conglomerate-0.1.1 vs spec/conglomerate_spec.rb in conglomerate-0.2.0

- old
+ new

@@ -32,17 +32,24 @@ end class ConglomerateExtraTestSerializer include Conglomerate.serializer + href { "" } attribute :id end class ConglomerateNullSerializer include Conglomerate.serializer + + href { "" } end +class ConglomerateInvalidSerializer + include Conglomerate.serializer +end + describe Conglomerate do let(:object) do double( "Object", :id => 1, @@ -87,16 +94,22 @@ let(:null_serializer) do ConglomerateNullSerializer.new(object, :context => context).serialize end + let(:invalid_serializer) do + ConglomerateInvalidSerializer.new(object, :context => context).serialize + end + let(:test_collection) { test_serializer["collection"] } let(:extra_test_collection) { extra_test_serializer["collection"] } let(:null_collection) { null_serializer["collection"] } + let(:invalid_collection) { invalid_serializer["collection"] } + describe "#version" do it "sets version to 1.0" do expect(null_collection["version"]).to eq("1.0") expect(test_collection["version"]).to eq("1.0") end @@ -105,11 +118,11 @@ describe "#href" do it "in context, uses the block to set the collection href" do expect(test_collection["href"]).to eq("abc") end - it "uses 'request.original_url' if preset 'rails_current_url' used" do - expect(extra_test_collection["href"]).to eq("https://example.com/items") + it "errors if no href given" do + expect { invalid_collection["href"] }.to raise_error end end describe "#query" do it "doesn't include any query templates if none are provided" do