Sto scrivendo una specifica di visualizzazione con RSpec e continuo ad avere questo problema. Il test troverà textarea ma fallisce quando provo a testare il contenuto. Eventuali suggerimenti?come utilizzare Rspec per verificare il contenuto di una textarea in una vista?
Questo è il test con cui ho problemi.
describe "reminders/edit.html.erb" do
before(:each) do
@reminder = Factory(:reminder)
end
it "should render the form to edit a reminder" do
assign :reminder, @reminder
render
rendered.should have_selector("form", :method => "post", :action => reminder_path(@reminder)) do |f|
f.should have_selector("input", :type => "text", :name => "reminder[title]", :value => "The Title" )
f.should have_selector("textarea", :name => "reminder[content]", :value => 'The big content')
f.should have_selector("input", :type => "submit")
end
end
Potrei fare tutto questo torto dal momento che sono abbastanza nuovo a TDD, ma sto vedendo che questo test viene superato quando rimuovo il valore del textarea che in realtà mi confonde. Quindi c'è un modo per testare una textarea per i suoi contenuti?
Grazie, il cappello ha funzionato perfettamente! Ed è esattamente quello che stavo cercando. –
Penso che ': content' ora sia': text' – aceofspades