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

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

新規登録して質問してみよう
ただいま回答率
85.49%
Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

RSpec

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

Q&A

1回答

1074閲覧

herokuでrspecが実行できず、bundler: command not found: rspecとエラーが出てしまう

you88

総合スコア147

Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

RSpec

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

0グッド

0クリップ

投稿2022/12/26 10:51

前提

herokuでrspecが実行できず、bundler: command not found: rspec Install missing gem executables with bundle installとエラーが出てしまいます。構成は下記になります。

  • heroku
  • rails
  • rspec
  • RAILS_ENVはdevelopment

実現したいこと

herokuでheroku run bundle exec rspec spec/requests/application_spec.rbを打ってテスト実行をしたい

発生している問題・エラーメッセージ

bundler: command not found: rspec Install missing gem executables with `bundle install`

該当のソースコード

gemfile

1group :test do 2 # Adds support for Capybara system testing and selenium driver 3 gem 'capybara', '>= 2.15' 4 gem 'selenium-webdriver' 5 # Easy installation and use of web drivers to run system tests with browsers 6 gem 'webdrivers' 7 gem 'rspec-rails' 8 gem "factory_bot_rails" 9end

testでのみ入れています

試したこと

localだとdevelopment環境でテストできます

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

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

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

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

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

guest

回答1

0

Gemfile で developmentにもrspec-rails を追加してはいかがでしょう
もしくは heroku で test 環境でテストが実行されるようにできませんか

投稿2022/12/26 11:13

yuma.inaura

総合スコア1451

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

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

you88

2022/12/26 11:57

ありがとうがとうございます! herokuのRAILS_ENVとRACK_ENVをdevelopmentにしてdeployしましたが、下記のエラーが出てデプロイできませんでした。productionに変更するとdeploy成功しました ``` -----> Building on the Heroku-20 stack -----> Using buildpack: heroku/ruby -----> Ruby app detected -----> Installing bundler 2.3.25 -----> Removing BUNDLED WITH version in the Gemfile.lock -----> Compiling Ruby/Rails -----> Using Ruby version: ruby-2.7.7 -----> Installing dependencies using bundler 2.3.25 Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4 Using rake 13.0.6 Using concurrent-ruby 1.1.10 Using i18n 1.12.0 Using minitest 5.16.3 Using thread_safe 0.3.6 Using tzinfo 1.2.10 Using zeitwerk 2.6.6 Using activesupport 6.0.6 Using builder 3.2.4 Using erubi 1.11.0 Using racc 1.6.1 Using nokogiri 1.13.10 (x86_64-linux) Using rails-dom-testing 2.0.3 Using crass 1.0.6 Using loofah 2.19.1 Using rails-html-sanitizer 1.4.4 Using actionview 6.0.6 Using rack 2.2.4 Using rack-test 2.0.2 Using actionpack 6.0.6 Using nio4r 2.5.8 Using websocket-extensions 0.1.5 Using websocket-driver 0.7.5 Using actioncable 6.0.6 Using globalid 1.0.0 Using activejob 6.0.6 Using activemodel 6.0.6 Using activerecord 6.0.6 Using marcel 1.0.2 Using activestorage 6.0.6 Using mini_mime 1.1.2 Using date 3.3.3 Using timeout 0.3.1 Using net-protocol 0.2.1 Using net-imap 0.3.2 Using net-pop 0.1.2 Using net-smtp 0.3.3 Using mail 2.8.0 Using actionmailbox 6.0.6 Using actionmailer 6.0.6 Using actiontext 6.0.6 Using public_suffix 5.0.1 Using addressable 2.8.1 Using aws_cf_signer 0.1.3 Using bcrypt 3.1.18 Using msgpack 1.6.0 Using bootsnap 1.15.0 Using bundler 2.3.25 Using mini_magick 4.12.0 Using ffi 1.15.5 Using ruby-vips 2.1.4 Using image_processing 1.12.2 Using ssrf_filter 1.1.1 Using carrierwave 2.2.3 Using http-accept 1.7.0 Using unf_ext 0.0.8.2 Using unf 0.1.4 Using domain_name 0.5.20190701 Using http-cookie 1.0.5 Using mime-types-data 3.2022.0105 Using mime-types 3.4.1 Using netrc 0.11.0 Using rest-client 2.1.0 Using cloudinary 1.24.0 Using orm_adapter 0.5.0 Using method_source 1.0.0 Using thor 1.2.1 Using railties 6.0.6 Using responders 3.0.1 Using warden 1.2.9 Using devise 4.8.1 Using devise-i18n 1.10.2 Using dotenv 2.8.1 Using dotenv-rails 2.8.1 Using excon 0.95.0 Using formatador 1.1.0 Using fog-core 2.3.0 Using multi_json 1.15.0 Using fog-json 1.2.0 Using fog-xml 0.1.4 Using fog-aws 3.15.0 Using jbuilder 2.11.5 Using kaminari-core 1.2.2 Using kaminari-actionview 1.2.2 Using kaminari-activerecord 1.2.2 Using kaminari 1.2.2 Using meta-tags 2.18.0 Using pg 1.4.5 Using puma 4.3.12 Using rack-proxy 0.7.4 Using sprockets 4.1.1 Using sprockets-rails 3.4.2 Using rails 6.0.6 Using rails-i18n 7.0.6 Using rinku 2.0.6 Using sassc 2.4.0 Using tilt 2.0.11 Using sassc-rails 2.1.2 Using sass-rails 6.0.0 Using semantic_range 3.0.0 Using sentry-ruby 5.7.0 Using sentry-rails 5.7.0 Using stripe 8.0.0 Using turbolinks-source 5.2.0 Using turbolinks 5.2.1 Using webpacker 5.4.3 Bundle complete! 35 Gemfile dependencies, 106 gems now installed. Gems in the groups 'development' and 'test' were not installed. Bundled gems are installed into `./vendor/bundle` Bundle completed (0.38s) Cleaning up the bundler cache. -----> Installing node-v16.18.1-linux-x64 -----> Installing yarn-v1.22.19 -----> Detecting rake tasks -----> Preparing app for Rails asset pipeline Running: rake assets:precompile /tmp/build_d5b985be/vendor/ruby-2.7.7/lib/ruby/2.7.0/net/protocol.rb:66: warning: already initialized constant Net::ProtocRetryError /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/net-protocol-0.2.1/lib/net/protocol.rb:68: warning: previous definition of ProtocRetryError was here /tmp/build_d5b985be/vendor/ruby-2.7.7/lib/ruby/2.7.0/net/protocol.rb:206: warning: already initialized constant Net::BufferedIO::BUFSIZE /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/net-protocol-0.2.1/lib/net/protocol.rb:214: warning: previous definition of BUFSIZE was here /tmp/build_d5b985be/vendor/ruby-2.7.7/lib/ruby/2.7.0/net/protocol.rb:503: warning: already initialized constant Net::NetPrivate::Socket /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/net-protocol-0.2.1/lib/net/protocol.rb:541: warning: previous definition of Socket was here rake aborted! NoMethodError: undefined method `web_console' for #<Rails::Application::Configuration:0x00005571b92e86e8> Did you mean? console /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/railties-6.0.6/lib/rails/railtie/configuration.rb:96:in `method_missing' /tmp/build_d5b985be/config/environments/development.rb:62:in `block in <main>' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/railties-6.0.6/lib/rails/railtie.rb:217:in `instance_eval' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/railties-6.0.6/lib/rails/railtie.rb:217:in `configure' /tmp/build_d5b985be/config/environments/development.rb:1:in `<main>' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.6/lib/active_support/dependencies.rb:324:in `block in require' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.6/lib/active_support/dependencies.rb:291:in `load_dependency' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.6/lib/active_support/dependencies.rb:324:in `require' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/railties-6.0.6/lib/rails/engine.rb:613:in `block (2 levels) in <class:Engine>' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/railties-6.0.6/lib/rails/engine.rb:612:in `each' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/railties-6.0.6/lib/rails/engine.rb:612:in `block in <class:Engine>' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/railties-6.0.6/lib/rails/initializable.rb:32:in `instance_exec' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/railties-6.0.6/lib/rails/initializable.rb:32:in `run' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/railties-6.0.6/lib/rails/initializable.rb:61:in `block in run_initializers' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/railties-6.0.6/lib/rails/initializable.rb:50:in `each' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/railties-6.0.6/lib/rails/initializable.rb:50:in `tsort_each_child' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/railties-6.0.6/lib/rails/initializable.rb:60:in `run_initializers' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/railties-6.0.6/lib/rails/application.rb:363:in `initialize!' /tmp/build_d5b985be/config/environment.rb:5:in `<main>' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.6/lib/active_support/dependencies.rb:324:in `block in require' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.6/lib/active_support/dependencies.rb:291:in `load_dependency' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.6/lib/active_support/dependencies.rb:324:in `require' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/railties-6.0.6/lib/rails/application.rb:339:in `require_environment!' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/railties-6.0.6/lib/rails/application.rb:523:in `block in run_tasks_blocks' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/sentry-ruby-5.7.0/lib/sentry/rake.rb:24:in `execute' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/sprockets-rails-3.4.2/lib/sprockets/rails/task.rb:61:in `block (2 levels) in define' /tmp/build_d5b985be/vendor/bundle/ruby/2.7.0/gems/sentry-ruby-5.7.0/lib/sentry/rake.rb:24:in `execute' Tasks: TOP => environment (See full trace by running task with --trace) ! ! Precompiling assets failed. ! ! Push rejected, failed to compile Ruby app. ! Push failed ```
yuma.inaura

2022/12/26 13:08

回答に書いたのは Gemfile の development グループに rails-spec を入れてみては?という意味でした こんな記述もありますがいかがでしょう https://devcenter.heroku.com/ja/articles/getting-started-with-rails6 >Heroku では、アプリは development​ や test​ グループなしで構築されます。アプリの実行がこれらのグループのいずれかからの gem に依存している場合、これをグループから除外します。 全環境向けに rails-spec を入れておいてはいかがですか?
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.49%

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

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

質問する

関連した質問