Question about calling Cucumber from with in Ruby code

190 views
Skip to first unread message

Amir Hossein Ebrahimi

unread,
May 18, 2011, 6:46:42 AM5/18/11
to Cukes
Hi all,
I have been trying to call the Cucumber compiler from within the ruby
code. The code which I have been using looks like this: In file 1

require 'NFRParser2'

TestCucumber.runCucumber(ARGV[0])

and in file NFRParser2:
require 'rubygems'
require 'cucumber'

class TestCucumber
def self.runCucumber(filename)

puts "1"
runtime = Cucumber::Runtime.new
runtime.load_programming_language('rb')
puts "2"
Cucumber::Cli::Main.new([]).execute!(runtime)
puts "3"
end

end

then from the command prompt I call "ruby file1 featurefile.feature"
But the problem I have is that the output looks like this:
1
2
1
2
1
2
...
As you can see it seems like the calling of the cucumber compiler
fails!
Can anyone help me?

Regards
Amir

Matt Wynne

unread,
May 18, 2011, 8:07:34 AM5/18/11
to cu...@googlegroups.com

What you've done looks reasonable. See here for an example:

https://github.com/cucumber/cucumber/blob/master/legacy_features/api/run_cli_main_with_existing_runtime.feature

I find it impossible to help you any further without sitting down next to you, I'm afraid.

cheers,
Matt

--
Freelance programmer & coach
Founder, http://relishapp.com
+44(0)7974430184 | http://twitter.com/mattwynne

Juan Manuel Barreneche

unread,
May 18, 2011, 9:05:43 AM5/18/11
to cu...@googlegroups.com
Hi!
Looking at the feature Matt pointed out, and your CLI invocation, I see you don't respect cucumbers conventions for the path to files (ie. features/ and features/step_definitions/). I see that the filename you are passing to your method isn't being used, so, how would cucumber know where to find them?
I don't know if this info can be specified to the runtime, but I bet the problem has to do with the path to your files.

Cheers,
Juan Manuel Barreneche


Matt Wynne

unread,
May 18, 2011, 9:52:10 AM5/18/11
to cu...@googlegroups.com
I hadn't noticed that. If you look at the constructor of Cucumber::Runtime, you'll see it accepts a configuration object, or otherwise uses a default. The default assumes your features are stored in ./features. Read the code for further details.




--
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 http://groups.google.com/group/cukes?hl=en.

cheers,
Matt

07974 430184

Reply all
Reply to author
Forward
0 new messages