Cucumber is one of the cornerstone for BDD in Ruby on Rails. Non technical or business participants can write tests (called as features or stories) in plain English and cucumber allows the developers to execute these tests.
I was very excited when I started looking at it. In my test.feature file, I have a feature:
Feature: Grant and revoke access
To have proper security model
User should have proper access
Scenario: Revoke access of a user who do not deserves access
Given Gourav is a user who do not deserves access
When system run cron job to verify access
Then Gourav's access should be revoked
I went to open source community and worked little bit on issue #81 (first encounter with Opensource community :) ) and found troubleshooting for this issue. Now "rake features" works well and give proper output.
2. Cucumber as a gem:
I was very excited when I started looking at it. In my test.feature file, I have a feature:
Feature: Grant and revoke access
To have proper security model
User should have proper access
Scenario: Revoke access of a user who do not deserves access
Given Gourav is a user who do not deserves access
When system run cron job to verify access
Then Gourav's access should be revoked
There are two ways to execute this file:
1. Cucumber as a plugin (by rake task):
It starts eating 'a' and 'A' characters on windows:
Feture: Grnt nd revoke ccess # fetures/grnt_nd_revoke_ccess.feture
To hve proper security model
User should hve proper ccess
Scenrio: Revoke ccess of user who do not deserves ccess # fetures/test.feture:5
Given Gourv is user who do not deserves ccess # fetures/test.feture:6
When system run cron job to verify ccess # fetures/test.feture:9
Then Gourv's ccess should be revoked # fetures/test.feture:10
I went to open source community and worked little bit on issue #81 (first encounter with Opensource community :) ) and found troubleshooting for this issue. Now "rake features" works well and give proper output.
2. Cucumber as a gem:
cucumber features\test.feature It gives:Feature: Grant and revoke access # features/test.feature
To have proper security model
User should have proper access
Scenario: Revoke access of a user who do not deserves accessC:/ruby/lib/ruby/gems/1.8/
gems/cucumber-0.1.12/bin/../lib/cucumber/tree/scenario.rb:70:in length': undefined methodjlength' for Scenario ng (NoMethodError)
from C:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.1.12/bin/../lib/cucumber/tree/scenario.rb:74:in `max_line_length'
from C:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.1.12/bin/../lib/cucumber/tree/scenario.rb:78:in `padding_length'
from C:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.1.12/bin/../lib/cucumber/formatters/pretty_formatter.rb:197:in `padding_spaces'
from C:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.1.12/bin/../lib/cucumber/formatters/pretty_formatter.rb:58:in `scenario_executing'
from C:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.1.12/bin/../lib/cucumber/broadcaster.rb:15:in `__send__'
from C:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.1.12/bin/../lib/cucumber/broadcaster.rb:15:in `method_missing'
from C:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.1.12/bin/../lib/cucumber/broadcaster.rb:13:in `each'
from C:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.1.12/bin/../lib/cucumber/broadcaster.rb:13:in `method_missing'
... 12 levels...
from C:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.1.12/bin/../lib/cucumber/cli.rb:11:in `execute'
from C:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.1.12/bin/cucumber:6
from C:/ruby/bin/cucumber:19:in `load'
from C:/ruby/bin/cucumber:19
I found a workaround for this:
In file C:\ruby\lib\ruby\gems\1.8\gems\cucumber-0.1.12\lib\cucumber\tree\Scenario.rb on line number 69, I have changed jlength to length:
@length ||= Cucumber.language['scenario'].length + 2 + (@name.nil? ? 0 : @name.length)
Similarly, in file C:\ruby\lib\ruby\gems\1.8\gems\cucumber-0.1.12\lib\cucumber\tree\step.rb on line number 22 I have changed jlength to length:
keyword.length + 1 + name.length
But for a better solution I am still working on issue #81
0 comments:
Post a Comment