2011-01-11 16 views
1

私はrails 3 w/rspec-rails 2.4.1を使用していますが、モデル生成中にエラーが発生します。グーグルで何も見つかりません。誰でも何が起こっているのか知っていますか?rspec未定義のローカル変数またはメソッド `class_nesting_depth`

TIA

$ rails g model CourseRating student_id:integer course_id:integer difficulty:integer usefulness:integer 
    invoke active_record 
    create db/migrate/20110111044035_create_course_ratings.rb 
    create app/models/course_rating.rb 
    invoke rspec 
    create  spec/models/course_rating_spec.rb 
(erb):1:in `template': undefined local variable or method `class_nesting_depth' for #<Rspec::Generators::ModelGenerator:0x0000010424e460> (NameError) 
    from /Users/glurban/.rvm/rubies/ruby-1.9.2-rc2/lib/ruby/1.9.1/erb.rb:753:in `eval' 
    from /Users/glurban/.rvm/rubies/ruby-1.9.2-rc2/lib/ruby/1.9.1/erb.rb:753:in `result' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/actions/file_manipulation.rb:111:in `block in template' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/actions/create_file.rb:54:in `call' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/actions/create_file.rb:54:in `render' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/actions/create_file.rb:63:in `block (2 levels) in invoke!' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/actions/create_file.rb:63:in `open' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/actions/create_file.rb:63:in `block in invoke!' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/actions/empty_directory.rb:114:in `call' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/actions/empty_directory.rb:114:in `invoke_with_conflict_check' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/actions/create_file.rb:61:in `invoke!' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/actions.rb:95:in `action' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/actions/create_file.rb:26:in `create_file' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/actions/file_manipulation.rb:110:in `template' 
    from /Users/glurban/code/recruitd/lib/generators/rspec/model/model_generator.rb:10:in `create_test_file' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/task.rb:22:in `run' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `block in invoke_all' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `each' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `map' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `invoke_all' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/group.rb:226:in `dispatch' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/invocation.rb:109:in `invoke' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/group.rb:269:in `block in _invoke_for_class_method' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/shell.rb:74:in `with_padding' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/group.rb:258:in `_invoke_for_class_method' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/group.rb:150:in `_invoke_from_option_test_framework' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/task.rb:22:in `run' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `block in invoke_all' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `each' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `map' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `invoke_all' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/group.rb:226:in `dispatch' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/invocation.rb:109:in `invoke' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/group.rb:269:in `block in _invoke_for_class_method' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/shell.rb:74:in `with_padding' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/group.rb:258:in `_invoke_for_class_method' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/group.rb:150:in `_invoke_from_option_orm' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/task.rb:22:in `run' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `block in invoke_all' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `each' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `map' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `invoke_all' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/group.rb:226:in `dispatch' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/thor-0.14.6/lib/thor/base.rb:389:in `start' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/railties-3.0.0/lib/rails/generators.rb:163:in `invoke' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/railties-3.0.0/lib/rails/commands/generate.rb:10:in `<top (required)>' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `block in require' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:225:in `block in load_dependency' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:591:in `new_constants_in' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:225:in `load_dependency' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require' 
    from /Users/glurban/.rvm/gems/ruby-1.9.2-rc2/gems/railties-3.0.0/lib/rails/commands.rb:17:in `<top (required)>' 
    from script/rails:6:in `require' 
    from script/rails:6:in `<main>' 

編集:ここにlib/generators/rspec/model/model_generator.rbです:

require 'generators/rspec' 

module Rspec 
    module Generators 
    class ModelGenerator < Base 
     argument :attributes, :type => :array, :default => [], :banner => "field:type field:type" 
     class_option :fixture, :type => :boolean 

     def create_test_file 
     template 'model_spec.rb', File.join('spec/models', class_path, "#{file_name}_spec.rb") 
     end 

     hook_for :fixture_replacement 

     def create_fixture_file 
     if options[:fixture] && options[:fixture_replacement].nil? 
      template 'fixtures.yml', File.join('spec/fixtures', "#{table_name}.yml") 
     end 
     end 
    end 
    end 
end 
+0

アプリケーションの 'lib/generators/rspec/model/model_generator.rb'ファイルは何をしていますか?それは目立たないように見えるスタックトレースに現れます。それは失敗している。 –

+0

ありがとうございます。編集した質問にファイルの内容を追加しました。 – unsorted

+0

Hmm。それはRSpecコードですが、そこからロードされるのはなぜですか? (/ glurban/code/recruitd)。 gem/plugin設定の問題のように見えます。 – zetetic

答えて

1

私は https://github.com/pjb3/rails3-generators.gitから私のアプリケーションのlibフォルダにポール・バリーのHAMLジェネレータをクローン化したときに私のために犯人がいました。これは、私のすべてのジェネレータがrspecテストを作成しているのと同じエラーが発生しました。私はすぐにそれを取り除き、その後はうまくいった。

関連する問題