Skip to content

Commit

Permalink
Clean up test names
Browse files Browse the repository at this point in the history
  • Loading branch information
icy-arctic-fox committed Jul 26, 2024
1 parent b43127b commit d5e4527
Show file tree
Hide file tree
Showing 11 changed files with 192 additions and 185 deletions.
12 changes: 6 additions & 6 deletions spec/spectator/matchers/built_in/be_a_matcher_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ Spectator.describe BeAMatcher do
end

context "DSL" do
describe "be_a" do
context "with .to" do
describe "`be_a`" do
context "with `.to`" do
it "matches if the value is an instance of the type" do
expect do
expect(42).to be_a(Int32)
Expand Down Expand Up @@ -105,7 +105,7 @@ Spectator.describe BeAMatcher do
end
end

context "with .not_to" do
context "with `.not_to`" do
it "does not match if the value is an instance of the type" do
expect do
expect(42).not_to be_a(Int32)
Expand Down Expand Up @@ -145,8 +145,8 @@ Spectator.describe BeAMatcher do
end
end

describe "be_an" do
context "with .to" do
describe "`be_an`" do
context "with `.to`" do
it "matches if the value is an instance of the type" do
expect do
expect(42).to be_an(Int32)
Expand Down Expand Up @@ -191,7 +191,7 @@ Spectator.describe BeAMatcher do
end
end

context "with .not_to" do
context "with `.not_to`" do
it "does not match if the value is an instance of the type" do
expect do
expect(42).not_to be_an(Int32)
Expand Down
6 changes: 3 additions & 3 deletions spec/spectator/matchers/built_in/be_between_matcher_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Spectator.describe BeBetweenMatcher do
end

context "DSL" do
describe "be_between" do
describe "`be_between`" do
it "is inclusive by default" do
expect do
expect(40).to be_between(40, 50)
Expand All @@ -135,7 +135,7 @@ Spectator.describe BeBetweenMatcher do
end.to pass_check
end

context "with .to" do
context "with `.to`" do
it "matches if the value is between the min and max" do
expect do
expect(42).to be_between(40, 50)
Expand Down Expand Up @@ -243,7 +243,7 @@ Spectator.describe BeBetweenMatcher do
end
end

context "with .not_to" do
context "with `.not_to`" do
it "does not match if the value is between the min and max" do
expect do
expect(42).not_to be_between(40, 50)
Expand Down
6 changes: 3 additions & 3 deletions spec/spectator/matchers/built_in/be_blank_matcher_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ Spectator.describe BeBlankMatcher do
end

context "DSL" do
describe "be_blank" do
context "with .to" do
describe "`be_blank`" do
context "with `.to`" do
it "matches if the value is blank" do
object = BlankObject.new
expect do
Expand Down Expand Up @@ -82,7 +82,7 @@ Spectator.describe BeBlankMatcher do
end
end

context "with .not_to" do
context "with `.not_to`" do
it "does not match if the value is blank" do
object = BlankObject.new
expect do
Expand Down
150 changes: 76 additions & 74 deletions spec/spectator/matchers/built_in/be_close_matcher_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -51,82 +51,84 @@ Spectator.describe BeCloseMatcher do
end

describe "DSL" do
context "with .to" do
it "matches if the value is within the delta" do
expect do
expect(1.01).to be_close(1.0, delta: 0.1)
end.to pass_check
describe "`be_close`" do
context "with `.to`" do
it "matches if the value is within the delta" do
expect do
expect(1.01).to be_close(1.0, delta: 0.1)
end.to pass_check
end

it "does not match if the value is outside the delta" do
expect do
expect(1.11).to be_close(1.0, delta: 0.1)
end.to fail_check <<-MESSAGE
Expected: 1.11
to be within: 1.0 ± 0.1
MESSAGE
end

it "matches if the values are equal" do
expect do
expect(1.0).to be_close(1.0, delta: 0.1)
end.to pass_check
end

it "matches if the value is at the minimum" do
expect do
expect(0.9).to be_close(1.0, delta: 0.1)
end.to pass_check
end

it "matches if the value is at the maximum" do
expect do
expect(1.1).to be_close(1.0, delta: 0.1)
end.to pass_check
end
end

it "does not match if the value is outside the delta" do
expect do
expect(1.11).to be_close(1.0, delta: 0.1)
end.to fail_check <<-MESSAGE
Expected: 1.11
to be within: 1.0 ± 0.1
MESSAGE
end

it "matches if the values are equal" do
expect do
expect(1.0).to be_close(1.0, delta: 0.1)
end.to pass_check
end

it "matches if the value is at the minimum" do
expect do
expect(0.9).to be_close(1.0, delta: 0.1)
end.to pass_check
end

it "matches if the value is at the maximum" do
expect do
expect(1.1).to be_close(1.0, delta: 0.1)
end.to pass_check
end
end

context "with .not_to" do
it "does not match if the value is within the delta" do
expect do
expect(1.01).not_to be_close(1.0, delta: 0.1)
end.to fail_check <<-MESSAGE
Expected: 1.01
to be outside: 1.0 ± 0.1
MESSAGE
end

it "matches if the value is outside the delta" do
expect do
expect(1.11).not_to be_close(1.0, delta: 0.1)
end.to pass_check
end

it "does not match if the values are equal" do
expect do
expect(1.0).not_to be_close(1.0, delta: 0.1)
end.to fail_check <<-MESSAGE
Expected: 1.0
to be outside: 1.0 ± 0.1
MESSAGE
end

it "does not match if the value is at the minimum" do
expect do
expect(0.9).not_to be_close(1.0, delta: 0.1)
end.to fail_check <<-MESSAGE
Expected: 0.9
to be outside: 1.0 ± 0.1
MESSAGE
end

it "does not match if the value is at the maximum" do
expect do
expect(1.1).not_to be_close(1.0, delta: 0.1)
end.to fail_check <<-MESSAGE
Expected: 1.1
to be outside: 1.0 ± 0.1
MESSAGE
context "with `.not_to`" do
it "does not match if the value is within the delta" do
expect do
expect(1.01).not_to be_close(1.0, delta: 0.1)
end.to fail_check <<-MESSAGE
Expected: 1.01
to be outside: 1.0 ± 0.1
MESSAGE
end

it "matches if the value is outside the delta" do
expect do
expect(1.11).not_to be_close(1.0, delta: 0.1)
end.to pass_check
end

it "does not match if the values are equal" do
expect do
expect(1.0).not_to be_close(1.0, delta: 0.1)
end.to fail_check <<-MESSAGE
Expected: 1.0
to be outside: 1.0 ± 0.1
MESSAGE
end

it "does not match if the value is at the minimum" do
expect do
expect(0.9).not_to be_close(1.0, delta: 0.1)
end.to fail_check <<-MESSAGE
Expected: 0.9
to be outside: 1.0 ± 0.1
MESSAGE
end

it "does not match if the value is at the maximum" do
expect do
expect(1.1).not_to be_close(1.0, delta: 0.1)
end.to fail_check <<-MESSAGE
Expected: 1.1
to be outside: 1.0 ± 0.1
MESSAGE
end
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/spectator/matchers/built_in/be_empty_matcher_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ Spectator.describe BeEmptyMatcher do
end

context "DSL" do
describe "be_empty" do
context "with .to" do
describe "`be_empty`" do
context "with `.to`" do
it "matches if the value is empty" do
expect do
expect(EmptyObject.new).to be_empty
Expand Down Expand Up @@ -97,7 +97,7 @@ Spectator.describe BeEmptyMatcher do
end
end

context "with .not_to" do
context "with `.not_to`" do
it "does not match if the value is empty" do
object = EmptyObject.new
expect do
Expand Down
6 changes: 3 additions & 3 deletions spec/spectator/matchers/built_in/be_in_matcher_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ Spectator.describe BeInMatcher do
end

describe "DSL" do
describe "be_in" do
context "with .to" do
describe "`be_in`" do
context "with `.to`" do
it "matches if the value is in the list" do
expect do
expect(2).to be_in([1, 2, 3])
Expand All @@ -54,7 +54,7 @@ Spectator.describe BeInMatcher do
end
end

context "with .not_to" do
context "with `.not_to`" do
it "matches if the value is not in the list" do
expect do
expect(4).not_to be_in([1, 2, 3])
Expand Down
12 changes: 6 additions & 6 deletions spec/spectator/matchers/built_in/be_infinite_matcher_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ Spectator.describe BeInfiniteMatcher do
end

context "DSL" do
describe "#be_infinite" do
context "with .to" do
describe "`be_infinite`" do
context "with `.to`" do
it "does not match a finite value" do
object = InfiniteObject.new
expect do
Expand Down Expand Up @@ -184,7 +184,7 @@ Spectator.describe BeInfiniteMatcher do
end
end

context "with .not_to" do
context "with `.not_to`" do
it "matches a finite object" do
object = InfiniteObject.new(false)
expect do
Expand Down Expand Up @@ -241,8 +241,8 @@ Spectator.describe BeInfiniteMatcher do
end
end

describe "#be_finite" do
context "with .to" do
describe "`be_finite`" do
context "with `.to`" do
it "matches a finite value" do
object = InfiniteObject.new(false)
expect do
Expand Down Expand Up @@ -286,7 +286,7 @@ Spectator.describe BeInfiniteMatcher do
end
end

context "with .not_to" do
context "with `.not_to`" do
it "does not match finite value" do
object = InfiniteObject.new(false)
expect do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ Spectator.describe BeInstanceOfMatcher do
end

describe "DSL" do
describe "be_instance_of" do
context "with .to" do
describe "`be_instance_of`" do
context "with `.to`" do
it "matches if the object is the exact type" do
expect do
expect("foo").to be_instance_of(String)
Expand Down Expand Up @@ -115,7 +115,7 @@ Spectator.describe BeInstanceOfMatcher do
end
end

context "with .not_to" do
context "with `.not_to`" do
it "does not match if the object is the exact type" do
expect do
expect("foo").not_to be_instance_of(String)
Expand Down
6 changes: 3 additions & 3 deletions spec/spectator/matchers/built_in/be_matcher_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ Spectator.describe BeMatcher do
end

describe "DSL" do
describe "be" do
context "with .to" do
describe "`be`" do
context "with `.to`" do
it "matches if the objects are the same" do
object = [] of Int32
expect do
Expand Down Expand Up @@ -132,7 +132,7 @@ Spectator.describe BeMatcher do
end
end

context "with .not_to" do
context "with `.not_to`" do
it "does not match if the objects are the same" do
object = [] of Int32
expect do
Expand Down
Loading

0 comments on commit d5e4527

Please sign in to comment.