mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add RSpec respond_to
matcher spec
This commit is contained in:
parent
a2508d5f6b
commit
e3a4dedfc6
1 changed files with 29 additions and 0 deletions
29
spec/rspec/expectations/respond_to_matcher_spec.cr
Normal file
29
spec/rspec/expectations/respond_to_matcher_spec.cr
Normal 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
|
Loading…
Reference in a new issue