Indika K
Indika K

Reputation: 1414

Ruby gem CLI testing with Aruba

I am testing a gem with Aruba. My problem is that even when I do not have anything in bin directory the step When I run 'executable' is passing. Here is the scenario.

  Scenario: Send SMS
  When I run `serialsms`
  Then message should be sent

feature/support/env.rb

$LOAD_PATH.push File.join(File.dirname(__FILE__), "/../../lib" )
ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
require 'serial_sms'
require 'aruba/cucumber'

cucumber output

  Scenario: Send SMS            # features/send_sms_cli.feature:7
    When I run `serialsms`      # aruba-0.4.9/lib/aruba/cucumber.rb:56
    Then message should be sent # features/send_sms_cli.feature:9

1 scenario (1 undefined)
2 steps (1 undefined, 1 passed)
0m0.123s

You can implement step definitions for undefined steps with these snippets:

Then /^message should be sent$/ do
  pending # express the regexp above with the code you wish you had
end

Is this the normal behavior of Aruba or am I doing something wrong.

Upvotes: 3

Views: 1393

Answers (1)

Richard Conroy
Richard Conroy

Reputation: 1880

If you add the @announce hook before your feature definition you can get some expanded information about what aruba is doing.

In particular aruba does a lot of funky things with creating a tmp directory for itself, copying your sources around etc. However that might not be your issue.

IIRC the step definition for

When I run "foo"

is not one that will fail it doesn't have asserts or matchers. You need to follow it with something like

Then it should pass ....

to get a failing test (checks for exit code, things send to STD(OUT|ERR) etc.)

Upvotes: 3

Related Questions