I'm new at coding and I'm trying to implement RSpec testing to a command I made for my slack bot using Ruby. The command retrieves the data from the database using .where(Time.zone.now.begining_of_day..Time.zone.now.end_of_day) => showed in the code down bellow. map through each of them and format it for the user output
Code:
Class StartCommand
def call
Answer.where(created_at: Time.zone.now.beginning_of_day..Time.zone.now.end_of_day)
.map { |answer| "#{answer.slack_identifier}:\n#{answer.body}" }
.join("\n\n")
end
end
RSpec testing:
RSpec.describe RecordCommand do
describe '#call' do
it 'retrieves data and format it' do
StartCommand.new.call
expect(Answer.where).to eq()
end
end
As you can see I'm kinda lost how to implement the code in the RSpec testing, any ideas, hints or solutions would be awesome! Help! Im using Ruby and Ruby on Rails 4