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 http://flea.sourceforge.net/resume.html
aslak hellesoy wrote:> 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 > > AslakNope! Exact same error. Should I get the bench version? (It''s 0.3.0 now.) -- Phlip http://flea.sourceforge.net/resume.html
Phlip wrote:> aslak hellesoy wrote: > >> 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 > > 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
Aslak Hellesøy
2009-Apr-25 12:51 UTC
[rspec-users] [Cucumber] call the (Treetop?) parser directly?
Den 25. april. 2009 kl. 13.10 skrev Phlip <phlip2005 at gmail.com>:> Phlip wrote: >> aslak hellesoy wrote: >>> 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 >> 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 >Please explain how it doesn''t work. Output, error etc. Aslak> -- > Phlip > http://flea.sourceforge.net/resume.html > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
Aslak Helles?y wrote:>> 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 >> > > 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. 1) 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
aslak hellesoy
2009-Apr-26 15:04 UTC
[rspec-users] [Cucumber] call the (Treetop?) parser directly?
On Sat, Apr 25, 2009 at 5:00 PM, Phlip <phlip2005 at gmail.com> wrote:> Aslak Helles?y wrote: > >>> 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 >>> >> >> 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. > > ?1) 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> 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 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Bump?>> Please explain how it doesn''t work. Output, error etc. > > Same as before:I also get it from a rspec-rails case...
David Chelimsky
2009-Apr-28 14:09 UTC
[rspec-users] [Cucumber] call the (Treetop?) parser directly?
On Tue, Apr 28, 2009 at 8:56 AM, Phlip <phlip2005 at gmail.com> 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.
Korny Sietsma
2009-Apr-29 11:34 UTC
[rspec-users] [Cucumber] call the (Treetop?) parser directly?
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 - or see my post earlier at http://groups.google.com/group/rspec/browse_thread/thread/c8fde28e5f757758 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. - Korny On Sat, Apr 25, 2009 at 2:07 PM, Phlip <phlip2005 at gmail.com> wrote:> 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 > ?http://flea.sourceforge.net/resume.html > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > 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"