mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add specs for anonymous and null object doubles docs
This commit is contained in:
parent
827b69483b
commit
c228984956
2 changed files with 31 additions and 0 deletions
15
spec/docs/anonymous_doubles_spec.cr
Normal file
15
spec/docs/anonymous_doubles_spec.cr
Normal file
|
@ -0,0 +1,15 @@
|
|||
require "../spec_helper"
|
||||
|
||||
# https://gitlab.com/arctic-fox/spectator/-/wikis/Anonymous-Doubles
|
||||
Spectator.describe "Anonymous Doubles Docs" do
|
||||
it "does something" do
|
||||
dbl = double(foo: 42)
|
||||
expect(dbl.foo).to eq(42)
|
||||
end
|
||||
|
||||
it "does something" do
|
||||
dbl = double(foo: 42)
|
||||
allow(dbl).to receive(:foo).and_return(123)
|
||||
expect(dbl.foo).to eq(123)
|
||||
end
|
||||
end
|
16
spec/docs/null_objects_spec.cr
Normal file
16
spec/docs/null_objects_spec.cr
Normal file
|
@ -0,0 +1,16 @@
|
|||
require "../spec_helper"
|
||||
|
||||
# https://gitlab.com/arctic-fox/spectator/-/wikis/Null-Objects
|
||||
Spectator.describe "Null Objects Docs" do
|
||||
double :my_double
|
||||
|
||||
it "returns itself for undefined methods" do
|
||||
dbl = double(:my_double).as_null_object
|
||||
expect(dbl.some_undefined_method).to be(dbl)
|
||||
end
|
||||
|
||||
it "can be used to chain methods" do
|
||||
dbl = double(:my_double).as_null_object
|
||||
expect(dbl.foo.bar.baz).to be(dbl)
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue