我是新手上紅寶石在鐵軌上和我試圖測試我的控制器在紅寶石在軌道上。 它的工作,但現在我不知道發生了什麼,但是當我做了測試,我得到了一個錯誤信息:`負載':沒有這樣的文件加載
/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