0.02
No release in over a year
RSpec matchers for Protobuf
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

rspec-protobuf

Gem codecov

RSpec matchers for Protobuf.

require "rspec/protobuf"

subject { MyProtoMessage.new(msg: "hi") }

it { is_expected.to be_a_protobuf }

# check type
it { is_expected.to be_a_protobuf(MyProtoMessage) }

# check field values
it { is_expected.to be_a_protobuf(msg: "hi") }
it { is_expected.to be_a_protobuf(msg: /^h/) }

# composite matching
it { expect(result).to include(data: a_protobuf(MyProtoMessage, msg: starting_with("h"))) }

Improved RSpec Errors

Before

Failure/Error: is_expected.to have_attributes(date: { month: 2 })
     expected <ComplexMessage: complex: false, date: <DateMessage: type: :DATE_DEFAULT, month: 1, day: 0, year: 0>> to have attributes {:date => {:month => 2}} but had attributes {:date => <DateMessage: type: :DATE_DEFAULT, month: 1, day: 0, year: 0>}
     Diff:
     @@ -1 +1 @@
     -:date => {:month=>2},
     +:date => <DateMessage: type: :DATE_DEFAULT, month: 1, day: 0, year: 0>,

After

Failure/Error: is_expected.to be_a_protobuf(date: { month: 2 })
     Diff:
     @@ -1 +1 @@
     -:date => {:month=>2},
     +:date => {:month=>1},

Contributing

Yes please :)

  1. Fork it
  2. Create your feature branch (git checkout -b my-feature)
  3. Ensure the tests pass (bundle exec rspec)
  4. Commit your changes (git commit -am 'awesome new feature')
  5. Push your branch (git push origin my-feature)
  6. Create a Pull Request