问题
I have this problem in RSPEC: be_true
and be_false
seems not to be working in Rspec 2.1
.
This is my specs file for the class Zombie
:
spec/lib/zombie_spec.rb
require "spec_helper"
require "zombie"
describe "A Zombie" do
# your examples (tests) go here
it "is named Ash" do
zombie=Zombie.new
zombie.name.should=="Ash"
end
it "has no brains" do
zombie= Zombie.new
#zombie.brains.should < 1
zombie.brains.should be <1
end
it "is alive" do
zombie=Zombie.new
zombie.alive.should==false
end
it "is hungry" do
zombie=Zombie.new
#zombie.hungry?.should==true Working correct
zombie.hungry?.should be_true # Not working
end
end
This is the file where I have the class Zombie
:
lib/zombie.rb
class Zombie
attr_accessor :name,:brains,:alive
def initialize
@name="Ash"
@brains=0
@alive=false
end
def hungry?
true
end
end
Console:
fernando:~/estudio/Zombies$ rspec spec/lib/zombie_spec.rb ...F
Failures:
1) A Zombie is hungry
Failure/Error: zombie.hungry?.should be_true
expected true to respond to 'true'?
# ./spec/lib/zombie_spec.rb:25:in `block (2 levels) in <top (required)>'
Can you help me with this problem?
来源:https://stackoverflow.com/questions/24995582/command-be-true-seems-not-to-work-in-rspec-2-1