Re: [Cucumber] [JVM] JRuby via maven gives error on gherkin commands

412 views
Skip to first unread message

aslak hellesoy

unread,
Apr 9, 2013, 12:27:03 PM4/9/13
to Cucumber Users



On Tue, Apr 9, 2013 at 3:11 PM, Jasper Timmer <jjwt...@gmail.com> wrote:
Hi,

I try to get Cucumber tests running with JRuby via maven. So far I have made two attempts, both start cucumber, but they both trip over the step definitions. Please see these gists for my attempts: https://gist.github.com/Y3PP3R/5337722 and https://gist.github.com/Y3PP3R/5345915.

Error is: NoMethodError: undefined method `Given' for main:Object (at first stepfile.rb line 1). This line contains:
    Given /^I check out the homepage$/ do

With plain ruby I can  just run my cucumber tests, no errors.

How can I make JRuby recognize my step files?


The tests in the cucumber-jruby module are passing, so I'm not aware of any bugs. I assume there is something wrong with your project.

Can you share a project on github where we can reproduce what you see?

Aslak
 
Thanks,

Jasper

--
-- Rules --
 
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.
 
You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cu...@googlegroups.com. To unsubscribe from this group, send email to cukes+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jasper Timmer

unread,
Apr 10, 2013, 6:56:31 AM4/10/13
to cu...@googlegroups.com
Hi,

Op dinsdag 9 april 2013 18:27:03 UTC+2 schreef Aslak Hellesøy het volgende:



On Tue, Apr 9, 2013 at 3:11 PM, Jasper Timmer <jjwt...@gmail.com> wrote:
Hi,

I try to get Cucumber tests running with JRuby via maven. So far I have made two attempts, both start cucumber, but they both trip over the step definitions. Please see these gists for my attempts: https://gist.github.com/Y3PP3R/5337722 and https://gist.github.com/Y3PP3R/5345915.

Error is: NoMethodError: undefined method `Given' for main:Object (at first stepfile.rb line 1). This line contains:
    Given /^I check out the homepage$/ do

With plain ruby I can  just run my cucumber tests, no errors.

How can I make JRuby recognize my step files?


The tests in the cucumber-jruby module are passing, so I'm not aware of any bugs. I assume there is something wrong with your project.

Can you share a project on github where we can reproduce what you see?

I did some more work and investigation, and now I have the following pom.xml, which will run my feature file: https://gist.github.com/Y3PP3R/5353619, only thing is I need capybara support (AKA I need tagged hooks support as per https://github.com/cucumber/cucumber-jvm/issues/467). Is this something small? I looked at the code, but I am not sure how to implement it, since I'm not a cuke dev and I do not have a lot of Ruby experience yet.

Aslak Hellesøy

unread,
Apr 10, 2013, 7:15:49 AM4/10/13
to cu...@googlegroups.com

On Wednesday, 10 April 2013 at 11:56, Jasper Timmer wrote:

Hi,

Op dinsdag 9 april 2013 18:27:03 UTC+2 schreef Aslak Hellesøy het volgende:



On Tue, Apr 9, 2013 at 3:11 PM, Jasper Timmer <jjwt...@gmail.com> wrote:
Hi,

I try to get Cucumber tests running with JRuby via maven. So far I have made two attempts, both start cucumber, but they both trip over the step definitions. Please see these gists for my attempts: https://gist.github.com/Y3PP3R/5337722 and https://gist.github.com/Y3PP3R/5345915.

Error is: NoMethodError: undefined method `Given' for main:Object (at first stepfile.rb line 1). This line contains:
    Given /^I check out the homepage$/ do

With plain ruby I can  just run my cucumber tests, no errors.

How can I make JRuby recognize my step files?


The tests in the cucumber-jruby module are passing, so I'm not aware of any bugs. I assume there is something wrong with your project.

Can you share a project on github where we can reproduce what you see?

I did some more work and investigation, and now I have the following pom.xml, which will run my feature file: https://gist.github.com/Y3PP3R/5353619, only thing is I need capybara support (AKA I need tagged hooks support as per https://github.com/cucumber/cucumber-jvm/issues/467). Is this something small?
It should be fairly quick to implement for someone familiar with the codebase.

I'll assign it to one of our new team members and we'll see.

Aslak 

Jasper Timmer

unread,
Apr 13, 2013, 6:39:56 AM4/13/13
to cu...@googlegroups.com
Hi Aslak,

I saw the github commit you did on tagged hooks, thank a lot. There is a but, unfortunatly.

I asked for tagged hooks because I have the same problem as descibed here: https://groups.google.com/forum/?fromgroups=#!topic/cukes/NPOliqJdtno (wrong number of arguments for Before: 1 for 0). This error still exists. Here is the code for my Before hook:

Before do |scenario|
  time = Time.now.strftime('%d-%m-%Y %H:%M')
  puts "#{time}"
  @current_scenario_name = scenario.name
  if scenario.failed?
    puts "`previous test failed"
   end
end

Do you know if the problem is on my or your side? I think it expects 'Before do' instead of 'Before do |scenario|' but how do I get access to scenario then? It runs on ruby 1.9.3.

Op woensdag 10 april 2013 13:15:49 UTC+2 schreef Aslak Hellesøy het volgende:

Jasper Timmer

unread,
Apr 13, 2013, 8:06:19 AM4/13/13
to cu...@googlegroups.com
Hm, I think I didn't have the snapshot cucumber-jruby jar on my classpath, it's gone now. Still struggling though:

←[1A←[31mFailure in before hook:←[0m←[31msrc/test/gems/gems/capybara-2.1.0/lib/capybara/cucumber.rb:21←[0m
←[31mMessage: ←[0m←[31morg.jruby.exceptions.RaiseException: (NoMethodError) undefined method `source_tag_names' for #<Java::CucumberRuntime::ScenarioImpl:0x23774f19>
        at RUBY.(root)(D:/ibanx/unite/cucumber/src/test/gems/gems/capybara-2.1.0/lib/capybara/cucumber.rb:22)
        at org.jruby.RubyBasicObject.instance_exec(org/jruby/RubyBasicObject.java:1738)
        at RUBY.execute(jar:file:D:/ibanx/unite/cucumber/libs/cucumber-jruby.jar!/cucumber/runtime/jruby/dsl.rb:56)
←[0m      ←[31morg.jruby.exceptions.RaiseException: (NoMethodError) undefined method `source_tag_names' for #<Java::CucumberRuntime::ScenarioImpl:0x23774f19>
        at RUBY.(root)(D:/ibanx/unite/cucumber/src/test/gems/gems/capybara-2.1.0/lib/capybara/cucumber.rb:22)
        at org.jruby.RubyBasicObject.instance_exec(org/jruby/RubyBasicObject.java:1738)
        at RUBY.execute(jar:file:D:/ibanx/unite/cucumber/libs/cucumber-jruby.jar!/cucumber/runtime/jruby/dsl.rb:56)
      ←[0m
←[1A←[31mFailure in before hook:←[0m←[31mnl/ibanx/cucumber/support/hooks.rb:3←[0m
←[31mMessage: ←[0m←[31morg.jruby.exceptions.RaiseException: (NoMethodError) undefined method `name' for #<Java::CucumberRuntime::ScenarioImpl:0x23774f19>
        at RUBY.(root)(nl\ibanx\cucumber\support\hooks.rb:7)
        at org.jruby.RubyBasicObject.instance_exec(org/jruby/RubyBasicObject.java:1738)
        at RUBY.execute(jar:file:D:/ibanx/unite/cucumber/libs/cucumber-jruby.jar!/cucumber/runtime/jruby/dsl.rb:56)
←[0m      ←[31morg.jruby.exceptions.RaiseException: (NoMethodError) undefined method `name' for #<Java::CucumberRuntime::ScenarioImpl:0x23774f19>
        at RUBY.(root)(nl\ibanx\cucumber\support\hooks.rb:7)
        at org.jruby.RubyBasicObject.instance_exec(org/jruby/RubyBasicObject.java:1738)
        at RUBY.execute(jar:file:D:/ibanx/unite/cucumber/libs/cucumber-jruby.jar!/cucumber/runtime/jruby/dsl.rb:56)
      ←[0m


Op zaterdag 13 april 2013 12:39:56 UTC+2 schreef Jasper Timmer het volgende:

Aslak Hellesøy

unread,
Apr 13, 2013, 10:56:53 AM4/13/13
to cu...@googlegroups.com

On Saturday, 13 April 2013 at 13:06, Jasper Timmer wrote:

Hm, I think I didn't have the snapshot cucumber-jruby jar on my classpath, it's gone now. Still struggling though:

←[1A←[31mFailure in before hook:←[0m←[31msrc/test/gems/gems/capybara-2.1.0/lib/capybara/cucumber.rb:21←[0m
←[31mMessage: ←[0m←[31morg.jruby.exceptions.RaiseException: (NoMethodError) undefined method `source_tag_names' for #
The Cucumber-Ruby API that Capybara uses is slightly different from the Cucumber-JVM API. We'd have to modify either Cucumber-JVM or Capybara to make this work.

Can you create a ticket in the cucumber-jvm tracker please?

Aslak

aslak hellesoy

unread,
Jun 6, 2013, 9:59:42 AM6/6/13
to cu...@googlegroups.com


On Thursday, June 6, 2013, Major Paul wrote:
Hi Aslak,

I am having the same issue with cucumber-jvm when trying to run via maven-ant-plugin, stuck with "[java] NoMethodError: undefined method `Given' for main:Object". I see you had solved this issue 

Please refresh my memory. Where did you see that I solved this?

Aslak
 
but did not see what was the fix. Could you please post the fix how you made this work. 

Thanks,
Major 


On Tuesday, April 9, 2013 9:11:06 AM UTC-5, Jasper Timmer wrote:
Hi,

I try to get Cucumber tests running with JRuby via maven. So far I have made two attempts, both start cucumber, but they both trip over the step definitions. Please see these gists for my attempts: https://gist.github.com/Y3PP3R/5337722 and https://gist.github.com/Y3PP3R/5345915.

Error is: NoMethodError: undefined method `Given' for main:Object (at first stepfile.rb line 1). This line contains:
    Given /^I check out the homepage$/ do

With plain ruby I can  just run my cucumber tests, no errors.

How can I make JRuby recognize my step files?

Thanks,

Jasper

Jasper Timmer

unread,
Jun 6, 2013, 10:09:56 AM6/6/13
to cu...@googlegroups.com
@Aslak: It was not resolved, but I just gave up given my time constraints, and stuck to the original ruby implementation. You did however close this related ticket, created by me: https://github.com/cucumber/cucumber-jvm/issues/504


On Thursday, June 6, 2013 3:59:42 PM UTC+2, Aslak Hellesøy wrote:


On Thursday, June 6, 2013, Major Paul wrote:
Hi Aslak,

I am having the same issue with cucumber-jvm when trying to run via maven-ant-plugin, stuck with "[java] NoMethodError: undefined method `Given' for main:Object". I see you had solved this issue 

Please refresh my memory. Where did you see that I solved this?

Aslak
 
but did not see what was the fix. Could you please post the fix how you made this work. 

Thanks,
Major 

On Tuesday, April 9, 2013 9:11:06 AM UTC-5, Jasper Timmer wrote:
Hi,

I try to get Cucumber tests running with JRuby via maven. So far I have made two attempts, both start cucumber, but they both trip over the step definitions. Please see these gists for my attempts: https://gist.github.com/Y3PP3R/5337722 and https://gist.github.com/Y3PP3R/5345915.

Error is: NoMethodError: undefined method `Given' for main:Object (at first stepfile.rb line 1). This line contains:
    Given /^I check out the homepage$/ do

With plain ruby I can  just run my cucumber tests, no errors.

How can I make JRuby recognize my step files?

Thanks,

Jasper

--
-- Rules --
 
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.
 
You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cu...@googlegroups.com. To unsubscribe from this group, send email to cukes+unsubscribe@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en

---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+unsubscribe@googlegroups.com.

aslak hellesoy

unread,
Jun 6, 2013, 11:35:41 AM6/6/13
to Cucumber Users
On Thu, Jun 6, 2013 at 9:09 AM, Jasper Timmer <jjwt...@gmail.com> wrote:
@Aslak: It was not resolved,

Actually, it was resolved. That's why I closed the issue. See the commit in the issue.

If you look at the date of the commit (March 13 - hover the "2 months ago" text), you'll see that this was done *after* the last release, March 10[1]

I'll try to get a new release out in the next week or two if time permits.

Aslak
 
You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cu...@googlegroups.com. To unsubscribe from this group, send email to cukes+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en

---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.

Major Paul

unread,
Jun 17, 2013, 3:52:45 PM6/17/13
to cu...@googlegroups.com, aslak.h...@gmail.com
Aslak,

As you said, I am waiting for the release of the new release of cucumber-jvm with the fix for the issue cucumber-jvm tag @Given hooks not recognized. 



I am wondering if there's a way for me test this issue with a snapshot version, while you build the release. So, I will know if there's any other issues on my environment.

Thanks,
Major


You received this message because you are subscribed to a topic in the Google Groups "Cukes" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cukes/T0Jtf2g5ofc/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to cukes+un...@googlegroups.com.

aslak hellesoy

unread,
Jun 17, 2013, 3:59:28 PM6/17/13
to Major Paul, Cucumber Users
On Mon, Jun 17, 2013 at 2:52 PM, Major Paul <majorp...@gmail.com> wrote:
Aslak,

As you said, I am waiting for the release of the new release of cucumber-jvm with the fix for the issue cucumber-jvm tag @Given hooks not recognized. 


We have to make a new release of gherkin before making a new release of cucumber-jvm.
There are a few issues in gherkin that must be fixed first: 
 


I am wondering if there's a way for me test this issue with a snapshot version, while you build the release. So, I will know if there's any other issues on my environment.


Have you tried building cucumber-jvm yourself?

cd cucumber-jvm
mvn install

Aslak

Major Paul

unread,
Jun 24, 2013, 2:40:57 PM6/24/13
to cu...@googlegroups.com
Aslak

I tried fixing the cucumber-jvm for JRuby specifically and still have not made much progress. I understand it's running fine on Travis and on your box. Could you suggest anything that may need to be setup when running first time? 

The failure on cucumber-JVM (JRuby) is on 

Failed tests:   featureWithOutlineTest(cucumber.runtime.formatter.JSONPrettyFormatterTest):

at the last line of the JSON test data, there's a mismatch: 

expected - "uri": "cucumber\runtime\formatter\JSONPrettyFormatterTest.feature"
actual -  "uri": "cucumber\\runtime\\formatter\\JSONPrettyFormatterTest.feature"

Also, I am not sure how I would get a copy of snapshot from the source server? If you don't mind could you resend the procedure? 

aslak hellesoy

unread,
Jun 24, 2013, 3:02:09 PM6/24/13
to Cucumber Users
On Mon, Jun 24, 2013 at 1:40 PM, Major Paul <majorp...@gmail.com> wrote:
Aslak

I tried fixing the cucumber-jvm for JRuby specifically and still have not made much progress. I understand it's running fine on Travis and on your box. Could you suggest anything that may need to be setup when running first time? 


 
The failure on cucumber-JVM (JRuby) is on 

Failed tests:   featureWithOutlineTest(cucumber.runtime.formatter.JSONPrettyFormatterTest):

at the last line of the JSON test data, there's a mismatch: 

expected - "uri": "cucumber\runtime\formatter\JSONPrettyFormatterTest.feature"
actual -  "uri": "cucumber\\runtime\\formatter\\JSONPrettyFormatterTest.feature"

Also, I am not sure how I would get a copy of snapshot from the source server? If you don't mind could you resend the procedure? 


Thanks,
Major

On Tuesday, April 9, 2013 9:11:06 AM UTC-5, Jasper Timmer wrote:
Hi,

I try to get Cucumber tests running with JRuby via maven. So far I have made two attempts, both start cucumber, but they both trip over the step definitions. Please see these gists for my attempts: https://gist.github.com/Y3PP3R/5337722 and https://gist.github.com/Y3PP3R/5345915.

Error is: NoMethodError: undefined method `Given' for main:Object (at first stepfile.rb line 1). This line contains:
    Given /^I check out the homepage$/ do

With plain ruby I can  just run my cucumber tests, no errors.

How can I make JRuby recognize my step files?

Thanks,

Jasper

--

Björn Rasmusson

unread,
Jun 25, 2013, 3:05:09 AM6/25/13
to cu...@googlegroups.com
Aslak Hellesøy wrote:



On Mon, Jun 24, 2013 at 1:40 PM, Major Paul <majorp...@gmail.com> wrote:
Aslak

I tried fixing the cucumber-jvm for JRuby specifically and still have not made much progress. I understand it's running fine on Travis and on your box. Could you suggest anything that may need to be setup when running first time? 


Fork it and create a pull request:

 
The failure on cucumber-JVM (JRuby) is on 

Failed tests:   featureWithOutlineTest(cucumber.runtime.formatter.JSONPrettyFormatterTest):

at the last line of the JSON test data, there's a mismatch: 

expected - "uri": "cucumber\runtime\formatter\JSONPrettyFormatterTest.feature"
actual -  "uri": "cucumber\\runtime\\formatter\\JSONPrettyFormatterTest.feature"

This is an Windows issue, on *nix the "uri" looks like "cucumber/runtime/formatter/JSONPrettyFormatterTest.feature" so the test passes fine on Travis.
Looking at the pull request that introduced the test:
https://github.com/cucumber/cucumber-jvm/pull/426
the issue of different file path separators between Windows and other operating systems are pointed out and a fix to make it work on Windows is committed, but I'm not sure that the fix was ever tested on Windows, because I have always experienced this test failure on Windows (and not using JRuby). In the JSON file (actual) the Windows file path separator ("\") is escaped with a backslash, to get that in the expected you would actually have to have two escaped backslashes ("\\\\") in the java string to make them evaluate to "\\" (I recon), so to construct expected with File.separator is not enough, given the the escaped backslash in the JSON file.

Regards
Björn

 
Reply all
Reply to author
Forward
0 new messages