kschiess / parslet

A small PEG based parser library. See the Hacking page in the Wiki as well.
kschiess.github.com/parslet
MIT License
809 stars 95 forks source link

make the rspec rig work for rspec 2.99 #138

Closed maxjacobson closed 8 years ago

maxjacobson commented 9 years ago

Hello!

Thanks for this wonderful project

I'm currently upgrading my app from RSpec 2.14 to the latest. The upgrade guide recommends first upgrading to 2.99, then resolving all deprecation warnings, and then upgrading to 3.

Strangely, the rspec rig works great on 2.14 and 3.3, but fails on 2.99 with:

NameError:
  undefined method `failure_message_for_should' for class `Class'
adammiribyan commented 9 years ago

:+1:

maxjacobson commented 9 years ago

@adammiribyan lol hey Adam

kschiess commented 9 years ago

Hey, I am getting these errors using your code:

2.14, in pattern_spec.rb

undefined method `alias_method' for #<RSpec::Matchers::DSL::Matcher:

2.99, also in pattern_spec.rb

undefined method `failure_message' for class `RSpec::Matchers::DifferentiateBlockMethodTypes'

If you could fix these as well, I would incline towards merging this. Note that rspec is on it's way out - I think it has bad management - so in the long run, this is futile work.

Why do you need the development gems from parslet to get your application to work?

maxjacobson commented 9 years ago

I think an appropriate way to resolve those failures would be to specify a version of rspec used for testing the parslet source code. Because it doesn't, and I cloned the repo and bundled, it pulled the latest version of rspec (v3.3.0) where the tests are green. I updated the commit to add that version expectation. I think it's safe to fix the version of rspec used to test parslet in place and gracious to support multiple versions of rspec for the parslet-wielding developer

maxjacobson commented 9 years ago

Ah, just read your last sentence. Sorry for the ambiguity. It's not that I need parslet's development gems in my application, it's that while upgrading the version of rspec I'm using in my application, my parser tests started failing due to the rspec rig not being fully compatible with rspec 2.99.

So if you imagine this is my application: https://github.com/maxjacobson/parslet_failure_demo/tree/rspec-2.14

I'm happily working on my parser with passing tests. And then I hear about how cool RSpec 3.3 is and I want to upgrade. The official upgrade guide recommends first upgrading to RSpec 2.99 to resolve any deprecation warnings. I try doing that: https://github.com/maxjacobson/parslet_failure_demo and my tests start failing like this:

Failures:

  1) MyParser works
     Failure/Error: expect(parser).to parse("hello").as("hello")
     NameError:
       undefined method `failure_message_for_should' for class `Class'
     # ./spec/parser_spec.rb:4:in `block (2 levels) in <top (required)>'

so now I'm kind of stuck because the matcher is failing, and I'm unable to continue upgrading

This PR should resolve that issue

kschiess commented 9 years ago

Yeah - I can see where we crossed paths here in our discussion. Thinking about this some more, the challenge for me is to keep these rspec matchers working throughout the releases - which I cannot if the test suite doesn't pass for all target versions.

I've half a mind to extract the rspec suite to it's own gem and isolate myself from this madness once and for all...

I hope you understand that I don't want to run parslet's tests only in >3 for the time being. What we need is either extraction or a fix to the above problems.