0

次のコードがあります。

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がどのように機能するべきですか、それとも何か間違っていますか?

4

1 に答える 1