0
我谷歌和讀取約4個小時的stackoverflow,但不明白,爲什麼類似於鐵路教程測試失敗。RSpec:應該has_selector失敗,但標題存在
測試很簡單:
# encoding: utf-8
require 'spec_helper'
describe "StaticPages" do
subject { page }
describe "Contacts page" do
before { visit contacts_path }
it { should have_selector(:title, text: "|") }
end
end
所以,我想補充save_and_open_page看看,有什麼錯我的聯繫人頁面,但它看起來不錯。標題標籤存在幷包含「|」。
我不明白,怎麼了。我有:
- tryed get instead visit;
- 反應頁面;
- 檢查其他物體永久性(body.should have_selector(:h1))。
此外,我試着瞭解,如何提高rspec輸出到更多infomative。在現在我明白了:
Failure/Error: it { should have_selector(:title, text: "|") }
expected id :title with text "|" to return something
提問和回答的http://stackoverflow.com/questions/5129423/capybara-how-to-test-the-title-of-a-page –
我不是問怎麼樣。我問爲什麼have_selector不起作用。我發現,如果我使用字符串「標題」,而不是符號:標題 - 我的示例工作正常。 – Kulti