user2993456
user2993456

Reputation:

including executable file with gem

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!

Upvotes: 1

Views: 245

Answers (1)

matt
matt

Reputation: 79813

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.

Upvotes: 1

Related Questions