-
Notifications
You must be signed in to change notification settings - Fork 220
Improve parser testing support #3
Comments
What do you think is hacky about it? I think a mock based approach where we expect certain events is good. Do you see any problems with that approach or are you referring to how it's currently implemented with the spec's #scan method? (I think that can be improved). |
The spec's #scan method. It can be removed in favor of a before block that sets up @Listener and @table. I was also thinking of writing some custom matchers for use with the listener to enable writing specs like
or something like that, but that might be more trouble than it's worth. |
Let's wait with custom matchers until we see some repetitive patterns that can't be solved nicely without matchers. For features it could be something along the lines of:
Think that could work? |
For sure! That's close to what's in feature_spec.rb right now as it is. I'll move everything over to that and push later tonight. |
Mike, can we close this now? |
I'm looking into creating a TestListener that outputs something like to_sexp does in cucumber. As the feature files we're parsing get longer, I'm finding it harder to correctly ensure proper message reception and counts, particularly in regards to ordering and ensuring only a single message reception. I'd like to be able to do something like:
by simply appending all calls to the TestListener to a list in the order they're received. It would allow for simple assertions, and provide far better output than the current method when the assertion fails (e.g. "Mock 'listener' received :feature out of order" doesn't really tell me much about how the rest of the parsing went). It would, however, provide a level of indirection between the behavior of the parser and the expectations on the interface of the listener. What do you think? |
I love that idea. Instead of calling it TestListener, maybe we could call it SexpRecorder? It could serve two purposes: Testing and documentation of the Listener API. (It would only have one non-API method: #to_sexp) |
Come to think of it - it might be easier to implement SexpRecorder with #method_missing, which would render it useless as documentation ;-) (We could always write a different reference implementation. Maybe a pretty printer or something) |
I was screwing around with Google AppEngine last night and whipped this up: http://gherkintest.appspot.com. Pretty useless as it currently stands, but the code does contain an UglyPrinter that perhaps we could use as a basis for a reference implementation. :-) |
OK, I just pushed an implementation of a simple SexpRecorder and wrote one spec using it. I'm a bit busy working on a presentation I have tomorrow, so I won't be converting any of the existing specs... |
Oooh nice! Is the code open source? |
It will be tonight. :-) I used the google-appengine gem, and while it's super-easy to get started, I need to figure out how to create a git repo for a google app without all the extra generated stuff before pushing it to github. |
Perfect! Thanks. I'll close this issue. I'll work through converting the existing specs as I revisit them. Shouldn't take too long. |
The current parser testing is a hack pretty much all around. What we have for table parsing works well enough, but I'm not sure it's going to cut it for full-blown feature file parsing.
The text was updated successfully, but these errors were encountered: