Improve your Twirp code with RuboCop
gem install rubocop-twirp
Add to your Gemfile
gem "rubocop-twirp", require: false
Add to .rubocop.yml
require: rubocop-twirp
Scan and fix issues
rubocop -r rubocop-twirp --only Twirp -A
Fix Twirp::ClientResp
breaking change introduced in Twirp v1.10. (Cop disabled by default)
rubocop -r rubocop-twirp --only Twirp/DeprecatedArguments -A
Use webmock-twirp to stub Twirp client responses.
# bad
allow(MyTwirpClient).to receive(:my_rpc).and_return(Twirp::ClientResp.new(...))
# good
stub_twirp_request(MyTwirpClient, :my_rpc).to_return(...)
Checks that Twirp::ClientResp uses keyword arguments instead of positional arguments. Needed for Twirp >= 1.10
# bad
Twirp::ClientResp.new(data, error)
# good
Twirp::ClientResp.new(data: data, error: error)
Use rspec-twirp to simplify specs.
# bad
expect(...).to be_a(Twirp::ClientResp)
expect(...).to be_a(Twirp::Error)
# good
expect(...).to be_a_twirp_response
expect(...).to be_a_twirp_error
Yes please :)
- Fork it
- Create your feature branch (
git checkout -b my-feature
) - Ensure the tests pass (
bundle exec rspec
) - Commit your changes (
git commit -am 'awesome new feature'
) - Push your branch (
git push origin my-feature
) - Create a Pull Request