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

Already on GitHub? Sign in to your account

change generated descriptions from "should xxx" to "is xxx" or "does xxx" #171

Closed
dchelimsky opened this Issue Sep 8, 2012 · 5 comments

Comments

Projects
None yet
3 participants
Owner

dchelimsky commented Sep 8, 2012

No description provided.

Contributor

alindeman commented Sep 11, 2012

Did you take care of this in rspec-rails already?

Owner

dchelimsky commented Sep 12, 2012

@alindeman no - unfortunately this requires a fundamental change to rspec-expectations, which currently builds messages by prepending "should" or "should not" to the matcher's description (.e.g "eq 37"). I think that we'll need to support some sort of check when generating messages in order to make this work without breaking output from 3rd party matchers e.g.

    def self.generated_description
      return nil if last_should.nil?
      if last_matcher.respond_to?(:descriptions)
        last_matcher.descriptions[last_should =~ /not/ ? :negative : :positive]
      else
        "#{last_should.to_s.gsub('_',' ')} #{last_description}"
      end
    end

It's a micro perf hit to add another check to every matcher, but this would only be necessary for one-liners and only for doc formats, so you wouldn't see it w/ dots. Seem reasonable?

Owner

dchelimsky commented Sep 12, 2012

I posted a first cut of this (only changing the eq matcher) to the update-generated-descriptions branch. @myronmarston, @alindeman, @patmaddox, @spicycode please feel free to peek/comment.

Owner

myronmarston commented Sep 12, 2012

Isn't this what pull request #71 does? Maybe we should look into integrating that.

Owner

dchelimsky commented Sep 12, 2012

@myronmarston forgot about that - yes #71 does the job.

@dchelimsky dchelimsky closed this Sep 12, 2012

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