Sha256: dfcc2ee33a1343bb2c24ec6fdd30e715a8ea26e77247750a580da2d67d763af8
Contents?: true
Size: 1.72 KB
Versions: 3
Compression:
Stored size: 1.72 KB
Contents
require 'spec_helper' require 'json' describe Spectifly::Json::Builder do describe '#build' do it 'returns a hash representation of the entity' do entity = Spectifly::Entity.parse(fixture_path('individual')) json_path = expectation_path('individual', 'json') hash = described_class.new(entity).build JSON.pretty_generate(hash).strip.should == File.read(json_path).strip end it 'works with containing relationships' do entity = Spectifly::Entity.parse(fixture_path('group')) json_path = expectation_path('group', 'json') hash = described_class.new(entity).build JSON.pretty_generate(hash).should == File.read(json_path) end end describe '#present_as' do it 'filters entity through presenter, and returns self' do entity = Spectifly::Entity.parse(fixture_path('individual')) presenter_entity = Spectifly::Entity.parse(fixture_path('presenters/positionless_individual/individual')) json_path = expectation_path('presented/positionless_individual', 'json') builder = described_class.new(entity) builder.present_as(presenter_entity).should == builder hash = builder.build JSON.pretty_generate(hash).strip.should == File.read(json_path).strip end it 'works with overriding relationships' do entity = Spectifly::Entity.parse(fixture_path('group')) presenter_entity = Spectifly::Entity.parse(fixture_path('presenters/masterless_group/group')) json_path = expectation_path('presented/masterless_group', 'json') builder = described_class.new(entity) builder.present_as(presenter_entity).should == builder hash = builder.build JSON.pretty_generate(hash).should == File.read(json_path) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
spectifly-0.0.10 | spec/spectifly/json/builder_spec.rb |
spectifly-0.0.9 | spec/spectifly/json/builder_spec.rb |
spectifly-0.0.8 | spec/spectifly/json/builder_spec.rb |