0

我是ruby​​ on rails的新手,我正在尝试在ruby​​ on rails上测试我的控制器。它以前工作过,但现在我不知道发生了什么,但是当我进行测试时,我收到了下一条错误消息:

/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)

这是我的规格文件:

require 'spec_helper'

describe UserController do

it "create new user" do
    get :create, :user => { :email => 'foo@example.com', :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: "user@example.com"
    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
4

1 回答 1

0
/Users/armandodejesussantoyareales/Documents/project_newbie/Estaciones/estaciones/spec/controllers/user_controller_spec.rb

你确定那是正确的道路吗?在终端中,当您输入以下内容时会发生什么:

ls /Users/armandodejesussantoyareales/Documents/project_newbie/Estaciones/estaciones/spec/controllers/user_controller_spec.rb

如果您收到错误消息No such file or directory,则该路径不存在。如果它只是回响路径,那很好。

或者,您可以手动查找此文件并验证路径。但无论哪种方式,我的猜测是您只是错误地输入了您的规范文件的路径。

于 2012-07-23T15:07:19.340 回答