Sha256: 7806e907eac5833ebf64a3a4e743d4099d0d9d4840b86a024425aca922bffb97
Contents?: true
Size: 930 Bytes
Versions: 2
Compression:
Stored size: 930 Bytes
Contents
require 'xing/serializers/base' require 'json_spec' describe Xing::Serializers::Base do include JsonSpec::Matchers let :resource do double("a mock activemodel").tap do |model| allow(model).to receive(:read_attribute_for_serialization).with(:name).and_return("My Name!") allow(model).to receive(:read_attribute_for_serialization).with(:position).and_return(2) end end context "a subclass" do class MySerializer < Xing::Serializers::Base attributes :name, :position def links { :self => 'url_for_this_model' } end end it "should generate a JSON with the proper links and self" do json = MySerializer.new(resource).to_json expect(json).to be_json_eql('"url_for_this_model"').at_path('links/self') expect(json).to be_json_eql('"My Name!"').at_path('data/name') expect(json).to be_json_eql('2').at_path('data/position') end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
xing-backend-0.0.11 | spec/xing/serializers/base_spec.rb |
xing-backend-0.0.10 | spec/xing/serializers/base_spec.rb |