我正在研究ruby.railstutorial.org/ruby-on-rails-tutorial-book.我使用rails 3.2.7,spork,rspec,capybara,launchy和一些警卫:)
我在第3章中有一个非常奇怪的问题:测试:
似乎测试不适用于<head>-Tag中的内容.如果我将<title>-tag放在<body>-tag而不是head-tag中,它可以正常工作.当我把<h1>-tags放在<title>里面 - <head>标签时,它也有效.这很奇怪,不是吗?
请帮帮我搞清楚.
示例来自:ruby.railstutorial.org/chapters/static-pages#code:title_test:
it "should have the right title" do
visit '/static_pages/home'
page.should have_selector('title',
:text => "Ruby on Rails Tutorial Sample App | Home")
end
Run Code Online (Sandbox Code Playgroud)
错误消息是:
失败:
1)静态页面主页应该有标题'Home'失败/错误:page.should have_selector('title',:text =>'| Home')Capybara :: ExpectationNotMet:期望找到带有文本的css"title" |主页"但没有比赛.还找到"",它匹配选择器但不是所有过滤器.#./spec/requests/static_pages_spec.rb:15:在'块(3级)中'
那个工作:
it "should have the h1 'Sample App'" do
visit '/static_pages/home'
page.should have_selector('h1', :text => 'Sample App')
end
Run Code Online (Sandbox Code Playgroud)
呈现的HTML文件:
<!DOCTYPE html>
<html>
<head>
<title>Ruby on Rails Tutorial Sample App | …Run Code Online (Sandbox Code Playgroud) 我最近添加jQuery File Upload到我的rails应用程序类似于以下链接中显示的内容:https://github.com/blueimp/jQuery-File-Upload/wiki/Rails-setup-for-V6.
我看到的每个rails实现版本都有<script id="template-download" type="text/x-tmpl">-part.这些脚本标记内部是用于列出现有数据的模板.
https://github.com/yortz/carrierwave_jquery_file_upload/blob/master/app/views/pictures/_template-download.html.erb上还有一个<script id="template-download" type="text/x-jquery-tmpl">版本非常类似于.x-tmpl
我的问题是:
有什么好处x-tmpl?
在github.com/blueimp/jQuery-File-Upload/wiki/Template-Engine写道:
"但是,你不需要使用这个特定的模板引擎,可以用不同的实现来替换它,通过设置uploadTemplateId,downloadTemplateId,uploadTemplate和downloadTemplate选项"对我而言,听起来它可能使用普通
_partial_xy.html.erb而不是x-tmpl.
我错了吗?
如果是的话,至少可以在模板中使用rails helper,如number_to_currency,还是我必须像jquery.fileupload-ui.js中的formatFileSize那样实现它?
jquery jquery-templates ruby-on-rails-3.2 blueimp multiple-file-upload