이 두 시험 :RSpec에서 'expect'와 'should'사이에 차이가 있습니까?
it "fails to create given a bad player list" do
Team.new("Random name", bad_players).should raise_error
end
및
it "fails to create given a bad player list" do
expect {Team.new("Random name", bad_players)}.to raise_error
end
서로 다른 출력을 리턴 (2 일이 경과하는 동안 첫번째는 실패). 팀 모델의 내용에 따라 둘 다 합격하거나 실패 할 것으로 예상됩니다.
전체 RSpec에 코드는 다음과 같습니다
require_relative 'team'
describe "Team" do
it "has a name" do
Team.new("Random name").should respond_to(:name)
end
it "has a list of players" do
Team.new("Random name").players.should be_kind_of Array
end
it "is favored if it has a celebrity on it"
it "complains if there is a bad word in the name"
context "given a bad list of players" do
let(:bad_players) { {} }
it "fails to create given a bad player list" do
expect { Team.new("Random name", bad_players) }.to raise_error
end
end
end
내가 생각하는 이유 때문에서 유사한 구문이다 일하는 것이 '해야한다'테스트 '는 "이름이"'. 'should'가 틀렸고 'to ... to'이 맞다는 것이 밝혀지면, 나는 다른 것을 사용할 때를 알고 싶습니다. 감사. 권리 측면에서 무엇을 확인하는 차이
should
에게이