Undefined local variable or method `message' (NameError)

I am trying to learn Rspec-Cucumber tutorial by referring to “The
Pragmatic Programmers - The Rspec Book”. I am on the 4th chapter and
seems to be stuck with an error and not able to move forward.I have
followed exactly as per the tutorial but it is showing the below error
( in line : output.messages.should include(message))when I try to run
cucumber feature in my console.

undefined local variable or method `message’ for #Object:0x9c0c05c

My codebreaker_steps.rb file is as follows.

Then /^I should see "([^"]*)"$/ do |arg1|
output.messages.should include(message)

class Output
  def messages
  @messages ||= []

  def puts(message)
  messages << message

  def output
  @output ||= Output.new

I’m not an expert, but you’re passing |arg1| as block argument, but
calling the messages method to the object variable. Maybe it should

arg1.messages.should include(message)

2014-04-06 10:16 GMT+02:00 ruby rails [email protected]:

The book shows:

“Then /^I should see “([^”]*)"$/ do |message|
output.messages.should include(message)

Excerpt From: David C… “The RSpec Book (for Tamara T.).”

you have |arg1| after the do, not |message|

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs