small medium large xlarge

Generic-user-small
20 Feb 2012, 20:07
axdp944 (4 posts)
Environment: CentoOS 6.2 64-bit ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]

After writing the first calculator example used in chapter 2, I seem to be having an issue getting my test scenario to run successfully.

[aguida@localhost features]$ cucumber ~/IdeaProjects/CucumberBook/features/adding.features (eval):1: compile error (eval):1: unknown regexp options - agda (SyntaxError) /home/aguida/IdeaProjects/CucumberBook/features/calc.rb:1 /home/aguida/.gem/ruby/1.8/gems/cucumber-1.1.8/bin/../lib/cucumber/rb_support/rb_language.rb:129:in eval' /home/aguida/IdeaProjects/CucumberBook/features/calc.rb:1 /home/aguida/.gem/ruby/1.8/gems/cucumber-1.1.8/bin/../lib/cucumber/rb_support/rb_language.rb:129:in load’ /home/aguida/.gem/ruby/1.8/gems/cucumber-1.1.8/bin/../lib/cucumber/rb_support/rb_language.rb:129:in load_code_file' /home/aguida/.gem/ruby/1.8/gems/cucumber-1.1.8/bin/../lib/cucumber/runtime/support_code.rb:171:in load_file’ /home/aguida/.gem/ruby/1.8/gems/cucumber-1.1.8/bin/../lib/cucumber/runtime/support_code.rb:83:in load_files!' /home/aguida/.gem/ruby/1.8/gems/cucumber-1.1.8/bin/../lib/cucumber/runtime/support_code.rb:82:in each’ /home/aguida/.gem/ruby/1.8/gems/cucumber-1.1.8/bin/../lib/cucumber/runtime/support_code.rb:82:in load_files!' /home/aguida/.gem/ruby/1.8/gems/cucumber-1.1.8/bin/../lib/cucumber/runtime.rb:175:in load_step_definitions’ /home/aguida/.gem/ruby/1.8/gems/cucumber-1.1.8/bin/../lib/cucumber/runtime.rb:40:in run!' /home/aguida/.gem/ruby/1.8/gems/cucumber-1.1.8/bin/../lib/cucumber/cli/main.rb:43:in execute!’ /home/aguida/.gem/ruby/1.8/gems/cucumber-1.1.8/bin/../lib/cucumber/cli/main.rb:20:in execute' /home/aguida/.gem/ruby/1.8/gems/cucumber-1.1.8/bin/cucumber:14 /usr/bin/cucumber:19:in load’ /usr/bin/cucumber:19

Looking at the stacktrace above, I believe the issue may have something to do with the “print eval(ARGV[0])” statement in calc.rb which is somehow pulling my username as from the shell output:

calc.rb: print eval(ARGV[0])

I originally started going thru the exercised using IntellijIDEA (w/ ruby plugin) and was successful running cucumber projects on tutorials taken from the cuke4ninja. But to try and debug this issue, I’ve since gone back to running this on the command line to ensure it wasn’t a problem with my IDE.

I can think of a couple of ways of rewriting the steps such as making Calc it’s own class instead of calling it directly, I’d love to get some idea as to what’s causing this issue

Any help would be greatly appreciated!

Avatar_pragsmall
20 Feb 2012, 21:32
Matt Wynne (92 posts)

Hi,

It looks as though you need to change directories. Try doing @cd ~/IdeaProjects/CucumberBook/@ and then running @cucumber@.

Are you using the supplied source code or did you type it in yourself?

Generic-user-small
21 Feb 2012, 05:24
axdp944 (4 posts)

Hi Matt,

Thanks for your reply! To confirm I wasn’t committing any obvious errors, I started over, creating a new test taking the sources taken straight from pragprog.com site untouched into a new directory. After reading the appendix section, I then confirmed I had installed cucumber and rspec gems correctly, then reran the test. This time I received the following error:

[aguida@localhost features]$ cucumber can’t convert nil into String (TypeError) /home/aguida/code/calculator/features/calc.rb:9:in eval' /home/aguida/code/calculator/features/calc.rb:9 /usr/lib/ruby/gems/1.8/gems/cucumber-1.1.8/bin/../lib/cucumber/rb_support/rb_language.rb:129:in load’ /usr/lib/ruby/gems/1.8/gems/cucumber-1.1.8/bin/../lib/cucumber/rb_support/rb_language.rb:129:in load_code_file' /usr/lib/ruby/gems/1.8/gems/cucumber-1.1.8/bin/../lib/cucumber/runtime/support_code.rb:171:in load_file’ /usr/lib/ruby/gems/1.8/gems/cucumber-1.1.8/bin/../lib/cucumber/runtime/support_code.rb:83:in load_files!' /usr/lib/ruby/gems/1.8/gems/cucumber-1.1.8/bin/../lib/cucumber/runtime/support_code.rb:82:in each’ /usr/lib/ruby/gems/1.8/gems/cucumber-1.1.8/bin/../lib/cucumber/runtime/support_code.rb:82:in load_files!' /usr/lib/ruby/gems/1.8/gems/cucumber-1.1.8/bin/../lib/cucumber/runtime.rb:175:in load_step_definitions’ /usr/lib/ruby/gems/1.8/gems/cucumber-1.1.8/bin/../lib/cucumber/runtime.rb:40:in run!' /usr/lib/ruby/gems/1.8/gems/cucumber-1.1.8/bin/../lib/cucumber/cli/main.rb:43:in execute!’ /usr/lib/ruby/gems/1.8/gems/cucumber-1.1.8/bin/../lib/cucumber/cli/main.rb:20:in execute' /usr/lib/ruby/gems/1.8/gems/cucumber-1.1.8/bin/cucumber:14 /usr/bin/cucumber:19:in load’ /usr/bin/cucumber:19

This is really puzzling to me since the example very straightforward. As far as I can tell, the argument from the .feature isn’t making its way to calc.rb for some reason. I can pass an argument directly into calc.rb from ruby, but running it thru cucumber fails.

Avatar_pragsmall
21 Feb 2012, 10:58
Matt Wynne (92 posts)

Okay that’s puzzling. What operating system are you running this on?

Generic-user-small
21 Feb 2012, 15:08
axdp944 (4 posts)

Hi Matt,

I’m running CentOS 6.2 64-bit (RHEL-based Linux) using ruby 1.8.7. I recently created a new VM specifically for running thru these cucumber examples and installed ruby from the yum repository.

Avatar_pragsmall
22 Feb 2012, 11:24
Matt Wynne (92 posts)

The installation instructions in the appendix explain specifically how to install Ruby 1.9.3, which these examples are tested with. I’m afraid we can’t vouch for how they’ll run on older versions of Ruby, sorry.

Is it possible for you to go through the instructions in the appendix of the book and run them with Ruby 1.9.3?

Generic-user-small
26 Feb 2012, 04:20
axdp944 (4 posts)

Hi Matt,

After a little trial and error, I discovered the issue had to do with the location of my calc.rb file. I had originally thought that calc.rb should be inside the /features directory. After a little digging, I learned that cucumber was actually looking for this file in the same directory cucumber was run in: /calculator. Moving the file to /calculator/calc.rb, cucumber was then able to find it and get the test to pass.

Hope this information helps someone else. It was otherwise a very good tutorial and I learned a lot about both cucumber and ruby as a result of these issues. If anything, I might suggest making it a little clearer where that file should be in relation to the directory structure in a future revision.

Thanks again for your help Matt. It’s really great to be able to reach out to an author like this!

-Adam

Avatar_pragsmall
26 Feb 2012, 13:21
Matt Wynne (92 posts)

Good, glad you cracked it.

You must be logged in to comment