Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cucumber cpp gives error: no implicit conversion of nil into String (TypeError) #194

Closed
ozenozkaya opened this issue Jun 18, 2018 · 8 comments

Comments

@ozenozkaya
Copy link

ozenozkaya commented Jun 18, 2018

Summary

Calculator example gives "no implicit conversion of nil into String error. I changed nothing and cloned latest version of the repo. I am building the cucumber-cpp in Ubuntu 16.04 64-bit version.

Logs:

+ build/examples/Calc/GTestCalculatorSteps
+ cucumber examples/Calc
Feature: Addition
  In order to avoid silly mistakes
  As a math idiot 
  I want to be told the sum of two numbers

  Scenario Outline: Add two numbers                    # examples/Calc/features/addition.feature:7
    Given I have entered <input_1> into the calculator # examples/Calc/features/addition.feature:8
    And I have entered <input_2> into the calculator   # examples/Calc/features/addition.feature:9
    When I press <button>                              # examples/Calc/features/addition.feature:10
    Then the result should be <output> on the screen   # examples/Calc/features/addition.feature:11

    Examples: 
      | input_1 | input_2 | button | output |
      no implicit conversion of nil into String (TypeError)
      ./features/support/hooks.rb:4:in `exists?'
      ./features/support/hooks.rb:4:in `Before'
      | 20      | 30      | add    | 50     |
      no implicit conversion of nil into String (TypeError)
      ./features/support/hooks.rb:4:in `exists?'
      ./features/support/hooks.rb:4:in `Before'
      | 2       | 5       | add    | 7      |
      no implicit conversion of nil into String (TypeError)
      ./features/support/hooks.rb:4:in `exists?'
      ./features/support/hooks.rb:4:in `Before'
      | 0       | 40      | add    | 40     |

Feature: Division
  In order to avoid silly mistakes
  Cashiers must be able to calculate a fraction

  Scenario: Regular numbers                     # examples/Calc/features/division.feature:6
  no implicit conversion of nil into String (TypeError)
  ./features/support/hooks.rb:4:in `exists?'
  ./features/support/hooks.rb:4:in `Before'
    Given I have entered 3 into the calculator  # examples/Calc/features/division.feature:7
    And I have entered 2 into the calculator    # examples/Calc/features/division.feature:8
    When I press divide                         # examples/Calc/features/division.feature:9
    Then the result should be 1.5 on the screen # examples/Calc/features/division.feature:10

Failing Scenarios:
cucumber examples/Calc/features/addition.feature:15 # Scenario Outline: Add two numbers, Examples (#1)
cucumber examples/Calc/features/addition.feature:16 # Scenario Outline: Add two numbers, Examples (#2)
cucumber examples/Calc/features/addition.feature:17 # Scenario Outline: Add two numbers, Examples (#3)
cucumber examples/Calc/features/division.feature:6 # Scenario: Regular numbers

4 scenarios (4 failed)
16 steps (16 undefined)
0m0.025s

Expected Behavior

Expected behavior is to run success.

Current Behavior

Following and similar errors came:

  Scenario: Regular numbers                     # examples/Calc/features/division.feature:6
  no implicit conversion of nil into String (TypeError)
  ./features/support/hooks.rb:4:in `exists?'
  ./features/support/hooks.rb:4:in `Before'

Steps to Reproduce (for bugs)

Just build the cucumber-cpp under ubuntu and you'll get the errors.

@muggenhor
Copy link
Contributor

What's the version of cucumber that you're using? (cucumber --version)

I'm expecting this to be caused by a problem similar to #179. Which I'm reasonably sure is caused by a backwards compatible break in the wire protocol, similar to cucumber/cucumber-ruby#1183.

@ozenozkaya
Copy link
Author

Hello, here below you'll see the version as 3.1.1:

dev@ubuntu:~/ws/cucumber-cpp$ cucumber --version
3.1.1

@konserw
Copy link
Contributor

konserw commented Jul 1, 2018

Hi @ozenozkaya please use cucumber 2.4

@elominp
Copy link

elominp commented Oct 17, 2018

Hello, on Windows I reproduced this error with all versions of Cucumber >= 2.1.0, using Cucumber 2.4.0 didn't fix it (for some specific reasons I wasn't able to try Cucumber 2.0.0).

The reason is the environment variable "TMP_DIR" being not set, as visible in the cucumber output:

no implicit conversion of nil into String (TypeError)
./features/support/hooks.rb:4:in `exists?'
./features/support/hooks.rb:4:in `Before'
./features/support/hooks.rb:4:in `exists?'
./features/support/hooks.rb:4:in `Before'
2  require 'fileutils'
3  featuresTmpSpace = ENV["TMP_DIR"]
4  FileUtils.rm_rf(featuresTmpSpace) if Dir.exists?(featuresTmpSpace)
5  FileUtils.mkdir(featuresTmpSpace)
6  FileUtils.touch("#{featuresTmpSpace}/cycle.log")
7# gem install syntax to get syntax highlighting

Defining this variable with the path of the Calc example worked for me and gives the expected output so it's a hacky solution until it's fixed.

My configuration:

  • OS: Windows 10 1709 x64
  • Compiler: MSVC 14.0
  • Gems:
    • cucumber 2.1.0
    • cucumber-core 1.3.0
    • cucumber-expressions 6.0.1
    • cucumber-tag_expressions 1.1.1
    • cucumber-wire 0.0.1
    • gherkin3 3.1.2

@paoloambrosio
Copy link
Member

@elominp your problem seems to be unrelated to what has been reported in this issue.

The code that you pasted is related to the end-to-end test suite for Cucumber-CPP and not the Calc example. The environment variable TMP_DIR is passed by the build system whenever you run the features, features-pretty or features-wip targets.

It looks like running cucumber examples\Calc still tries to load the support code from features\support\hooks.rb instead of trying to reading from examples\Calc\.... Changing the current directory to examples\Calc before running cucumber should fix your problem. Not sure why we don't see the same issue in our CI build.

@paoloambrosio
Copy link
Member

Closing this as it is a Cucumber-Ruby 3.x issue: cucumber/cucumber-ruby#1183

@ghost
Copy link

ghost commented Dec 21, 2018

@elominp
@paoloambrosio

Not sure why we don't see the same issue in our CI build.

CI is set-up to use cucumber 2.0.0 and this issue comes with cucumber 2.1 or above.

gem 'cucumber', "=2.0.0"

@erichstuder
Copy link
Contributor

@elominp your problem seems to be unrelated to what has been reported in this issue.

The code that you pasted is related to the end-to-end test suite for Cucumber-CPP and not the Calc example. The environment variable TMP_DIR is passed by the build system whenever you run the features, features-pretty or features-wip targets.

It looks like running cucumber examples\Calc still tries to load the support code from features\support\hooks.rb instead of trying to reading from examples\Calc\.... Changing the current directory to examples\Calc before running cucumber should fix your problem. Not sure why we don't see the same issue in our CI build.

This solved my problem for now.
I would have saved a lot of time (about 2 days) if this hint was also present in the README.md
Maybe it would help to add it there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants