Comments (13)
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).
from gherkin2.
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
parsing("|a|b|\n").should find(3).rows
parsing("Feature: foo").should find_feature("foo")
or something like that, but that might be more trouble than it's worth.
from gherkin2.
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:
@listener.should_receive(:feature).with("Feature", "foo")
@listener.should_receive(:scenario).with("Scenario", "bar")
@listener.should_receive(:step).with("Given", "bar")
@parser.parse("Feature: foo\nScenario: bar\nGiven bar")
Think that could work?
from gherkin2.
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.
from gherkin2.
Mike, can we close this now?
from gherkin2.
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:
@listener.messages.should == [
[:feature, "Feature", "This is a feature\n With multiple lines", 1],
[:comment, "This is a comment", 3],
[:scenario, "Scenario", "This is a scenario, 4]]
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?
from gherkin2.
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)
from gherkin2.
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)
from gherkin2.
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. :-)
from gherkin2.
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...
from gherkin2.
Oooh nice! Is the code open source?
from gherkin2.
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.
from gherkin2.
Perfect! Thanks. I'll close this issue. I'll work through converting the existing specs as I revisit them. Shouldn't take too long.
from gherkin2.
Related Issues (20)
- JS JSONFormatter - No way to attach an embedding without base64 encoding HOT 2
- Unable to compile
- Support i18n in snippet generation HOT 4
- cannot load such file -- 2.1/gherkin_lexer_en HOT 10
- [Java] Ugly formatting for CJK data containing full-width characters
- [Suggestion] Delete merged branches from the repo
- [Ruby] Backslashes in tables HOT 1
- SyntaxError in output HOT 1
- Background.feature is nil (in Cucumber 2.0) HOT 1
- Couldn't load 2.1/gherkin_lexer_en HOT 3
- Scenerios should be randomized across feature files, not just within a feature file HOT 2
- NPE in JSONFormatter in scenario print in a @Before HOT 1
- Getting Lexing Error HOT 5
- Cucumber generating empty JSON file upon multiple feature failures. HOT 1
- cucumber for java: number format exception when using tag with semicolon in name HOT 5
- allow tagging individual outline examples HOT 1
- Request for new release HOT 3
- Pretty formatter cannot handle comments in feature correctly
- Source files without license headers HOT 4
- NullPointerException when 'type' property is missing HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gherkin2.