New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize specs #54

Merged
merged 12 commits into from Sep 6, 2016

Conversation

Projects
None yet
2 participants
@ivoanjo
Copy link
Contributor

ivoanjo commented Aug 29, 2016

This PR includes a number of improvements and fixes to hal-client's specs.

It:

  • Upgrades rspec to the latest version
  • Changes specs that were still using an older syntax and/or depended on rspec's monkey patches
  • Enables auto-require of the spec_helper
  • Adds the current recommended rspec defaults to spec_helper
  • Enables ruby warnings during spec execution
  • Fixes the ruby warnings uncovered

...and bumps hal-client to 3.16.1.

Why? I'm working on a project that makes use of hal-client and where we run our specs with warnings enabled, and I'm looking to fix warnings from our dependencies so we can have a clean spec execution with warnings enabled. The other fixes... I was in the neighbourhood ;)

Thanks for your awesome work on hal-client!

ivoanjo added some commits Aug 29, 2016

Modernize spec syntax using transpec
Ran transpec to replace legacy rspec syntax with the
currently-recommended one.

All specs still green.
Add .rspec config file that automatically requires the spec_helper
Using .rspec to require the spec_helper avoids needing to remember to
require the file on all specs.

Also added the --color option as a default to output the spec execution
in color.
Merge existing spec_helper with latest recommended rspec defaults
Re-ran rspec --init (by first renaming the existing spec_helper.rb) and
merged the resulting spec_helper.rb with the old one.

This adds a number of modern configs, two of which (no monkey patching,
and enable ruby warnings) I still left disabled for now --- will address
in the coming commits.
Enable rspec's disable_monkey_patching! option
To avoid the need for monkey patching, top-level describes must be
prefixed with the RSpec module (e.g. RSpec.describe).

This change allows rspec to run without any need for monkey patching the
ruby runtime objects, resulting in a cleaner, less error-prone spec
execution environment.
Fix "method redefined; discarding old default_entity_request_headers"…
… warning

There is already in line 245 an attr_reader declared for
default_entity_request_headers, thus having a method for doing it is not
needed.
Extract default procs to avoid warnings and re-allocation
The default_procs used in representation.rb and links_section.rb caused
a "shadowing outer local variable - link_rel" warning, but instead of
simply renaming their variable I instead decided to extract them to
constants, simplifying the methods that used them and avoiding the
constant re-allocation of the same procs.

@pezra pezra merged commit 162ae16 into pezra:master Sep 6, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@pezra

This comment has been minimized.

Copy link
Owner

pezra commented Sep 6, 2016

👍 thanks for the improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment