working on stuff, broken
This commit is contained in:
parent
91d9773933
commit
4150dd1828
2
Gemfile
2
Gemfile
@ -15,3 +15,5 @@ gem 'mocha', '0.9.12'
|
||||
gem 'guard-jasmine-headless-webkit', :git => 'git://github.com/johnbintz/guard-jasmine-headless-webkit.git'
|
||||
gem 'facter'
|
||||
|
||||
gem 'jquery-rails'
|
||||
|
||||
|
@ -1,21 +1,23 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require 'rubygems'
|
||||
require 'rainbow'
|
||||
|
||||
def gem_dir
|
||||
File.expand_path('../..', __FILE__)
|
||||
end
|
||||
|
||||
$:.unshift(File.join(gem_dir, 'lib'))
|
||||
|
||||
require 'jasmine-headless-webkit'
|
||||
require 'coffee-script'
|
||||
require 'rainbow'
|
||||
|
||||
begin
|
||||
options = Jasmine::Headless::Options.from_command_line
|
||||
runner = Jasmine::Headless::Runner.new(options)
|
||||
|
||||
if options[:do_list]
|
||||
files_list = Jasmine::FilesList.new(:config => runner.jasmine_config)
|
||||
files_list = Jasmine::Headless::FilesList.new(:config => runner.jasmine_config)
|
||||
files_list.files.each { |file| puts file }
|
||||
else
|
||||
exit runner.run
|
||||
|
@ -24,4 +24,5 @@ Gem::Specification.new do |s|
|
||||
s.add_dependency 'coffee-script', '>= 2.2'
|
||||
s.add_dependency 'rainbow'
|
||||
s.add_dependency 'multi_json'
|
||||
s.add_dependency 'sprockets', '~> 2.0'
|
||||
end
|
||||
|
@ -1,7 +1,3 @@
|
||||
module Jasmine
|
||||
autoload :FilesList, 'jasmine/files_list'
|
||||
end
|
||||
|
||||
require 'jasmine/headless'
|
||||
require 'jasmine/headless/railtie' if defined?(Rails) && Rails::VERSION::MAJOR >= 3
|
||||
|
||||
|
@ -8,6 +8,8 @@ module Jasmine::Headless
|
||||
autoload :Runner, 'jasmine/headless/runner'
|
||||
autoload :Options, 'jasmine/headless/options'
|
||||
autoload :Task, 'jasmine/headless/task'
|
||||
autoload :FilesList, 'jasmine/headless/files_list'
|
||||
autoload :TestFile, 'jasmine/headless/test_file'
|
||||
|
||||
autoload :TemplateWriter, 'jasmine/headless/template_writer'
|
||||
|
||||
|
@ -2,7 +2,7 @@ require 'jasmine-core'
|
||||
require 'time'
|
||||
require 'multi_json'
|
||||
|
||||
module Jasmine
|
||||
module Jasmine::Headless
|
||||
class FilesList
|
||||
attr_reader :files, :spec_files, :filtered_files, :spec_outside_scope
|
||||
|
||||
@ -60,7 +60,7 @@ module Jasmine
|
||||
|
||||
def spec_file_line_numbers
|
||||
@spec_file_line_numbers ||= Hash[@spec_files.collect { |file|
|
||||
if File.exist?(file)
|
||||
if ::File.exist?(file)
|
||||
if !(lines = Jasmine::Headless::SpecFileAnalyzer.for(file)).empty?
|
||||
[ file, lines ]
|
||||
end
|
||||
@ -82,6 +82,8 @@ module Jasmine
|
||||
|
||||
source = nil
|
||||
|
||||
next file.to_html
|
||||
|
||||
result = case File.extname(file)
|
||||
when '.coffee'
|
||||
begin
|
||||
@ -162,6 +164,9 @@ module Jasmine
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@files.collect! { |file| Jasmine::Headless::TestFile.new(file) }
|
||||
@filtered_files.collect! { |file| Jasmine::Headless::TestFile.new(file) }
|
||||
end
|
||||
|
||||
def config?
|
@ -66,7 +66,7 @@ module Jasmine
|
||||
def run
|
||||
Jasmine::Headless::CacheableAction.enabled = @options[:enable_cache]
|
||||
|
||||
files_list = Jasmine::FilesList.new(
|
||||
files_list = Jasmine::Headless::FilesList.new(
|
||||
:config => jasmine_config,
|
||||
:only => @options[:files]
|
||||
)
|
||||
|
9
lib/jasmine/headless/test_file.rb
Normal file
9
lib/jasmine/headless/test_file.rb
Normal file
@ -0,0 +1,9 @@
|
||||
module Jasmine::Headless
|
||||
class TestFile
|
||||
attr_reader :path
|
||||
|
||||
def initialize(path)
|
||||
@path = path
|
||||
end
|
||||
end
|
||||
end
|
@ -138,5 +138,21 @@ describe "jasmine-headless-webkit" do
|
||||
File.size(runner_path.path).should_not == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe 'sprockets' do
|
||||
it 'should pull in the code via sprockets' do
|
||||
files = %x{bin/jasmine-headless-webkit -l -j spec/jasmine/with_sprockets_includes/with_sprockets_includes.yml}
|
||||
$?.exitstatus.should == 0
|
||||
|
||||
puts files
|
||||
|
||||
files.lines.to_a.should include('vendor/assets/javascripts/jquery.js')
|
||||
files.lines.to_a.should include('assets/code.js')
|
||||
files.lines.to_a.should include('assets/required.js')
|
||||
files.lines.to_a.should include('assets/subcode/more_code.js')
|
||||
files.lines.to_a.should include('spec/spec_helper.js')
|
||||
files.lines.to_a.should include('spec/code_spec.js')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -0,0 +1,2 @@
|
||||
//= require 'jquery'
|
||||
//= require_tree '.'
|
2
spec/jasmine/with_sprockets_includes/assets/code.js
Normal file
2
spec/jasmine/with_sprockets_includes/assets/code.js
Normal file
@ -0,0 +1,2 @@
|
||||
window.a = '1';
|
||||
|
@ -0,0 +1,2 @@
|
||||
//= require 'required'
|
||||
|
9
spec/jasmine/with_sprockets_includes/spec/code_spec.js
Normal file
9
spec/jasmine/with_sprockets_includes/spec/code_spec.js
Normal file
@ -0,0 +1,9 @@
|
||||
//= require 'code'
|
||||
|
||||
describe('code', function() {
|
||||
it('should equal 1', function() {
|
||||
expect(window.a).toEqual(1)
|
||||
expect(jQuery).not.toBeUndefined()
|
||||
});
|
||||
});
|
||||
|
2
spec/jasmine/with_sprockets_includes/spec/spec_helper.js
Normal file
2
spec/jasmine/with_sprockets_includes/spec/spec_helper.js
Normal file
@ -0,0 +1,2 @@
|
||||
//= require 'jquery'
|
||||
|
@ -0,0 +1,12 @@
|
||||
src_dir: spec/jasmine/with_sprockets_includes/assets
|
||||
spec_dir: spec/jasmine/with_sprockets_includes/spec
|
||||
|
||||
spec_files:
|
||||
- "*_spec.js"
|
||||
|
||||
src_files:
|
||||
- "*.js"
|
||||
|
||||
helpers:
|
||||
- "spec_helper.js"
|
||||
|
@ -1,11 +1,10 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
require 'spec_helper'
|
||||
require 'jasmine/files_list'
|
||||
require 'fakefs/spec_helpers'
|
||||
require 'coffee-script'
|
||||
|
||||
describe Jasmine::FilesList do
|
||||
describe Jasmine::Headless::FilesList do
|
||||
let(:files_list) { described_class.new }
|
||||
|
||||
describe '#initialize' do
|
||||
@ -47,7 +46,7 @@ describe Jasmine::FilesList do
|
||||
|
||||
shared_examples_for :reading_data do
|
||||
it 'should read the data from the jasmine.yml file and add the files' do
|
||||
files_list.files.should == Jasmine::FilesList::DEFAULT_FILES + [
|
||||
files_list.files.should == Jasmine::Headless::FilesList::DEFAULT_FILES + [
|
||||
File.expand_path(first_file),
|
||||
File.expand_path(src_file),
|
||||
File.expand_path(stylesheet_file),
|
||||
@ -114,7 +113,7 @@ describe Jasmine::FilesList do
|
||||
end
|
||||
|
||||
context 'with filtered specs' do
|
||||
let(:files_list) { Jasmine::FilesList.new(:only => filter, :config => config) }
|
||||
let(:files_list) { Jasmine::Headless::FilesList.new(:only => filter, :config => config) }
|
||||
let(:spec_dir) { 'spec' }
|
||||
|
||||
include FakeFS::SpecHelpers
|
52
spec/lib/jasmine/headless/test_file_spec.rb
Normal file
52
spec/lib/jasmine/headless/test_file_spec.rb
Normal file
@ -0,0 +1,52 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Jasmine::Headless::TestFile do
|
||||
let(:file) { described_class.new(path) }
|
||||
let(:path) { 'path' }
|
||||
|
||||
subject { file }
|
||||
|
||||
its(:path) { should == path }
|
||||
|
||||
describe '#to_html' do
|
||||
subject { file.to_html }
|
||||
|
||||
context '.js' do
|
||||
let(:path) { 'path.js' }
|
||||
|
||||
it { should == %{<script type="text/javascript" src="#{path}"></script>} }
|
||||
end
|
||||
|
||||
context '.css' do
|
||||
let(:path) { 'path.css' }
|
||||
|
||||
it { should == %{<script type="text/javascript" src="#{path}"></script>} }
|
||||
end
|
||||
|
||||
context '.coffee' do
|
||||
let(:path) { 'path.coffee' }
|
||||
|
||||
let(:handle_expectation) { Jasmine::Headless::CoffeeScriptCache.any_instance.stubs(:handle) }
|
||||
|
||||
context 'compilation error' do
|
||||
let(:error) { CoffeeScript::CompilationError.new("fail") }
|
||||
|
||||
before do
|
||||
handle_exception.raises(error)
|
||||
end
|
||||
|
||||
it 'should pass along the error' do
|
||||
expect { subject }.to raise_error(error)
|
||||
end
|
||||
end
|
||||
|
||||
context 'compiles fine' do
|
||||
let(:cached_expectation) { Jasmine::Headless::CoffeeScriptCache.any_instance.stubs(:cached?).returns(cache_return) }
|
||||
|
||||
before do
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user