Sha256: e34260c92c6ebffa17ecbab8f9f38fb7110f7ea6ca89a74b4f32be513cf83d20

Contents?: true

Size: 530 Bytes

Versions: 1

Compression:

Stored size: 530 Bytes

Contents

RSpec::Matchers.define :be_filtered_by do |filtered_attribute, json_value=nil|
  match do |items|
    if filtered_attribute.nil?
      true
    else
      items.all?{|item| item[filtered_attribute.to_s].to_s == json_value}
    end
  end

  description do
    if filtered_attribute.nil?
      %Q(not be filtered by any specific attribute)
    else
      %Q(be filtered by #{filtered_attribute.to_json} => #{json_value})
    end
  end

  failure_message_for_should do |items|
    %Q(should #{description}, but is #{items})
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-api-0.1.0 lib/rspec-api/matchers/filter.rb