Using mocks library in Crystal
Mocks cannot be defined in describe/it
body so this won’t work:
describe Bot::Slack do
describe "#post_response" do
it "sends formatted message" do
Mocks.create_mock JsonClient do
mock self.post(url, body)
end
# testing here
and you will get: can't declare class dynamically
.
Correct way:
Mocks.create_mock JsonClient do
mock self.post(url, body)
end
describe Bot::Slack do
describe "#post_response" do
it "sends formatted message" do
# testing here
Tweet