Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8372431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:25:49+00:00 2026-06-09T14:25:49+00:00

So I’m on the first project in Pragmatic Cucumber and I’m getting an undefined

  • 0

So I’m on the first project in “Pragmatic Cucumber” and I’m getting an undefined method error in my step definitions. The error is coming from $?.success?. Needless to say I’m confused. Am I missing a gem or something?

Here’s the Step Definition

Given /^the input "(.*?)"$/ do |input|
  @input = input
end

When /^the calculator is run$/ do
  @output = 'ruby calc.rb #{@input}'
  raise('Command failed!') unless $?.success? #$?.success? is failing. look that up.
end

Then /^the output should be "(.*?)"$/ do |arg1|
  pending # express the regexp above with the code you wish you had
end

Here’s the Error.

Feature: Adding

  Scenario: Add two numbers       # features/adding.feature:3
Given the input "2+2"         # features/step_definitions/calculator_steps.rb:1
When the calculator is run    # features/step_definitions/calculator_steps.rb:5
  undefined method `success?' for nil:NilClass (NoMethodError)
  ./features/step_definitions/calculator_steps.rb:7:in `/^the calculator is run$/'
  features/adding.feature:5:in `When the calculator is run'
Then the output should be "4" # features/step_definitions/calculator_steps.rb:10

Failing Scenarios:
cucumber features/adding.feature:3 # Scenario: Add two numbers

1 scenario (1 failed)
3 steps (1 failed, 1 skipped, 1 passed)
0m0.012s

So, what’s the problem here? I know that .success? is correct, why isn’t $? registering? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T14:25:51+00:00Added an answer on June 9, 2026 at 2:25 pm

    You need to use backticks instead of quotes to run your command:

    @output = 'ruby calc.rb #{@input}'
    

    Should be:

    @output = `ruby calc.rb #{@input}`
    

    Edit:

    Just tested this – you want to be very careful using this construct. The value of $? won’t be cleared out between Cucumber scenarios, so it would be easy to make an assertion against the result of a command that was run in a previous scenario. You may wish to look into Aruba which is specifically designed for situations where you need Cucumber to execute or assert against command-line programs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm making a simple page using Google Maps API 3. My first. One marker

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.