rspecが実行できなくなりました。bundler: failed to load command: rspec
解決済
回答 1
投稿
- 評価
- クリップ 0
- VIEW 3,796
2週間前に問題なく実行できていたrspecコマンドがいつのまにか実行できなくなりました。
faild to loadと出ているので、パスとか、ファイルの配置がおかしいのではと思っておりますが具体的にどうすれば良いかわかりません。
見当つくかたいらっしゃいましたら、何かアドバイスいただけますと幸いです。
ログ。
$ bundle exec rspec spec/controllers/article_controller_spec.rb
/Users/username/project/hoge/huga/config/initializers/mongoid_monkeypatch.rb:20: warning: already initialized constant Moped::BSON
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/gems/moped-1.5.3/lib/moped/bson/extensions/array.rb:2: warning: previous definition of BSON was here
bundler: failed to load command: rspec (/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/bin/rspec)
NoMethodError: undefined method `id' for nil:NilClass
/Users/username/project/hoge/huga/spec/support/factories/available_products.rb:12:in `block (3 levels) in <top (required)>'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/gems/factory_girl-4.5.0/lib/factory_girl/trait.rb:12:in `instance_eval'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/gems/factory_girl-4.5.0/lib/factory_girl/trait.rb:12:in `initialize'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/gems/factory_girl-4.5.0/lib/factory_girl/definition_proxy.rb:167:in `new'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/gems/factory_girl-4.5.0/lib/factory_girl/definition_proxy.rb:167:in `trait'
/Users/username/project/hoge/huga/spec/support/factories/available_products.rb:11:in `block (2 levels) in <top (required)>'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/gems/factory_girl-4.5.0/lib/factory_girl/syntax/default.rb:18:in `instance_eval'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/gems/factory_girl-4.5.0/lib/factory_girl/syntax/default.rb:18:in `factory'
/Users/username/project/hoge/huga/spec/support/factories/available_products.rb:7:in `block in <top (required)>'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/gems/factory_girl-4.5.0/lib/factory_girl/syntax/default.rb:49:in `instance_eval'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/gems/factory_girl-4.5.0/lib/factory_girl/syntax/default.rb:49:in `run'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/gems/factory_girl-4.5.0/lib/factory_girl/syntax/default.rb:7:in `define'
/Users/username/project/hoge/huga/spec/support/factories/available_products.rb:1:in `<top (required)>'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `require'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `block in require'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `require'
/Users/username/project/hoge/huga/spec/spec_helper.rb:22:in `block in <top (required)>'
/Users/username/project/hoge/huga/spec/spec_helper.rb:22:in `each'
/Users/username/project/hoge/huga/spec/spec_helper.rb:22:in `<top (required)>'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `require'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `block in require'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `require'
/Users/username/project/hoge/huga/spec/rails_helper.rb:6:in `<top (required)>'
/Users/username/project/hoge/huga/spec/controllers/admin/article_check_words_controller_spec.rb:1:in `require'
/Users/username/project/hoge/huga/spec/controllers/admin/article_check_words_controller_spec.rb:1:in `<top (required)>'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1361:in `load'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1361:in `block in load_spec_files'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1359:in `each'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1359:in `load_spec_files'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:106:in `setup'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:92:in `run'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:78:in `run'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:45:in `invoke'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/gems/rspec-core-3.4.4/exe/rspec:4:in `<top (required)>'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/bin/rspec:23:in `load'
/Users/username/project/hoge/huga/vender/bundle/ruby/2.3.0/bin/rspec:23:in `<top (required)>'
テストファイル
require "rails_helper" #
describe ArticlesController do
context "#index" do
before do
@users = create_list(:user, 3)
end
it "検索ボックスが表示されること" do
end
it "id検索できること" do
end
it "ユーザーの情報が表示されること" do
end
end
end
お手数おかけしますが、解決方法分かる方いらっしゃいましたら教えていただけると嬉しいです。
よろしくおねがいします。
-
気になる質問をクリップする
クリップした質問は、後からいつでもマイページで確認できます。
またクリップした質問に回答があった際、通知やメールを受け取ることができます。
クリップを取り消します
-
良い質問の評価を上げる
以下のような質問は評価を上げましょう
- 質問内容が明確
- 自分も答えを知りたい
- 質問者以外のユーザにも役立つ
評価が高い質問は、TOPページの「注目」タブのフィードに表示されやすくなります。
質問の評価を上げたことを取り消します
-
評価を下げられる数の上限に達しました
評価を下げることができません
- 1日5回まで評価を下げられます
- 1日に1ユーザに対して2回まで評価を下げられます
質問の評価を下げる
teratailでは下記のような質問を「具体的に困っていることがない質問」、「サイトポリシーに違反する質問」と定義し、推奨していません。
- プログラミングに関係のない質問
- やってほしいことだけを記載した丸投げの質問
- 問題・課題が含まれていない質問
- 意図的に内容が抹消された質問
- 過去に投稿した質問と同じ内容の質問
- 広告と受け取られるような投稿
評価が下がると、TOPページの「アクティブ」「注目」タブのフィードに表示されにくくなります。
質問の評価を下げたことを取り消します
この機能は開放されていません
評価を下げる条件を満たしてません
質問の評価を下げる機能の利用条件
この機能を利用するためには、以下の事項を行う必要があります。
- 質問回答など一定の行動
-
メールアドレスの認証
メールアドレスの認証
-
質問評価に関するヘルプページの閲覧
質問評価に関するヘルプページの閲覧
check解決した方法
0
自分で解決できましたので報告させていただきます。
コメントくださった方々どうもありがとうございました。
factoryと聞いて、ピンときました。
クラスができていなかったために落ちていました。
テスト用のseedコマンドを実行したところ治りました。
おかげさまで大変勉強になりました。ありがとうございました!
投稿
-
回答の評価を上げる
以下のような回答は評価を上げましょう
- 正しい回答
- わかりやすい回答
- ためになる回答
評価が高い回答ほどページの上位に表示されます。
-
回答の評価を下げる
下記のような回答は推奨されていません。
- 間違っている回答
- 質問の回答になっていない投稿
- スパムや攻撃的な表現を用いた投稿
評価を下げる際はその理由を明確に伝え、適切な回答に修正してもらいましょう。
15分調べてもわからないことは、teratailで質問しよう!
- ただいまの回答率 88.35%
- 質問をまとめることで、思考を整理して素早く解決
- テンプレート機能で、簡単に質問をまとめられる
質問への追記・修正、ベストアンサー選択の依頼
moke
2017/05/01 13:42
この状態ではわからないのですが。 FactoryGirlで生成したlistに問題があるのではないでしょうか
sutonea
2017/05/01 13:47
モデルクラスと、spec/factoriesディレクリ内のファイルを追加してください。