質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
RSpec

RSpecはRuby用のBDD(behaviour-driven development)フレームワークです。

Ruby on Rails 4

Ruby on Rails4はRubyによって書かれたオープンソースのウェブフレームワークです。 Ruby on Railsは「設定より規約」の原則に従っており、効率的に作業を行うために再開発を行う必要をなくしてくれます。

Q&A

解決済

1回答

5705閲覧

rspecが実行できなくなりました。bundler: failed to load command: rspec

big2017

総合スコア39

RSpec

RSpecはRuby用のBDD(behaviour-driven development)フレームワークです。

Ruby on Rails 4

Ruby on Rails4はRubyによって書かれたオープンソースのウェブフレームワークです。 Ruby on Railsは「設定より規約」の原則に従っており、効率的に作業を行うために再開発を行う必要をなくしてくれます。

0グッド

0クリップ

投稿2017/05/01 04:29

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

お手数おかけしますが、解決方法分かる方いらっしゃいましたら教えていただけると嬉しいです。
よろしくおねがいします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

moke

2017/05/01 04:42

この状態ではわからないのですが。 FactoryGirlで生成したlistに問題があるのではないでしょうか
sutonea

2017/05/01 04:47

モデルクラスと、spec/factoriesディレクリ内のファイルを追加してください。
guest

回答1

0

自己解決

自分で解決できましたので報告させていただきます。
コメントくださった方々どうもありがとうございました。
factoryと聞いて、ピンときました。
クラスができていなかったために落ちていました。
テスト用のseedコマンドを実行したところ治りました。

おかげさまで大変勉強になりました。ありがとうございました!

投稿2017/05/01 07:27

big2017

総合スコア39

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問