小编Tet*_*yna的帖子

Karma错误参数'Controller'不是函数,未定义

我试图测试我的控制器时遇到了问题.当我运行测试时出现错误

Error: [ng:areq] Argument 'MainCtrl' is not a function, got undefined   http://errors.angularjs.org/1.3.8/ng/areq?p0=MainCtrl&p1=not%20a%20function%2C%20got%20undefined
        at assertArg (/Users/tetianachupryna/project/bower_components/angular/angular.js:1577)
        at assertArgFn (/Users/tetianachupryna/project/bower_components/angular/angular.js:1588)
        at /Users/tetianachupryna/project/bower_components/angular/angular.js:8418
        at /Users/tetianachupryna/project/src/spec/controllers/main-controller.spec.js:11
        at /Users/tetianachupryna/project/src/spec/controllers/main-controller.spec.js:17
        at /Users/tetianachupryna/project/node_modules/karma-jasmine/lib/adapter.js:184
        at http://localhost:9877/karma.js:185
        at http://localhost:9877/context.html:51
Run Code Online (Sandbox Code Playgroud)

我知道SO充满了类似的问题.但是我在Angular和JS中总体上是空的,所以这些答案对我没有帮助.从SO上的类似问题我发现我的问题是控制器的错误定义,但我仍然无法弄清楚我做错了什么.我已经堆叠了,我求你帮忙.

首先,这是我的src/app/index.js文件,其中定义了我的模块

var app = angular.module('myModule', [
  'ngAnimate',
  'ngSanitize',
  'ngResource',
  'ui.router',
  'pascalprecht.translate',
  'thing1',
  'thing2']);
Run Code Online (Sandbox Code Playgroud)

这是src/app/controllers/main-controller.js

angular.module('myModule').controller('MainCtrl', [
    '$scope',
    '$state',
    function ($scope, $state) {
      $scope.state = $state;
      //***
      $scope.isBigStep = function isBigStep() {
        return $state.$current.step == 3;
      };    
  }]);
Run Code Online (Sandbox Code Playgroud)

最后这个文件带有测试src/spec/controllers/main-controller.spec.js

describe('MainCtrl', function() {
  var scope, $state, createController; …
Run Code Online (Sandbox Code Playgroud)

javascript jasmine angularjs karma-runner karma-jasmine

10
推荐指数
1
解决办法
1万
查看次数

RSpec 3错误未定义的方法`get'在请求测试中

在RSpec 3上迁移后,请求测试失败.这是我的测试

describe 'GET /api/v1/activities' do
    let!(:user) { create(:user) }

    subject { json['activities'] }

   context 'when not authenticated' do
      let(:token) { user.authentication_token }
      let(:email) { 'unregistered.user@mail.com' }
      before :each do
        get '/api/v1/activities', {}, {token: token, email: email}
      end
      it { expect(response).to_not be_success }
    end
end
Run Code Online (Sandbox Code Playgroud)

这是rspec日志

Activities GET /api/v1/activities when not authenticated 
     Failure/Error: get '/api/v1/activities', {}, {token: token, email: email}
     NoMethodError:
       undefined method `get' for #<RSpec::ExampleGroups::Activities::GETApiV1Activities::WhenNotAuthenticated:0x0000000becfaf8>
Run Code Online (Sandbox Code Playgroud)

它能是什么?

testing rspec ruby-on-rails request rspec3

2
推荐指数
1
解决办法
1320
查看次数

在RubyMine调试器中更改评估超时

我使用RubyMine及其远程调试器.在断点处,我想提出IMAP请求,因此需要很长时间.但我得到一个例外,"Timeout: evaluation took longer than 10 seconds." 我试图在Settings-> Debugger中增加调试连接超时.但显然这个技巧不起作用.

那么可以在RubyMine调试器中增加评估表达式超时吗?

remote-debugging rubymine

2
推荐指数
1
解决办法
3179
查看次数

在GMail线程中计算电子邮件的简单方法

有没有简单的方法可以知道GMail邮箱中的线程中有多少封电子邮件?我获取了有关消息的信息(message_id,X-GM-THRID,引用,in_reply_to等),我想知道在邮箱中有多少其他具有相同X-GM-THRID的消息.是否可以在不获取有关其他消息的信息的情况下?

email gmail imap

1
推荐指数
1
解决办法
369
查看次数

将已删除列中的数据移动到Rails迁移中刚刚创建的数据

我有一个表'Invoices',其中包含两个布尔列:

Table name: invoices

id               :integer          not null, primary key
...
sent             :boolean          default(FALSE)
payment_received :boolean          default(FALSE)
Run Code Online (Sandbox Code Playgroud)

这两列定义了发票的状态:

def status
  if sent & payment_received
    :paid
  elsif sent | payment_received
    :sent
  else
    :created
  end
end
Run Code Online (Sandbox Code Playgroud)

有一天,我们决定删除这些布尔列,并在Rails枚举的帮助下创建包含发票状态的新列

status :integer

enum status: [ :created, :sent, :paid ]
Run Code Online (Sandbox Code Playgroud)

所以现在我需要做三件事:

  1. 添加新列"状态"
  2. 计算现有发票的状态,更新状态列
  3. 删除列'sent'和'payment_received'.

我怎样才能做到这一点?我可以在我的本地环境中轻松完成此任务,但我无法理解如何在生产服务器上执行此操作.例如,如果我将创建一个更新我的表的迁移和一个计算状态的rake任务,则迁移首先传递,我的数据将从布尔列中移除,然后才能使用它们.

注意:如果它以某种方式重要:我使用Postgres.

任何帮助表示赞赏!

postgresql activerecord ruby-on-rails rails-migrations

0
推荐指数
1
解决办法
89
查看次数