1

The gem in question is on my GItHub

I am also on Linux, specifically Ubuntu. I am trying to make the gem compatible for Linux/OSX users at this point, with a focus on Windows users after it is working correctly for *nix systems.

So I have written a gem called fails. It can be used to build a test automation suite with the Ruby/Cucumber/Watir-webdriver stack around web applications written in other languages, and with other frameworks.

It creates powerful command line generation tools for building page objects and feature files using several commands, which are:

fails g page <page object name>
fails f <feature file name>
fails n <new automated test suite name>

I have written an appropriate executable file that should, on installing the gem, allow a user to call fails <arg> <arg> <arg>...etc from command line. However, when building the gem and installing it, I try and generate a page object by calling fails g page google but I get the error:

daniel@d:~/Downloads/fails_gem$ fails
/usr/local/bin/fails:23:in `load': /var/lib/gems/2.1.0/gems/fails-0.0.3/bin/fails:4: syntax error, unexpected tCONSTANT, expecting end-of-input (SyntaxError)
fails.rb ARGV[0] ARGV[1] ARGV[2] ARGV[3] ARGV[4] A...
                     ^
    from /usr/local/bin/fails:23:in `<main>'

This error is telling me that something is wrong with my executable file, but I don't quite understand what. I need to be able to call fails.rb with up to nine command line arguments. My executable file looks like this:

#!/usr/bin/env ruby

require 'fails'
fails.rb ARGV[0] ARGV[1] ARGV[2] ARGV[3] ARGV[4] ARGV[5] ARGV[6] ARGV[7] ARGV[8] ARGV[9]

The gem is really new and unpolished, so any open source support would be great if there is interest!

1 Answers1

1

You seem to be a bit confused about the contents of the executable bin/fails. This should be plain Ruby. It looks like you are trying to use some sort of combination Ruby and shell syntax with the line fails.rb ARGV[0] ..., which isn’t going to work.

In this case all I think you need is the require 'fails' line. This should load the file lib/fails.rb (since Rubygems will have added lib to your load path), and then the contents or ARGV will still be available in that file.

matt
  • 78,533
  • 8
  • 163
  • 197
  • OK awesome. I was thrown off by the tutorial on rubygems.org that teaches you how to create the `hola` gem. I reduced the executable file to just a shebang and `require 'fails'` and it's working great. Out of curiosity, do I have to do anything special to the executable to get the same functionality on Windows? –  Aug 30 '15 at 01:59
  • @FluffyKittens I don’t think so (I don’t have a Windows machine to test). I saw your `fails.bat` file – Rubygems creates a wrapper file for executables that sets up the load path etc. On Windows I think it creates an appropriate `.bat` file for you, so you shouldn’t need anything like that. – matt Aug 30 '15 at 02:05
  • Thanks. I had previously created that .bat file manually with the intent of creating an executable file to move it into bin. Guess that's not important anyone. –  Aug 30 '15 at 02:17