我有以下代码:
describe "when visiting roll call with no notes" do
before do
login_as_sensei
@dojo = FactoryGirl.create(:dojo, name: "Melbourne")
@time = FactoryGirl.create(:times, dojo: @dojo)
@roll = FactoryGirl.create(:roll_call)
visit time_roll_calls_path("melbourne", "14-2-2013", "1000")
end
specify { @roll.notes.should be_blank }
it { should_not have_content("This is a note!") }
describe "and filling in note information correctly" do
before do
fill_in "roll_call[notes]", with: "This is a note!"
click_button "Add Notes"
end
it { should have_content("This is a note!") } # 'it' refers to the page
specify { RollCall.last.notes.should_not be_blank }
specify { @roll.notes.should_not be_blank }
specify { @roll.reload.notes.should_not be_blank }
end
end
据我所知,最后所有 4 个测试都应该通过,但是只有前 2 个可以通过:
it { should have_content("This is a note!") }
specify { RollCall.last.notes.should_not be_blank }
最后 2 个返回以下错误:
1) RollCalls when visiting roll call with no notes and filling in note information correctly
Failure/Error: specify { @roll.notes.should_not be_blank }
expected blank? to return false, got true
# ./spec/features/roll_calls_spec.rb:241:in `block (4 levels) in <top (required)>'
2) RollCalls when visiting roll call with no notes and filling in note information correctly
Failure/Error: specify { @roll.reload.notes.should_not be_blank }
expected blank? to return false, got true
# ./spec/features/roll_calls_spec.rb:242:in `block (4 levels) in <top (required)>'
这是 rspec 应该如何工作还是我做错了什么?