包含要求'test_helper'时缺少方法

时间:2019-03-06 05:45:02

标签: ruby-on-rails ruby testing minitest

我正在尝试使用minitest进行测试,但是在运行此文件时

  

bin / rails test test / controllers / api / v1 / blogs_api_controller_test.rb

但是它给出了这个错误

  

.rvm / gems / ruby​​-2.3.1 / gems / railties-5.1.1 / lib / rails / railtie / configuration.rb:95:in   int count; float average; void main() { do while(true) { float temperature = ReadFromSensor(); //not included average = ((average*count) + temperature)/ ++count; cout << "average: " << average << endl; } } web_console'

     

(NoMethodError)您的意思是?控制台

method_missing': undefined method

发布版本require 'test_helper' class BlogsApiControllerTest < ActiveSupport::TestCase test 'Get all Blogs' do assert false end end Ruby 5.1.1

宝石文件

2.3.1

1 个答案:

答案 0 :(得分:0)

请将gem 'web-console'放入您的Gemfile的测试部分。您可以更改以下几行

group :development, :test do
  gem 'pry'

  # Use mysql as the database for Active Record
  gem 'mysql2', '~> 0.4.6'
end

跟随

group :development, :test do
  gem 'pry'
  gem 'web-console'
  # Use mysql as the database for Active Record
  gem 'mysql2', '~> 0.4.6'
end

然后从以下几行中删除web-console

group :development do
  gem 'wdm', '>= 0.1.0' if Gem.win_platform?
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console' # remove this

现在运行以下命令来更新捆绑包

bundle install