我正在关注代码和页面具体说明的内容,我唯一缺少的是 Ruby on Rails 的 rspec gem,因为我无法获得它(为 rspec 安装提供此错误:“ E: Unable to locate package rspec ”,因此任何帮助将不胜感激)由于无法找到包。
这是我的整个 pages_controller_spec.rb 文件,并且当 rails 服务器尝试连接到页面时显示的错误显示在标题中(如果在这里无法看到,则再次显示:“ PagesController:Class 的未定义方法 `describe' ”)。
注意:我也试过没有“require 'spec_helper'”的代码,它仍然无法运行。
class PagesController < ApplicationController
def home
end
def contact
end
def about
end
require 'spec_helper'
describe PagesController do
render_views
describe "GET 'home'" do
it "should be successful" 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 "should be successful" 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 "should be successful" 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
end