我是Ruby on Rails的新手。目前使用特立獨行的10.9.3,Rails 4.我嘗試運行rspec命令時出現以下錯誤。Michael Hartl的rails教程第3章,rspec中的錯誤
這裏是錯誤,我得到:
rspec ./spec/controllers/pages_controller_spec.rb:35 # PagesController GET 'about' should have the right title
rspec ./spec/controllers/pages_controller_spec.rb:24 # PagesController GET 'contact' should have the right title
rspec ./spec/controllers/pages_controller_spec.rb:11 # PagesController GET 'home' should have the right title
我的Gemfile包括:
group :development, :test do
gem 'rspec-rails', '2.14.2'
end
group :test do
gem 'rspec', '2.14.1'
gem 'spork', '0.9.0.rc'
end
也是我pages_controller_spec.rb
require 'spec_helper'
describe PagesController do
render_views
describe "GET 'home'" do
it "returns http success" do
get 'home'
response.should be_success
end
it "should have the right title" do
get 'home'
response.should have_selector("title", :content => "Ruby on Rails Tutorial Sample App | Home")
end
end
describe "GET 'contact'" do
it "returns http success" do
get 'contact'
response.should be_success
end
it "should have the right title" do
get 'contact'
response.should have_selector("title", :content => "Ruby on Rails Tutorial Sample App | Contact")
end
end
describe "GET 'about'" do
it "returns http success" do
get 'about'
response.should be_success
end
it "should have the right title" do
get 'about'
response.should have_selector("title", :content => "Ruby on Rails Tutorial Sample App | About")
end
end
end
從下面的評論
控制器代碼:
class PagesController < ApplicationController
def home
end
def contact
end
def about
end
end
邁克爾的教程是最有效的:)無論如何..我發現非常有用的一件事是'gem launchy'。獲取它,你可以在'visit'後面調用'save_and_open_page'來檢查頁面的外觀。 – pawel7318
實際控制代碼如下:類PagesController
\t
\t \t\t \t \t這是主頁 Ruby on Rails的教程 示例應用程序。 \t \t
\t –