mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add spec for GitHub issue 43
https://github.com/icy-arctic-fox/spectator/issues/43
This commit is contained in:
parent
70efa1ad78
commit
da3fbc9607
1 changed files with 51 additions and 0 deletions
51
spec/issues/github_issue_43_spec.cr
Normal file
51
spec/issues/github_issue_43_spec.cr
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
require "../spec_helper"
|
||||||
|
|
||||||
|
class Person
|
||||||
|
def initialize(@dog = Dog.new)
|
||||||
|
end
|
||||||
|
|
||||||
|
def pet
|
||||||
|
@dog.pet
|
||||||
|
end
|
||||||
|
|
||||||
|
def pet_more
|
||||||
|
@dog.pet(5)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Dog
|
||||||
|
def initialize
|
||||||
|
end
|
||||||
|
|
||||||
|
def pet(times = 2)
|
||||||
|
"woof" * times
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Spectator.describe Person do
|
||||||
|
mock Dog
|
||||||
|
|
||||||
|
describe "#pet" do
|
||||||
|
it "pets the persons dog" do
|
||||||
|
dog = mock(Dog)
|
||||||
|
person = Person.new(dog)
|
||||||
|
allow(dog).to receive(pet()).and_return("woof")
|
||||||
|
|
||||||
|
result = person.pet
|
||||||
|
|
||||||
|
expect(dog).to have_received(pet()).with(2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#pet_more" do
|
||||||
|
it "pets the persons dog alot" do
|
||||||
|
dog = mock(Dog)
|
||||||
|
person = Person.new(dog)
|
||||||
|
allow(dog).to receive(pet()).and_return("woof")
|
||||||
|
|
||||||
|
result = person.pet_more
|
||||||
|
|
||||||
|
expect(dog).to have_received(pet()).with(5)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue