Skip to content

Fix be_routable description -- Defines BeRoutableMatcher#description #1310

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

Merged
merged 2 commits into from
Feb 14, 2015

Conversation

tonyta
Copy link
Contributor

@tonyta tonyta commented Feb 13, 2015

Alternate implementation of #1307
Thanks for the feedback @JonRowe @cupakromer! 😹

Problem
Previously, using be_routable in a one-liner...

RSpec.describe 'a not-routable route', type: :routing do
  let(:sad_route) { '/this/route/makes/me/sad' }
  specify { expect(get: sad_route).not_to be_routable }
end

...will output the following:

a not-routable route
  should not be routable matcher

BaseMatcher#description turns BeRoutableMatcher into "be routable matcher".

Solution
BeRoutableMatcher#description is defined to override BaseMatcher#description...

class BeRoutableMatcher < RSpec::Matchers::BuiltIn::BaseMatcher
  # ...
  def description
    "be routable"
  end
end

...to correctly output:

a not-routable route
  should not be routable

overrides RSpec::Matchers::BuiltIn::BaseMatcher#description to
return the description "be routable" instead of "be routable matcher"
@JonRowe
Copy link
Member

JonRowe commented Feb 14, 2015

Thanks @tonyta

JonRowe added a commit that referenced this pull request Feb 14, 2015
Fix `be_routable` description -- Defines BeRoutableMatcher#description
@JonRowe JonRowe merged commit 67c6bac into rspec:master Feb 14, 2015
JonRowe added a commit that referenced this pull request Feb 14, 2015
@tonyta
Copy link
Contributor Author

tonyta commented Feb 14, 2015

Thanks, @JonRowe! Happy to help! 🐙

JonRowe added a commit that referenced this pull request Feb 21, 2015
cupakromer added a commit that referenced this pull request Feb 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants