File tree Expand file tree Collapse file tree 4 files changed +15
-4
lines changed Expand file tree Collapse file tree 4 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 11PATH
22 remote: .
33 specs:
4- rspec-api-matchers (0.6.2 )
4+ rspec-api-matchers (0.6.3 )
55 activesupport
66 rack
77 rspec
Original file line number Diff line number Diff line change @@ -45,7 +45,13 @@ def has_one_object?
4545
4646 def is_filtered?
4747 values = json . map { |item | item [ field ] }
48- values . all? { |v | v . send compare_with , value }
48+ values . all? do |v |
49+ if compare_with . is_a? ( Proc )
50+ compare_with . call value , v
51+ elsif compare_with . is_a? ( Symbol )
52+ v . send compare_with , value
53+ end
54+ end
4955 end
5056
5157 def reverse?
Original file line number Diff line number Diff line change 11module RSpecApi
22 module Matchers
3- VERSION = '0.6.2 '
3+ VERSION = '0.6.3 '
44 end
55end
Original file line number Diff line number Diff line change 3333 context 'given a JSON collection with 2 items with id < 5' do
3434 before { response . body = '[{"id":2},{"id":3,"name":"two"}]' }
3535
36- it 'passes given the right comparison method' do
36+ it 'passes given the right comparison method (symbol) ' do
3737 expect ( response ) . to be_filtered by : :id , value : 5 , compare_with : :<
3838 end
3939
40+ it 'passes given the right comparison method (proc)' do
41+ cmp = -> expected , actual { actual < expected }
42+ expect ( response ) . to be_filtered by : :id , value : 5 , compare_with : cmp
43+ end
44+
4045 it 'fails given the wrong comparison method' do
4146 expect {
4247 expect ( response ) . to be_filtered by : :id , value : 5 , compare_with : :>
You can’t perform that action at this time.
0 commit comments