Skip to content

Commit fc98379

Browse files
committed
Fix for rspec 3 compatability
- be_true/ be_false are no longer equivalent to "== true"/"== false" within rspec 3.0.
1 parent 91b4080 commit fc98379

File tree

2 files changed

+27
-26
lines changed

2 files changed

+27
-26
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Next Release
22
============
33

44
* Your contribution here.
5+
* [#77](https://github.com/intridea/grape-entity/pull/77): Fix compatibility with Rspec 3 - [@justfalter](https://github.com/justfalter).
56

67
0.4.2 (2014-04-03)
78
==================

spec/grape_entity/entity_spec.rb

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ class Parent < Person
422422

423423
it 'adds the collection: true option if called with a collection' do
424424
representation = subject.represent(4.times.map { Object.new })
425-
representation.each { |r| r.options[:collection].should be_true }
425+
representation.each { |r| r.options[:collection].should be true }
426426
end
427427

428428
it 'returns a serialized hash of a single object if serializable: true' do
@@ -909,7 +909,7 @@ class UserEntity < Grape::Entity
909909
rep = subject.send(:value_for, :friends)
910910
rep.should be_kind_of Array
911911
rep.size.should == 2
912-
rep.all? { |r| r.is_a?(EntitySpec::UserEntity) }.should be_true
912+
rep.all? { |r| r.is_a?(EntitySpec::UserEntity) }.should be true
913913
end
914914

915915
it 'class' do
@@ -920,7 +920,7 @@ class UserEntity < Grape::Entity
920920
rep = subject.send(:value_for, :friends)
921921
rep.should be_kind_of Array
922922
rep.size.should == 2
923-
rep.all? { |r| r.is_a?(EntitySpec::UserEntity) }.should be_true
923+
rep.all? { |r| r.is_a?(EntitySpec::UserEntity) }.should be true
924924
end
925925
end
926926
end
@@ -972,54 +972,54 @@ class UserEntity < Grape::Entity
972972
it 'only passes through hash :if exposure if all attributes match' do
973973
exposure_options = { if: { condition1: true, condition2: true } }
974974

975-
subject.send(:conditions_met?, exposure_options, {}).should be_false
976-
subject.send(:conditions_met?, exposure_options, condition1: true).should be_false
977-
subject.send(:conditions_met?, exposure_options, condition1: true, condition2: true).should be_true
978-
subject.send(:conditions_met?, exposure_options, condition1: false, condition2: true).should be_false
979-
subject.send(:conditions_met?, exposure_options, condition1: true, condition2: true, other: true).should be_true
975+
subject.send(:conditions_met?, exposure_options, {}).should be false
976+
subject.send(:conditions_met?, exposure_options, condition1: true).should be false
977+
subject.send(:conditions_met?, exposure_options, condition1: true, condition2: true).should be true
978+
subject.send(:conditions_met?, exposure_options, condition1: false, condition2: true).should be false
979+
subject.send(:conditions_met?, exposure_options, condition1: true, condition2: true, other: true).should be true
980980
end
981981

982982
it 'looks for presence/truthiness if a symbol is passed' do
983983
exposure_options = { if: :condition1 }
984984

985-
subject.send(:conditions_met?, exposure_options, {}).should be_false
986-
subject.send(:conditions_met?, exposure_options, condition1: true).should be_true
987-
subject.send(:conditions_met?, exposure_options, condition1: false).should be_false
988-
subject.send(:conditions_met?, exposure_options, condition1: nil).should be_false
985+
subject.send(:conditions_met?, exposure_options, {}).should be false
986+
subject.send(:conditions_met?, exposure_options, condition1: true).should be true
987+
subject.send(:conditions_met?, exposure_options, condition1: false).should be false
988+
subject.send(:conditions_met?, exposure_options, condition1: nil).should be false
989989
end
990990

991991
it 'looks for absence/falsiness if a symbol is passed' do
992992
exposure_options = { unless: :condition1 }
993993

994-
subject.send(:conditions_met?, exposure_options, {}).should be_true
995-
subject.send(:conditions_met?, exposure_options, condition1: true).should be_false
996-
subject.send(:conditions_met?, exposure_options, condition1: false).should be_true
997-
subject.send(:conditions_met?, exposure_options, condition1: nil).should be_true
994+
subject.send(:conditions_met?, exposure_options, {}).should be true
995+
subject.send(:conditions_met?, exposure_options, condition1: true).should be false
996+
subject.send(:conditions_met?, exposure_options, condition1: false).should be true
997+
subject.send(:conditions_met?, exposure_options, condition1: nil).should be true
998998
end
999999

10001000
it 'only passes through proc :if exposure if it returns truthy value' do
10011001
exposure_options = { if: lambda { |_, opts| opts[:true] } }
10021002

1003-
subject.send(:conditions_met?, exposure_options, true: false).should be_false
1004-
subject.send(:conditions_met?, exposure_options, true: true).should be_true
1003+
subject.send(:conditions_met?, exposure_options, true: false).should be false
1004+
subject.send(:conditions_met?, exposure_options, true: true).should be true
10051005
end
10061006

10071007
it 'only passes through hash :unless exposure if any attributes do not match' do
10081008
exposure_options = { unless: { condition1: true, condition2: true } }
10091009

1010-
subject.send(:conditions_met?, exposure_options, {}).should be_true
1011-
subject.send(:conditions_met?, exposure_options, condition1: true).should be_false
1012-
subject.send(:conditions_met?, exposure_options, condition1: true, condition2: true).should be_false
1013-
subject.send(:conditions_met?, exposure_options, condition1: false, condition2: true).should be_false
1014-
subject.send(:conditions_met?, exposure_options, condition1: true, condition2: true, other: true).should be_false
1015-
subject.send(:conditions_met?, exposure_options, condition1: false, condition2: false).should be_true
1010+
subject.send(:conditions_met?, exposure_options, {}).should be true
1011+
subject.send(:conditions_met?, exposure_options, condition1: true).should be false
1012+
subject.send(:conditions_met?, exposure_options, condition1: true, condition2: true).should be false
1013+
subject.send(:conditions_met?, exposure_options, condition1: false, condition2: true).should be false
1014+
subject.send(:conditions_met?, exposure_options, condition1: true, condition2: true, other: true).should be false
1015+
subject.send(:conditions_met?, exposure_options, condition1: false, condition2: false).should be true
10161016
end
10171017

10181018
it 'only passes through proc :unless exposure if it returns falsy value' do
10191019
exposure_options = { unless: lambda { |_, options| options[:true] == true } }
10201020

1021-
subject.send(:conditions_met?, exposure_options, true: false).should be_true
1022-
subject.send(:conditions_met?, exposure_options, true: true).should be_false
1021+
subject.send(:conditions_met?, exposure_options, true: false).should be true
1022+
subject.send(:conditions_met?, exposure_options, true: true).should be false
10231023
end
10241024
end
10251025

0 commit comments

Comments
 (0)