Sha256: 91d10dbbe8bedc1a1dd06862ee23956c3342b780919a7c5bcf5fd03fa27629d9
Contents?: true
Size: 929 Bytes
Versions: 14
Compression:
Stored size: 929 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
14 entries across 14 versions & 1 rubygems