mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add RSpec start_with
and end_with
matchers specs
This commit is contained in:
parent
5fa6b5d549
commit
f23141b3e1
2 changed files with 66 additions and 0 deletions
33
spec/rspec/expectations/end_with_matcher_spec.cr
Normal file
33
spec/rspec/expectations/end_with_matcher_spec.cr
Normal file
|
@ -0,0 +1,33 @@
|
|||
require "../../spec_helper"
|
||||
|
||||
# Examples taken from:
|
||||
# https://relishapp.com/rspec/rspec-expectations/v/3-8/docs/built-in-matchers/end-with-matcher
|
||||
# and modified to fit Spectator and Crystal.
|
||||
Spectator.describe "`end_with` matcher" do
|
||||
context "string usage" do
|
||||
describe "this string" do
|
||||
it { is_expected.to end_with "string" }
|
||||
it { is_expected.not_to end_with "stringy" }
|
||||
|
||||
# deliberate failures
|
||||
# TODO: Add support for expected failures.
|
||||
xit { is_expected.not_to end_with "string" }
|
||||
xit { is_expected.to end_with "stringy" }
|
||||
end
|
||||
end
|
||||
|
||||
context "array usage" do
|
||||
describe [0, 1, 2, 3, 4] do
|
||||
it { is_expected.to end_with 4 }
|
||||
# TODO: Add support for multiple items at the end of an array.
|
||||
# it { is_expected.to end_with 3, 4 }
|
||||
it { is_expected.not_to end_with 3 }
|
||||
# it { is_expected.not_to end_with 0, 1, 2, 3, 4, 5 }
|
||||
|
||||
# deliberate failures
|
||||
# TODO: Add support for expected failures.
|
||||
xit { is_expected.not_to end_with 4 }
|
||||
xit { is_expected.to end_with 3 }
|
||||
end
|
||||
end
|
||||
end
|
33
spec/rspec/expectations/start_with_matcher_spec.cr
Normal file
33
spec/rspec/expectations/start_with_matcher_spec.cr
Normal file
|
@ -0,0 +1,33 @@
|
|||
require "../../spec_helper"
|
||||
|
||||
# Examples taken from:
|
||||
# https://relishapp.com/rspec/rspec-expectations/v/3-8/docs/built-in-matchers/start-with-matcher
|
||||
# and modified to fit Spectator and Crystal.
|
||||
Spectator.describe "`start_with` matcher" do
|
||||
context "with a string" do
|
||||
describe "this string" do
|
||||
it { is_expected.to start_with "this" }
|
||||
it { is_expected.not_to start_with "that" }
|
||||
|
||||
# deliberate failures
|
||||
# TODO: Add support for expected failures.
|
||||
xit { is_expected.not_to start_with "this" }
|
||||
xit { is_expected.to start_with "that" }
|
||||
end
|
||||
end
|
||||
|
||||
context "with an array" do
|
||||
describe [0, 1, 2, 3, 4] do
|
||||
it { is_expected.to start_with 0 }
|
||||
# TODO: Add support for multiple items at the beginning of an array.
|
||||
# it { is_expected.to start_with(0, 1) }
|
||||
it { is_expected.not_to start_with(2) }
|
||||
# it { is_expected.not_to start_with(0, 1, 2, 3, 4, 5) }
|
||||
|
||||
# deliberate failures
|
||||
# TODO: Add support for expected failures.
|
||||
xit { is_expected.not_to start_with 0 }
|
||||
xit { is_expected.to start_with 3 }
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue