Sha256: b1c4ea1e2eefff70c481e1943c7fe63dfb0d6341c914ff32eef4dac31d675dc8

Contents?: true

Size: 1.64 KB

Versions: 1

Compression:

Stored size: 1.64 KB

Contents

require 'spec_helper'

feature "user generates rails app with karma/jasmine" do
  def app_name
    'dummy_rails'
  end

  def app_path
    join_paths(tmp_path, app_name)
  end

  before(:all) do
    make_it_so!("rails #{app_name} --js-test-lib karma")
  end

  let(:package_json_path) { File.join(app_path, 'package.json') }

  it 'creates a karma.config' do
    karma_config = File.join(app_path, 'karma.conf.js')
    expect(FileTest.exists?(karma_config)).to eq(true)
  end

  it 'creates a testHelper.js' do
    test_helper = File.join(app_path, 'spec/javascript/testHelper.js')
    expect(FileTest.exists?(test_helper)).to eq(true)
  end

  it 'includes karma in package.json' do
    in_package_json?(File.join(app_path, 'package.json')) do |json|
      expect(json["devDependencies"]["karma"]).to_not be_nil
    end
  end

  it 'includes jasmine in package.json' do
    in_package_json?(File.join(app_path, 'package.json')) do |json|
      expect(json["devDependencies"]["jasmine-core"]).to_not be_nil
    end
  end

  it 'adds coverage/* to gitignore' do
    expect(read_file('.gitignore')).to include("coverage/*\n")
  end

  it 'configures enzyme with adapter in testHelper' do
    testHelper = read_file('spec/javascript/testHelper.js')
    expect(testHelper).to include("Enzyme.configure({ adapter: new EnzymeAdapter() })")
  end

  it 'karma.conf.js uses @babel/polyfill' do
    expect(read_file('karma.conf.js')).to include("node_modules/@babel/polyfill/dist/polyfill.js")
  end

  it 'does not add jest as the test script in package.json' do
    in_package_json?(package_json_path) do |json|
      expect(json["scripts"]["test"]).to_not include("jest")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
make_it_so-0.5.0 spec/features/rails/user_generates_rails_with_karma_spec.rb