我是新手上红宝石在铁轨上和我试图测试我的控制器在红宝石在轨道上。 它的工作,但现在我不知道发生了什么,但是当我做了测试,我得到了一个错误信息:`负载':没有这样的文件加载
/Library/Ruby/Gems/1.8/gems/rspec-core-2.10.1/lib/rspec/core/configuration.rb:746:in `load': no such file to load -- /Users/armandodejesussantoyareales/Documents/project_newbie/Estaciones/estaciones/spec/controllers/user_controller_spec.rb (LoadError)
这是我的spec文件:
require 'spec_helper'
describe UserController do
it "create new user" do
get :create, :user => { :email => '[email protected]', :name => 'userexample' }
flash[:notice] = 'new user was successfully created.'
end
describe "signup" do
before { visit signup_path }
let(:submit) { "Create my account" }
describe "with invalid information" do
it "should not create a user" do
expect { click_button submit }.not_to change(User, :count)
end
end
describe "with valid information" do
before do
fill_in "Name", with: "Example User"
fill_in "Email", with: "[email protected]"
fill_in "Password", with: "foobar"
fill_in "Confirmation", with: "foobar"
end
it "should create a user" do
expect { click_button submit }.to change(User, :count).by(1)
end
end
end
end
和这是我的Usercontroller
class UserController < ApplicationController
def new
@user = User.new
end
def create
@user = User.new(params[:user])
if @user.save
redirect_to user_session_path
else
redirect_to new_user_session_path
end
def show
@user = User.find(params[:id])
#redirect_to @user
end
end
与您的问题没有直接关系,但使用Rails控制器的单个名称可能会出现问题。按照惯例,这应该被称为'UsersController',文件名应该是users_controller.rb。 – 2012-07-24 07:42:17