【发布时间】:2015-08-16 10:27:15
【问题描述】:
请帮助解决问题。我使用 rails4 + rspec + capybara。
我的页面有标题元素:
<!DOCTYPE html>
<html lang="ru">
<head>
<title>I am learning Rails</title>
<link rel="stylesheet" media="all" href="/assets/albums.self855.css?body=1" data-turbolinks-track="true" />
......
.........
........
rspec 测试:
require 'spec_helper'
describe ImagesController, type: :controller do
describe "index action" do
it 'render title-element on root page' do
visit '/'
#page.should have_selector 'head title', :visible => false
page.should have_selector('head title',
:text => "Складик картинок")
end
end
end
我在控制台中运行:
rspec spec
但控制台显示以下错误消息:
...F
Failures:
1) ImagesController index action render title-element on root page
Failure/Error: page.should have_selector('head title',
expected to find css "head title" with text "I am learning Rails" but there were no matches
# ./spec/controllers/images_controller_spec.rb:37:in `block (3 levels) in <top (required)>'
Finished in 0.94045 seconds (files took 1.95 seconds to load)
4 examples, 1 failure
Failed examples:
rspec ./spec/controllers/images_controller_spec.rb:30 # ImagesController index action render title-element on root page
【问题讨论】:
-
"складик картинок" - 太可爱了:)
标签: ruby-on-rails ruby-on-rails-4 rspec capybara