File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ def matches?(record)
1919 expectation_method = inverted ? :any? : :all?
2020
2121 constraints . send ( expectation_method ) do |attribute , expected |
22- value = record . public_send ( attribute )
22+ value = record [ attribute ]
2323
2424 matches_value? ( value , expected )
2525 end
@@ -41,4 +41,4 @@ def matches_value?(value, comparison)
4141 def normalize ( value )
4242 value . respond_to? ( :to_s ) ? value . to_s : value
4343 end
44- end
44+ end
Original file line number Diff line number Diff line change 5050 expect ( array . size ) . to eq ( 2 )
5151 end
5252 end
53+
54+ describe "colliding methods" do
55+ it "should handle attributes named after existing methods" do
56+ klass = Class . new ( ActiveHash ::Base ) do
57+ self . data = [
58+ {
59+ id : 1 ,
60+ name : "Aaa" ,
61+ display : true ,
62+ } ,
63+ {
64+ id : 2 ,
65+ name : "Bbb" ,
66+ display : false ,
67+ } ,
68+ ]
69+ end
70+ expect ( klass . where ( display : true ) . length ) . to eq ( 1 )
71+ end
72+ end
5373end
You can’t perform that action at this time.
0 commit comments