Add RSpec respond_to matcher spec

This commit is contained in:
Michael Miller 2020-01-17 22:14:25 -07:00
parent a2508d5f6b
commit e3a4dedfc6

View file

@ -0,0 +1,29 @@
require "../../spec_helper"
# Examples taken from:
# https://relishapp.com/rspec/rspec-expectations/v/3-8/docs/built-in-matchers/respond-to-matcher
# and modified to fit Spectator and Crystal.
Spectator.describe "`respond_to` matcher" do
context "basic usage" do
describe "a string" do
it { is_expected.to respond_to(:size) } # It's size in Crystal, not length.
it { is_expected.to respond_to(:hash, :class, :to_s) }
it { is_expected.not_to respond_to(:to_model) }
it { is_expected.not_to respond_to(:compact, :flatten) }
# deliberate failures
# TODO: Add support for expected failures.
xit { is_expected.to respond_to(:to_model) }
xit { is_expected.to respond_to(:compact, :flatten) }
xit { is_expected.not_to respond_to(:size) }
xit { is_expected.not_to respond_to(:hash, :class, :to_s) }
# mixed examples--String responds to :length but not :flatten
# both specs should fail
xit { is_expected.to respond_to(:size, :flatten) }
xit { is_expected.not_to respond_to(:size, :flatten) }
end
end
# Spectator doesn't support argument matching with respond_to.
end