I have code for the user input:
class Z
def self.input()
val = $stdin.gets.chomp
if val == "123"
p "Ok"
else
p "none"
end
end
end
I want to test different data:
describe "Z" do
it "should receive none"
Object.stub!(:gets){"das"}
Z.input
Object.should_receive(:p).with("none")
end
end
But i get an error:
Failure/Error: Object.should_receive(:p).with("none")
(<Object (class)>).p("none")
expected: 1 time
received: 0 times
How to test the output?
Thanks.
Try this: