错误“不知道如何构建任务” konacha:serve”

时间:2019-04-30 06:37:23

标签: javascript ruby-on-rails rspec konacha

我已按照https://www.botreetechnologies.com/blog/test-rails-app-using-mocha-js-chai-js中的步骤设置了konacha。

我在spec / javascripts文件夹中编写了一个简单的hello world测试,如下所示:

var assert = require('assert');
describe('HelloWorld Module', function() {
  it('should return -1 when "Hello" is missing', function() {
    assert.equal(-1, "Hallo World".indexOf("Hello"));
  });
  it('should return 0 when sentence starts with Hello', function() {
    assert.equal(0, "Hello World, how are you?".indexOf("Hello"));
  });
});

当我运行$ bundle exec rake konacha:run --trace时,出现以下错误:

rake aborted!
Don't know how to build task 'konacha:run' (see --tasks)
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/task_manager.rb:71:in `[]'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:151:in `invoke_task'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:108:in `each'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:108:in `block in top_level'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:117:in `run_with_threads'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:102:in `top_level'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:80:in `block in run'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:178:in `standard_exception_handling'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/rake-11.3.0/lib/rake/application.rb:77:in `run'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/rake-11.3.0/exe/rake:27:in `<top (required)>'
/home/vagrant/.rbenv/versions/2.2.10/bin/rake:23:in `load'
/home/vagrant/.rbenv/versions/2.2.10/bin/rake:23:in `<top (required)>'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.1/lib/bundler/cli/exec.rb:74:in `load'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.1/lib/bundler/cli/exec.rb:74:in `kernel_load'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.1/lib/bundler/cli/exec.rb:28:in `run'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.1/lib/bundler/cli.rb:463:in `exec'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.1/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.1/lib/bundler/cli.rb:27:in `dispatch'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.1/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.1/lib/bundler/cli.rb:18:in `start'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.1/exe/bundle:30:in `block in <top (required)>'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.1/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
/home/vagrant/.rbenv/versions/2.2.10/lib/ruby/gems/2.2.0/gems/bundler-1.17.1/exe/bundle:22:in `<top (required)>'
/home/vagrant/.rbenv/versions/2.2.10/bin/bundle:23:in `load'
/home/vagrant/.rbenv/versions/2.2.10/bin/bundle:23:in `<main>'

有人可以帮我吗?

1 个答案:

答案 0 :(得分:0)

我不仅要将gem包含在gemfile的:test组中,而且还包括在:development组中。在那之后似乎起作用了。