Comments (2)
For now, the simplest way to do this is to factor your Scenario into a method (yes, you can do this ;-) ) that accept parameters.
For example, it is perfectly legal to do this:
def canned_scenario_with_args(params = {})
Scenario "My canned senario" do
Given "A given parameter like #{params[:first_given]}" do
....
end
When "An event parameter like #{params[:first_when]}" do
....
end
Then "An expectation parameter like #{params[:first_then]}" do
....
end
end
end
Want to get whackier? It's perfectly legitimate to pass Procs in Hashes. So, occasionally, I wrote my Coulda tests but inject even more behavior instead of just data. The only downside I find is that the backtrace can become a bit difficult to untangle at times.
def canned_scenario_with_args(params = {})
Scenario "My canned senario" do
Given "A given parameter like #{params[:first_given]}" do
...
eval(params[:first_given])
...
end
When "An event parameter like #{params[:first_when]}" do
...
eval(params[:first_when])
...
end
Then "An expectation parameter like #{params[:first_then]}" do
...
eval(params[:first_then])
...
end
end
end
canned_scenario_with_args(
:first_given => lambda {
...
},
:first_when => lambda {
...
},
:first_then => lambda {
...
}
)
To the original point, I'm not averse to using FIT-like tables with Coulda. However, I am hesitant to introduce them into Coulda directly. I prefer an ecology of tools that play well together versus a single monolithic tool that tries to be everything to everyone. I've discussed with a few people, at times, extracting FIT-like table support from Cucumber in such a way that it would be reusable within arbitrary Ruby code including Coulda.
However, adding Scenario Outlines would likely require tighter integration.
from coulda.
FWIW, I've been using Coulda regularly in my consulting. I often extract steps (Given, When, etc.) out into methods that are sometimes reusable across Features. And, yes, I do the same thing within a single Feature as well for Scenarios.
Unlike Cucumber, Coulda is just Ruby. It's important to remember that. You have access to the full Ruby language instead of a coupling of a Turing incomplete programming language (Gherkin) with Ruby.
from coulda.
Related Issues (15)
- Macros are not visible during semantic validation HOT 2
- There isn't any tutorial or guide HOT 2
- Allow for steps to accept a symbol HOT 6
- Reuse through instance methods in a Feature currently fails HOT 4
- Add support for Rails Integration tests HOT 1
- rspec integration test with coulda HOT 2
- Global 'after' is needed to restart time.
- Do you have a recomendation on how to emulate cucumber tags in a coulda environment HOT 3
- Run a specific scenario within a test HOT 2
- Pending scenarios should indicate that they are pending HOT 2
- Getting an odd error when using this code
- Pending scenarios aren't currently showing up as pending.
- step failure should indicate the name of the step failed
- 0.7.1 Has broken all of my tests HOT 1
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 coulda.