首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Jasmine Headless Webkit规范文件在资产之前运行?

Jasmine Headless Webkit规范文件在资产之前运行?
EN

Stack Overflow用户
提问于 2012-06-14 09:58:13
回答 1查看 703关注 0票数 0

为了将规范文件和资源作为咖啡脚本运行,我决定使用jasmine-headless-webkit。我相信我已经正确安装了所有内容,但可能是我的jasmine.yml文件中出现了错误:

代码语言:javascript
复制
src_files:
  - spec/support/javascripts/jquery-1.7.2.js
  - app/assets/javascripts/application.js
helpers:
  - helpers/**/*
spec_files:
  - "**/*_spec.*"
src_dir: 
  - vendor/assets/javascripts
spec_dir: spec/javascripts

当我运行该命令时,我得到三个错误,而且都是相同的行:

代码语言:javascript
复制
Editor should have an array named tables. (/Users/aaronmcleod/Documents/awesome_model/spec/javascripts/editor_spec.js.coffee:20)
ReferenceError: Can't find variable: AwesomeModel

AwesomeModel变量是我用来导出到window对象的散列。然后,我将像Editor类这样的东西附加到它。你有什么想法来解释为什么没有定义它吗?下面是我的规范文件,如果它有帮助的话:

代码语言:javascript
复制
fixture_text = ->
  "Company has_many:Employee\n" +
  "  id : int\n" +
  "  name : varchar\n" +
  "Employee belongs_to:Company\n" +
  "  id : int\n" +
  "  name : varchar\n" +
  "  phone : varchar\n" +
  "ComplicatedTable-Name\n" +
  "  id : int"

class DummyPane
  constructor: ->
    @viewport = {}

  clean_up: ->

describe "Editor", ->

  it "should have an array named tables", ->
    editor = new AwesomeModel.Editor(fixture_text())
    expect(editor.tables).toBeDefined()

  describe "#parse_table_names", ->
    text = fixture_text()
    editor = new AwesomeModel.Editor(text)

    it "tables should be of three length", ->
      editor.parse_table_names()
      expect(editor.tables.length).toEqual(3)

    it "the first table name should be 'Company'", ->
      editor.parse_table_names()
      expect(editor.tables[0].name).toEqual("Company")

    it "the third table name should be 'ComplicatedTable-Name'", ->
      editor.parse_table_names()
      expect(editor.tables[2].name).toEqual("ComplicatedTable-Name")

  describe "#add_columns", ->
    text = fixture_text()
    editor = new AwesomeModel.Editor(text)
    editor.parse_table_names()

    describe "first table", ->
      it "the first table should have two columns", ->
        editor.add_columns()
        table = editor.tables[0]

        expect(table.columns.length).toEqual(2)

      it "the first column of first table should be named 'id : int'", ->
        editor.add_columns
        table = editor.tables[0]
        expect(table.columns[0].name).toEqual('id : int')
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-06-20 06:48:55

通过使用guard找到了答案。不对等级库文件进行更改,而对jasmine.yml文件进行一些次要更改。这是我的gemfile:

代码语言:javascript
复制
source 'https://rubygems.org'

gem 'rails', '3.2.0'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer'

  gem 'uglifier', '>= 1.0.3'
end

gem 'haml-rails'

gem 'jquery-rails'

platforms :ruby do
  gem 'pg'
end

platforms :jruby do
  gem 'jruby-openssl'
  gem 'activerecord-jdbcpostgresql-adapter'
end

group :test, :development do
  gem 'rspec-rails'
  gem 'capybara'
  gem 'jasmine'
  gem 'guard'
  gem 'guard-coffeescript'
end

我的防护文件:

代码语言:javascript
复制
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

guard 'coffeescript', input: 'spec/javascripts', output: 'spec/javascripts'

Jasmine.yml

代码语言:javascript
复制
src_dir: 
  - assets/javascripts
src_files:
  - assets/application.js
helpers:
  - helpers/**/*
spec_files:
  - "**/*_spec.js"

spec_dir: spec/javascripts

我更改了资源路径,不使用本地文件夹结构,而是正确使用资源路径。

要运行此命令,只需在一个选项卡中运行guard,在另一个选项卡中运行rake jasmine。保存等级库文件时,.js版本将由guard编译。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11025720

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档