No commit activity in last 3 years
No release in over 3 years
Array of hashes matcher.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.16
~> 10.0

Runtime

 Project Readme

rspec-match_table

It is array of hashes matcher.

Gem Version Build Status

Installation

Add this line to your application's Gemfile:

gem 'rspec-match_table'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rspec-match_table

Usage

require 'rspec/match_table'

RSpec.describe do
  specify do
  context 'when not match' do
    specify do
      expect(
        [
          {foo: 'bar', 100 => :zoo,  '100' => 100},
          {bar: 'foo', 200 => :baz,  '200' => 200},
          {baz: 'bar', 300 => 'foo', '300' => 300},
        ]
      ).to match_table( # or match_table_without_order
        [
          {foo: 'bar', 100 => :zoo,  '100' => 100},
          {bar: 'foo', 200 => 'baz', '200' => 200},
          {baz: 'bar', 300 => 'foo', '300' => 301},
        ]
      )
      #=> Failure/Error:
      #     expect(
      #       [
      #         {foo: 'bar', 100 => :zoo,  '100' => 100},
      #         {bar: 'foo', 200 => :baz,  '200' => 200},
      #         {baz: 'bar', 300 => 'foo', '300' => 300},
      #       ]
      #     ).to match_table(
      #       [
      #         {foo: 'bar', 100 => :zoo,  '100' => 100},
      #         {bar: 'foo', 200 => 'baz', '200' => 200},
      #
      #     expected: [{:foo=>"bar", 100=>:zoo, "100"=>100}, {:bar=>"foo", 200=>"baz", "200"=>200}, {:baz=>"bar", 300=>"foo", "300"=>301}]
      #          got: [{:foo=>"bar", 100=>:zoo, "100"=>100}, {:bar=>"foo", 200=>:baz, "200"=>200}, {:baz=>"bar", 300=>"foo", "300"=>300}]
      #
      #     Diff:
      #     @@ -1,4 +1,4 @@
      #      [{100=>:zoo, "100"=>100, :foo=>"bar"},
      #     - {200=>"baz", "200"=>200, :bar=>"foo"},
      #     - {300=>"foo", "300"=>301, :baz=>"bar"}]
      #     + {200=>:baz, "200"=>200, :bar=>"foo"},
      #     + {300=>"foo", "300"=>300, :baz=>"bar"}]
    end
  end
end