Sha256: 1c403e107b5df0e4874297be7074eb8f55b9078307b87a20887493af75be64da
Contents?: true
Size: 1.69 KB
Versions: 1
Compression:
Stored size: 1.69 KB
Contents
require 'spec_helper' require 'grape_entity' describe GrapeEntityMatchers do before(:all) do class PetEntity < Grape::Entity expose :name, :age end class Person include Grape::Entity::DSL entity :name, :age do expose :date_of_birth, :as => :brithday expose :cat, :as => :cat, :using => PetEntity expose :dog, :using => PetEntity expose :secret, :if => lambda{ |person, options| person.authorized? } expose :super_dooper_secret, :as => :top_secret, :if => lambda{ |person, options| person.authorized? } end end end context 'matchers' do subject(:entity){ Person::Entity } # TODO: move the tests to this format to shadow the thoughtbot tests. # it { should represent(:name) } it "should ensure the representation includes the specified property" do entity.should represent :name end it { should represent(:date_of_birth).as(:brithday) } it { should_not represent(:t_shirt_size) } it { should_not represent(:t_shirt_size).as(:brithday) } it { should_not represent(:name).as(:brithday) } it { should_not represent(:date_of_birth) } it { should represent(:secret).when( :authorized? => true ) } it { should_not represent(:secret).when( :authorized? => false ) } it { should represent(:super_dooper_secret).as(:top_secret).when( :authorized? => true ) } it { should_not represent(:super_dooper_secret).as(:top_secret).when( :authorized? => false ) } it { should_not represent(:super_dooper_secret).when( :authorized? => true ) } it { should represent(:dog).using(PetEntity) } it { should represent(:cat).as(:cat).using(PetEntity) } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
grape-entity-matchers-0.0.1 | spec/grape_entity_matchers/represent_matcher_spec.rb |