1

コントローラーのテストパスを取得しようとしています...私のroutes.rb

namespace :school do
  resource :account, :except => [:new, :create, :destroy], :controller => 'account'
  resources :classes, :path => "" do
   resources :discussions do
    resources :comments
  end
  resources :materials
end
end 

私のディスカッションコントローラーの仕様:

describe "POST 'create'" do
 before(:each) do
  @user = FactoryGirl.create(:coordinator_user)
  login_user(@user)
  @klass = FactoryGirl.build(:klass)
  @klass.creator = @user
  @klass.save
  @parameters = FactoryGirl.attributes_for(:discussion, :klass_id => @klass, :user_id => @user)
end

context "with valid parameters" do
  it "creates a new job" do
    expect { post :create, :class_id => @klass.id, :discussion => @parameters }.to   change(Discussion, :count).by(1)
  end

  it "should create a new discussion" do
    post :create, :class_id => @klass.id
    response.should be_redirect
    response.should redirect_to(school_account_path(assigns(:discussion).id))
    assigns(:discussion).should_not be_nil
    assigns(:discussion).should_not be_new_record
  end

end

エラーが発生します: 1) NoMethodError: undefined method empty?' for nil:NilClass # ./lib/slug.rb:3:inslug' ここで nil とは何かを理解できません。

4

0 に答える 0