Shy*_*ani 6 ruby ruby-on-rails railstutorial.org
你好,我是铁路新手.我正在关注Michael Hartl的railstutorial.org.我陷入了清单4.5的第4章:当我点击$ bundle exec rake test它时显示的结果与根据教程显示的结果不同.注意:我使用Ubuntu 15.10作为平台.
我击中的结果 $ bundle exec rake test
/home/shyambhimani/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/minitest-reporters-1.0.5/lib/minitest/minitest_reporter_plugin.rb:8:in `block in plugin_minitest_reporter_init': undefined method `add_defaults' for #<Guard::Minitest::Reporter:0x005580a1496930> (NoMethodError)
from /home/shyambhimani/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/minitest-reporters-1.0.5/lib/minitest/minitest_reporter_plugin.rb:6:in `each'
from /home/shyambhimani/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/minitest-reporters-1.0.5/lib/minitest/minitest_reporter_plugin.rb:6:in `plugin_minitest_reporter_init'
from /home/shyambhimani/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/minitest-5.8.4/lib/minitest.rb:74:in `block in init_plugins'
from /home/shyambhimani/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/minitest-5.8.4/lib/minitest.rb:72:in `each'
from /home/shyambhimani/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/minitest-5.8.4/lib/minitest.rb:72:in `init_plugins'
from /home/shyambhimani/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/minitest-5.8.4/lib/minitest.rb:123:in `run'
from /home/shyambhimani/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/minitest-5.8.4/lib/minitest.rb:56:in `block in autorun'
Run Code Online (Sandbox Code Playgroud)
application.html.erb
<!DOCTYPE html>
<html>
<head>
<title><%= full_title(yield(:title)) %></title>
<%= stylesheet_link_tag 'application', media: 'all',
'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
application_helper.rb
module ApplicationHelper
# Returns the full title on a per-page basis.
def full_title(page_title = '')
base_title = "Ruby on Rails Tutorial Sample App"
if page_title.empty?
base_title
else
page_title + " | " + base_title
end
end
end
Run Code Online (Sandbox Code Playgroud)
static_pages_controller_test.rb
require 'test_helper'
class StaticPagesControllerTest < ActionController::TestCase
test "should get home" do
get :home
assert_response :success
assert_select "title", "Ruby on Rails Tutorial Sample App"
end
test "should get help" do
get :help
assert_response :success
assert_select "title", "Help | Ruby on Rails Tutorial Sample App"
end
test "should get about" do
get :about
assert_response :success
assert_select "title", "About | Ruby on Rails Tutorial Sample App"
end
end
Run Code Online (Sandbox Code Playgroud)
test_helper.rb中
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require "minitest/reporters"
Minitest::Reporters.use!
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical
# order.
fixtures :all
# Add more helper methods to be used by all tests here...
end
Run Code Online (Sandbox Code Playgroud)
的Gemfile
source 'https://rubygems.org'
gem 'rails', '4.2.6'
gem 'sass-rails', '5.0.2'
gem 'uglifier', '2.5.3'
gem 'coffee-rails', '4.1.0'
gem 'jquery-rails', '4.0.3'
gem 'turbolinks', '2.3.0'
gem 'jbuilder', '2.2.3'
gem 'sdoc', '0.4.0', group: :doc
group :development, :test do
gem 'sqlite3', '1.3.9'
gem 'byebug', '3.4.0'
gem 'web-console', '2.0.0.beta3'
gem 'spring', '1.1.3'
end
group :test do
gem 'minitest-reporters', '1.0.5'
gem 'mini_backtrace', '0.1.3'
gem 'guard-minitest', '2.3.1'
end
group :production do
gem 'pg', '0.17.1'
gem 'rails_12factor', '0.0.2'
end
Run Code Online (Sandbox Code Playgroud)
请指导我如何摆脱错误.
看起来你正在使用RubyDep,这是一个可以帮助你避免不安全的Ruby版本的工具.RubyDep在第一行告诉你:
RubyDep:警告:您的Ruby存在安全漏洞!请升级!(......)
查看堆栈跟踪.../.rbenv/versions/2.2.3/...的其他行的path(),看起来您正在使用随rbenv一起安装的Ruby 2.2.3版.
RubyDep是对的:Ruby中2.2.3存在一个已知的漏洞.
有更新版本的Ruby可用.您可以升级到最新2.2.x版本(或最新版本2.3.x).我建议升级到2.2.5,因为我不知道教程是否兼容2.3.x.
要rbenv按照以下步骤将Ruby升级到更新版本(我想你曾经brew安装过rbenv):
brew update # update to the latest brew version
brew upgrade ruby-build # update Ruby version library
brew upgrade rbenv # update rbenv
rbenv install 2.2.5 # install Ruby 2.2.5
Run Code Online (Sandbox Code Playgroud)
将2.2.5设置为默认的Ruby版本:
rbenv global 2.2.5
Run Code Online (Sandbox Code Playgroud)
更新您的Rails应用程序以使用此Ruby版本.为此,请检查以下文件(如果存在,可能会隐藏它们)并更改该文件中的Ruby版本:
.ruby-version
Gemfile
Run Code Online (Sandbox Code Playgroud)
您可能想要在应用程序根目录中检查您使用的是Ruby的更新版本:
ruby -v # should return `ruby 2.2.5p...`
Run Code Online (Sandbox Code Playgroud)
最后一步是重新安装宝石:
gem install bundler
bundler install
Run Code Online (Sandbox Code Playgroud)
更新是否成功?
bundle exec rake test
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
983 次 |
| 最近记录: |