ReferenceError:未定义loadFixtures

时间:2019-07-17 01:45:34

标签: ruby-on-rails ruby-on-rails-5 jasmine-jquery

我正在我的项目中设置jasmine和jasmine-jquery库来测试jquery代码。 Jasmine工作正常,但我无法加载jasmine-jquery。

我看到了this,但我不知道将茉莉花jQuery库放在哪里?

GemFile:

  gem 'jasmine', '~> 2.3'
  gem 'jasmine-jquery-rails', '~> 2.0'

错误:

ReferenceError: loadFixtures is not defined
ReferenceError: loadFixtures is not defined
    at UserContext.<anonymous> (http://localhost:8888/__spec__/toggle_reviews_spec.js:3:5)
    at attempt (http://localhost:8888/__jasmine__/jasmine.js:4478:46)
    at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4402:20)
    at QueueRunner.execute (http://localhost:8888/__jasmine__/jasmine.js:4384:10)
    at Spec.queueRunnerFactory (http://localhost:8888/__jasmine__/jasmine.js:964:35)
    at Spec.execute (http://localhost:8888/__jasmine__/jasmine.js:563:10)
    at UserContext.fn (http://localhost:8888/__jasmine__/jasmine.js:5541:37)
    at attempt (http://localhost:8888/__jasmine__/jasmine.js:4486:26)
    at QueueRunner.run (http://localhost:8888/__jasmine__/jasmine.js:4402:20)
    at QueueRunner.execute (http://localhost:8888/__jasmine__/jasmine.js:4384:10)

我要测试的文件: toggle_review_spec.js

describe("toggle review", function(){
  beforeEach(function() {
    loadFixtures('toggle_reviews.html');
  });

  it("by default it shows created", function(){
    expect("#review-text").toHaveText("Created");
  });
});

我有一个装置文件夹,在其中创建了toggle_reviews.html

我想加载jasmine-jquery,但我不知道如何加载它。 知道在哪里可以添加jasmine-jquery lib吗?

1 个答案:

答案 0 :(得分:0)

通过在yourProject / config / initializers / assets.rb文件中加载jquery.js和jasmine-jquery.js进行修复。

代码:

var result = text.Replace("f", "Kf").Replace("F", "KF");