Add specs of snippets from docs

This commit is contained in:
Michael Miller 2020-03-28 10:50:58 -06:00
parent 0322d5bd28
commit 5c24d606dd
7 changed files with 382 additions and 0 deletions

32
spec/docs/subject_spec.cr Normal file
View file

@ -0,0 +1,32 @@
require "../spec_helper"
Spectator.describe "subject" do
subject(array1) { [1, 2, 3] }
subject(array2) { [4, 5, 6] }
it "has different elements" do
expect(array1).to_not eq(subject) # array2 would also work here.
end
let(string) { "foobar" }
it "isn't empty" do
expect(string.empty?).to be_false
end
it "is six characters" do
expect(string.size).to eq(6)
end
let(array) { [0, 1, 2] }
it "modifies the array" do
array[0] = 42
expect(array).to eq([42, 1, 2])
end
it "doesn't carry across tests" do
array[1] = 777
expect(array).to eq([0, 777, 2])
end
end