Студент кодирования в необходимости консультации для методов Рубин &амп; аргументы по умолчанию лаборатории
Я потратил больше часа, пытаясь понять, как решить эту ошибку, но ничего не работает.
Вот сообщение об ошибке:
say_hello accepts an argument of a name and prints out Hello with that Name (FAILED - 1) defaults to Ruby Programmer when no name is passed in (FAILED - 2) Failures: 1) say_hello accepts an argument of a name and prints out Hello with that Name Failure/Error: expect($stdout).to receive(:puts).with("Hello Kent Beck!") (#<IO:<STDOUT>>).puts("Hello Kent Beck!") expected: 1 time with arguments: ("Hello Kent Beck!") received: 0 times # ./spec/say_hello_spec.rb:6:in `block (2 levels) in <top (required)>' 2) say_hello defaults to Ruby Programmer when no name is passed in Failure/Error: expect($stdout).to receive(:puts).with("Hello Ruby Programmer!") (#<IO:<STDOUT>>).puts("Hello Ruby Programmer!") expected: 1 time with arguments: ("Hello Ruby Programmer!") received: 0 times # ./spec/say_hello_spec.rb:11:in `block (2 levels) in <top (required)>' Finished in 0.01319 seconds (files took 0.19887 seconds to load) 2 examples, 2 failures Failed examples: rspec ./spec/say_hello_spec.rb:5 # say_hello accepts an argument of a name and prints out Hello with that Name rspec ./spec/say_hello_spec.rb:10 # say_hello defaults to Ruby Programmer when no name is passed in
Что я уже пробовал:
def say_hello (name = "Ruby Programming") "Hello, #{name}!" end say_hello ("Gabriela")
def say_hello (name = "Ruby Programming") puts "Hello, #{name}!" end say_hello ("Gabriela")