0
語境 「的答案是正確的」 做如何從RSpec的消除重複
before(:each) do
@answer = stub_model(Answer, :correct => true).as_new_record
assigns[:answer] = @answer
render "answers/summarize"
end
it "should display flashcard context properly" do
response.should contain("Quiz")
end
it "should summarize results" do
response.should contain("is correct")
end
末
語境 「答案是不正確」 做
before(:each) do
@answer = stub_model(Answer, :correct => false).as_new_record
assigns[:answer] = @answer
render "answers/summarize"
end
it "should display flashcard context properly" do
response.should contain("Quiz")
end
it "should summarize results" do
response.should contain("is incorrect")
end
末
我如何避免在上述兩個上下文中重複以下塊?
it "should display flashcard context properly" do
response.should contain("Quiz")
末