我有一個非常簡單的RSpec水豚have_selector(),似乎並沒有工作,我無法弄清楚爲什麼......但可能是簡單的東西。RSpec水豚have_selector測試不工作
這裏的RSpec的要求測試:
describe 'with valid information'
let(:user) { FactoryGirl.create(:user) }
before do
fill_in 'Email', with: user.email
fill_in 'Password, with: user.password
click_button 'Login'
end
it { should have_selector('p', text: user.first_name) }
...
end
在new.html.erb
的會議,我只是有這樣的事情:
<% if logged_in? %>
<p><%= current_user.first_name %></p>
<% else %>
<%= form_for(:session, url: sessions_path) do |f| %>
...
<% end %>
登錄表單完全在瀏覽器session#new
作品。我可以很好地登錄,並能夠在p
標籤中查看名字。問題似乎是水豚部分,因爲其他it
測試檢查頁面上的h1
標記(無論登錄是否存在)都可以正常工作。
有誰知道這個問題可能是什麼?
在此先感謝您的幫助!
您是否檢查過呈現的HTML? –