Phlip
April 25, 2009, 6:09am
1
Cucumberists:
The sample code:
require ‘treetop’
require ‘cucumber’
require ‘cucumber/parser’
require ‘cucumber/parser/treetop_ext’
too many requires because fishing around!
include Cucumber
include Parser
include Feature
@parser = FeatureParser.new
exp = @parser.parse_or_fail (%{# My comment
Feature: hi
})
The error message:
NameError: undefined local variable or method
_nt_scenario_outline_keyword' for #<Cucumber::Parser::FeatureParser:0xb6f3f67c> cucumber (0.3.0) lib/cucumber/parser/feature.rb:855:in
_nt_scenario_outline’
cucumber (0.3.0) lib/cucumber/parser/feature.rb:106:in
_nt_feature' cucumber (0.3.0) lib/cucumber/parser/feature.rb:102:in
loop’
…
Okay, how do I just whip out the parser and have it parse raw Cuke code?
–
Phlip
Resume for Philip C Plumlee
Phlip
April 25, 2009, 10:44am
2
On Sat, Apr 25, 2009 at 6:07 AM, Phlip [email protected] wrote:
include Cucumber
NameError: undefined local variable or method
_nt_scenario_outline_keyword' for #<Cucumber::Parser::FeatureParser:0xb6f3f67c> cucumber (0.3.0) lib/cucumber/parser/feature.rb:855:in
_nt_scenario_outline’
cucumber (0.3.0) lib/cucumber/parser/feature.rb:106:in _nt_feature' cucumber (0.3.0) lib/cucumber/parser/feature.rb:102:in
loop’
…
Okay, how do I just whip out the parser and have it parse raw Cuke code?
Try this:
require ‘cucumber’
Cucumber.load_language(‘en’)
p = Cucumber::Parser::FeatureParser.new
f = p.parse_or_fail <<-EOF
Feature: Foo
Scenario: Bar
Given Zap
EOF
Aslak
Phlip
April 25, 2009, 1:05pm
3
aslak hellesoy wrote:
EOF
Aslak
Nope! Exact same error. Should I get the bench version? (It’s 0.3.0
now.)
–
Phlip
http://flea.sourceforge.net/resume.html
Phlip
April 25, 2009, 1:11pm
4
Phlip wrote:
Scenario: Bar
Given Zap
EOF
Aslak
Nope! Exact same error. Should I get the bench version? (It’s 0.3.0 now.)
That sample works in a standalone script, and does not work in a Rails
unit test:
require File.dirname(FILE ) + ‘/…/test_helper’
class CukeFeatureParser < ActiveSupport::TestCase
def test_parser
require ‘cucumber’
Cucumber.load_language(‘en’)
p = Cucumber::Parser::FeatureParser.new
f = p.parse_or_fail <<-EOF
Feature: Foo
Scenario: Bar
Given Zap
EOF
end
end
–
Phlip
http://flea.sourceforge.net/resume.html
Phlip
April 25, 2009, 6:12pm
5
Aslak Hellesøy wrote:
f = p.parse_or_fail <<-EOF
Feature: Foo
Scenario: Bar
Given Zap
EOF
end
end
Please explain how it doesn’t work. Output, error etc.
Same as before:
$ ruby test/unit/cuke_test.rb
Loaded suite test/unit/cuke_test
Started
E
Finished in 0.127149 seconds.
Error:
test_parser(CukeFeatureParser):
NameError: undefined local variable or method
_nt_scenario_outline_keyword' for #<Cucumber::Parser::FeatureParser:0xb728ecc4> cucumber (0.3.0) lib/cucumber/parser/feature.rb:855:in
_nt_scenario_outline’
cucumber (0.3.0) lib/cucumber/parser/feature.rb:106:in
_nt_feature' cucumber (0.3.0) lib/cucumber/parser/feature.rb:102:in
loop’
cucumber (0.3.0) lib/cucumber/parser/feature.rb:102:in
_nt_feature' treetop (1.2.5) lib/treetop/runtime/compiled_parser.rb:18:in
send’
treetop (1.2.5) lib/treetop/runtime/compiled_parser.rb:18:in
parse' cucumber (0.3.0) lib/cucumber/parser/treetop_ext.rb:79:in
parse_or_fail’
test/unit/cuke_test.rb:12:in `test_parser’
1 tests, 0 assertions, 0 failures, 1 errors
–
Phlip
http://flea.sourceforge.net/resume.html
Phlip
April 25, 2009, 3:00pm
6
Den 25. april. 2009 kl. 13.10 skrev Phlip [email protected] :
Scenario: Bar
require File.dirname(FILE ) + ‘/…/test_helper’
Feature: Foo
Scenario: Bar
Given Zap
EOF
end
end
Please explain how it doesn’t work. Output, error etc.
Aslak
Phlip
April 27, 2009, 8:58am
7
On Sat, Apr 25, 2009 at 5:00 PM, Phlip [email protected] wrote:
Cucumber.load_language(‘en’)
Error:
test_parser(CukeFeatureParser):
NameError: undefined local variable or method `_nt_scenario_outline_keyword’
The #_nt_scenario_outline_keyword method comes from Ruby code that is
dynamically generated by Treetop while parsing the i18n.tt file. The
i18n.tt file parsed when you call Cucumber.load_parser (which
substitutes i18n keywords before passing it to Treetop). I’m not sure
what’s going on with your code.
It works for me - also in a Rails environment:
http://github.com/aslakhellesoy/cucumber_rails/commit/78b36a704279fab7e7ad47ccc3825916e5e9622c
What happens when you run the test I added here?
Aslak
Phlip
April 28, 2009, 3:58pm
8
Bump?
Please explain how it doesn’t work. Output, error etc.
Same as before:
I also get it from a rspec-rails case…
Phlip
April 28, 2009, 4:31pm
10
On Tue, Apr 28, 2009 at 8:56 AM, Phlip [email protected] wrote:
Bump?
Please explain how it doesn’t work. Output, error etc.
Same as before:
I also get it from a rspec-rails case…
Huh? What does this have to do w/ rspec-rails? This thread is about a
NameError on _nt_scenario_outline_keyword.
Phlip
April 29, 2009, 1:35pm
11
Just one comment - I went down this path a bit, and ended up finding
it drastically easier to write a custom formatter.
Take a look at
http://wiki.github.com/aslakhellesoy/cucumber/custom-formatters
I’m sure there are places where you’d want to call the parser
directly; but everything I needed to do was handled more easily by
writing a formatter and catching the events I care about.
On Sat, Apr 25, 2009 at 2:07 PM, Phlip [email protected] wrote:
include Cucumber
NameError: undefined local variable or method `_nt_scenario_outline_keyword’
Phlip
http://flea.sourceforge.net/resume.html
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users
–
Kornelis Sietsma korny at my surname dot com
“Every jumbled pile of person has a thinking part
that wonders what the part that isn’t thinking
isn’t thinking of”