spec/grape_entity/entity_spec.rb in grape-entity-0.1.0 vs spec/grape_entity/entity_spec.rb in grape-entity-0.2.0
- old
+ new
@@ -1,9 +1,9 @@
require 'spec_helper'
-describe GrapeEntity::Entity do
- let(:fresh_class) { Class.new(GrapeEntity::Entity) }
+describe Grape::Entity do
+ let(:fresh_class) { Class.new(Grape::Entity) }
context 'class methods' do
subject { fresh_class }
describe '.expose' do
@@ -377,11 +377,11 @@
context 'child representations' do
it 'disables root key name for child representations' do
module EntitySpec
- class FriendEntity < GrapeEntity::Entity
+ class FriendEntity < Grape::Entity
root 'friends', 'friend'
expose :name, :email
end
end
@@ -396,11 +396,11 @@
rep.last.serializable_hash[:name].should == 'Friend 2'
end
it 'passes through custom options' do
module EntitySpec
- class FriendEntity < GrapeEntity::Entity
+ class FriendEntity < Grape::Entity
root 'friends', 'friend'
expose :name
expose :email, :if => { :user_type => :admin }
end
end
@@ -422,11 +422,11 @@
rep.last.serializable_hash[:email].should == 'friend2@example.com'
end
it 'ignores the :collection parameter in the source options' do
module EntitySpec
- class FriendEntity < GrapeEntity::Entity
+ class FriendEntity < Grape::Entity
root 'friends', 'friend'
expose :name
expose :email, :if => { :collection => true }
end
end
@@ -531,15 +531,15 @@
describe '::DSL' do
subject{ Class.new }
it 'creates an Entity class when called' do
subject.should_not be_const_defined :Entity
- subject.send(:include, GrapeEntity::Entity::DSL)
+ subject.send(:include, Grape::Entity::DSL)
subject.should be_const_defined :Entity
end
context 'pre-mixed' do
- before{ subject.send(:include, GrapeEntity::Entity::DSL) }
+ before{ subject.send(:include, Grape::Entity::DSL) }
it 'is able to define entity traits through DSL' do
subject.entity do
expose :name
end