Here is the test:
I define the key data here:
let('bot_response') { {'bot_response' => 'the response contains <SETPROFILE><KEY>test_key</KEY><VALUE>TEST-SETPROFILE-VALUE</VALUE></SETPROFILE>'} } I run the method I want to test here:
let('bot_response') {BotResponse.act_on_set_profile_tag( value, bot_client_id, bot_response )} I assert the test condition here:
expect(bot_response['bot_response']).to eq("the response contains") Here is the key part of the actual method:
bot_response['bot_response'] = bot_response['bot_response'].gsub(/<SETPROFILE>(.*)<\/SETPROFILE>/, '').strip return bot_response My test fails with the following:
Failure/Error: expect(response['bot_response']).to eq("the response contains") expected: "the response contains" got: "the response contains <SETPROFILE><KEY>test_key</KEY><VALUE>TEST-SETPROFILE-VALUE</VALUE></SETPROFILE>" But I cannot figure out why. I am new to rspec and actually am not sure if I am doing it right, particularly the let