[rspec-users] given-when-then-and syntax support in Rspec
dchelimsky at gmail.com
Sun Mar 27 05:55:21 EDT 2011
On Mar 26, 2011, at 9:43 PM, Rodrigo Rosenfeld Rosas wrote:
> Hi David and fellows,
> I know this subject has already been discussed here and there are already some attempts to support the given-when-then-and syntax in Rspec, like the links below:
> First, I don't understand the reason to adopt the capital method names Given/When/Then/And instead of given/when/then/and.
'when', 'then', and 'and' are all Ruby keywords. You can define them as methods, but unpleasant things happen.
> Then, I don't think we can call this some real support for that syntax because "example" is not meant to be executed in any special order in Rspec nor it can be defined that any additional "then/and" should be aborted if a prior expectation wasn't met. And both solutions seem to work by simple aliasing "example" and "describe".
> I never used Cucumber because I find that working with it is cumbersome for most cases.
> I've been working mostly with Grails on my daily job for about 2 years now since I moved to my current job. I wanted something like Rspec for Groovy and Grails and while searching for some alternative, I found EasyB:
> Actually I liked the story syntax they provide as well as the reports and I found it would be useful for Rspec to incorporate that style too:
> What do you think?
Adding first class support for feature/scenario/given/when/then would be a fundamental change to rspec-core, requiring much more than simply exposing new syntax. We'd need new formatters, new ways to define shared code, new command line options, etc, etc. I think this would require too much work, and make the libraries more complicated to use and maintain.
I like the direction that rspec-given takes us: an extension library on top of RSpec. As you point out, it could be made more valuable by adding rich concepts like "steps" that are different from "examples", but I think that could be done within the context of rspec-given (or any other extension), and I'd gladly consider adding new extension points that would make that job easier.
> Best regards!
More information about the rspec-users