0

I'm trying to mock some data inside before(:each) and get

 NoMethodError:
   undefined method `receive_message' for #<RSpec::ExampleGroups::CurrencyExchange:0x007f87c652f3c8>

my before(:each

before(:each) do
  @rates = {"exchangerates"=>
            {"row"=>
                 [{"exchangerate"=>{"ccy"=>"EUR", "base_ccy"=>"UAH", "buy"=>"28.33917", "sale"=>"28.33917"}},
                  {"exchangerate"=>{"ccy"=>"RUR", "base_ccy"=>"UAH", "buy"=>"0.38685", "sale"=>"0.38685"}},
                  {"exchangerate"=>{"ccy"=>"USD", "base_ccy"=>"UAH", "buy"=>"24.88293", "sale"=>"24.88293"}},
                  {"exchangerate"=>{"ccy"=>"BTC", "base_ccy"=>"USD", "buy"=>"605.3695", "sale"=>"669.0926"}}]}}
 obj = double()
 @request = allow(obj).to receive_message(@rates)


end

How to fix it?

user
  • 1,341
  • 2
  • 17
  • 28

1 Answers1

1

It's just receive, unless you are allowing multiple messages, then it's receive_messages - plural.

Example:

allow(obj).to receive(:method_name)
allow(obj).to receive(:method_1 => :result_1, :method_2 => :result_2)

See the Relish documentation.

MrDanA
  • 11,489
  • 2
  • 36
  • 47