clean some things up
This commit is contained in:
parent
c9e7bb60cb
commit
7040e0e949
6
Gemfile
6
Gemfile
|
@ -2,10 +2,12 @@ source "http://rubygems.org"
|
||||||
|
|
||||||
# Specify your gem's dependencies in guard-jasmine-headless-webkit.gemspec
|
# Specify your gem's dependencies in guard-jasmine-headless-webkit.gemspec
|
||||||
gemspec
|
gemspec
|
||||||
gem 'guard', :git => 'https://github.com/guard/guard.git'
|
gem 'guard', :git => 'git://github.com/guard/guard.git'
|
||||||
gem 'rspec'
|
gem 'rspec'
|
||||||
gem 'mocha'
|
gem 'mocha'
|
||||||
gem 'rake', '0.8.7'
|
gem 'rake', '0.9.2'
|
||||||
gem 'growl'
|
gem 'growl'
|
||||||
gem 'fakefs', :require => nil
|
gem 'fakefs', :require => nil
|
||||||
gem 'jasmine-headless-webkit', :path => '../jasmine-headless-webkit'
|
gem 'jasmine-headless-webkit', :path => '../jasmine-headless-webkit'
|
||||||
|
gem 'coffee-script'
|
||||||
|
gem 'guard-rspec'
|
||||||
|
|
32
Rakefile
32
Rakefile
|
@ -13,27 +13,25 @@ require 'rspec/core/rake_task'
|
||||||
|
|
||||||
RSpec::Core::RakeTask.new(:spec)
|
RSpec::Core::RakeTask.new(:spec)
|
||||||
|
|
||||||
|
PLATFORMS = %w{1.8.7 1.9.2 ree 1.9.3-rc1}
|
||||||
|
|
||||||
|
def rvm_bundle(command = '')
|
||||||
|
Bundler.with_clean_env do
|
||||||
|
system %{bash -c 'unset BUNDLE_BIN_PATH && unset BUNDLE_GEMFILE && rvm #{PLATFORMS.join(',')} do bundle #{command}'}.tap { |o| p o }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class SpecFailure < StandardError; end
|
||||||
|
class BundleFailure < StandardError; end
|
||||||
|
|
||||||
namespace :spec do
|
namespace :spec do
|
||||||
desc "Run on three Rubies"
|
desc "Run on three Rubies"
|
||||||
task :platforms do
|
task :platforms do
|
||||||
current = %x{rvm-prompt v}
|
rvm_bundle "update"
|
||||||
|
rvm_bundle "exec rspec spec"
|
||||||
fail = false
|
raise SpecError.new if $?.exitstatus != 0
|
||||||
%w{1.8.7 1.9.2 ree}.each do |version|
|
|
||||||
puts "Switching to #{version}"
|
|
||||||
Bundler.with_clean_env do
|
|
||||||
system %{bash -c 'source ~/.rvm/scripts/rvm && rvm #{version} && bundle exec rake spec'}
|
|
||||||
end
|
|
||||||
if $?.exitstatus != 0
|
|
||||||
fail = true
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
system %{rvm #{current}}
|
|
||||||
|
|
||||||
exit (fail ? 1 : 0)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
task :default => 'spec:platforms'
|
task :default => 'spec:platforms'
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
# -*- encoding: utf-8 -*-
|
# -*- encoding: utf-8 -*-
|
||||||
$:.push File.expand_path("../lib", __FILE__)
|
|
||||||
require "guard/jasmine-headless-webkit/version"
|
|
||||||
|
|
||||||
Gem::Specification.new do |s|
|
Gem::Specification.new do |s|
|
||||||
s.name = "guard-jasmine-headless-webkit"
|
s.name = "guard-jasmine-headless-webkit"
|
||||||
s.version = Guard::JasmineHeadlessWebkitVersion::VERSION
|
s.version = '0.3.2'
|
||||||
s.platform = Gem::Platform::RUBY
|
s.platform = Gem::Platform::RUBY
|
||||||
s.authors = ["John Bintz"]
|
s.authors = ["John Bintz"]
|
||||||
s.email = ["john@coswellproductions.com"]
|
s.email = ["john@coswellproductions.com"]
|
||||||
|
@ -19,7 +17,7 @@ Gem::Specification.new do |s|
|
||||||
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
||||||
s.require_paths = ["lib"]
|
s.require_paths = ["lib"]
|
||||||
|
|
||||||
s.add_dependency 'guard', '>= 0.4.0'
|
s.add_runtime_dependency 'guard', '>= 0.4.0'
|
||||||
s.add_dependency 'jasmine-headless-webkit', '>= 0.7.0'
|
s.add_runtime_dependency 'jasmine-headless-webkit', '>= 0.7.0'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
require 'guard'
|
require 'guard'
|
||||||
require 'guard/guard'
|
require 'guard/guard'
|
||||||
require 'guard/jasmine-headless-webkit/runner'
|
|
||||||
require 'coffee-script'
|
require 'coffee-script'
|
||||||
|
|
||||||
module Guard
|
module Guard
|
||||||
class JasmineHeadlessWebkit < Guard
|
class JasmineHeadlessWebkit < Guard
|
||||||
|
autoload :Runner, 'guard/jasmine-headless-webkit/runner'
|
||||||
|
|
||||||
DEFAULT_EXTENSIONS = %w{js coffee}
|
DEFAULT_EXTENSIONS = %w{js coffee}
|
||||||
|
|
||||||
ALL_SPECS_MESSAGE = "Guard::JasmineHeadlessWebkit running all specs..."
|
ALL_SPECS_MESSAGE = "Guard::JasmineHeadlessWebkit running all specs..."
|
||||||
|
@ -72,7 +73,7 @@ module Guard
|
||||||
else
|
else
|
||||||
UI.info(SOME_SPECS_MESSAGE % paths.join(' '))
|
UI.info(SOME_SPECS_MESSAGE % paths.join(' '))
|
||||||
end
|
end
|
||||||
failed_files = JasmineHeadlessWebkitRunner.run(paths, @filtered_options)
|
failed_files = Runner.run(paths, @filtered_options)
|
||||||
@files_to_rerun = failed_files || paths
|
@files_to_rerun = failed_files || paths
|
||||||
|
|
||||||
failed_files && @files_to_rerun.empty?
|
failed_files && @files_to_rerun.empty?
|
||||||
|
|
|
@ -2,7 +2,8 @@ require 'guard/notifier'
|
||||||
require 'jasmine-headless-webkit'
|
require 'jasmine-headless-webkit'
|
||||||
|
|
||||||
module Guard
|
module Guard
|
||||||
class JasmineHeadlessWebkitRunner
|
class JasmineHeadlessWebkit
|
||||||
|
class Runner
|
||||||
class << self
|
class << self
|
||||||
def run(paths = [], options = {})
|
def run(paths = [], options = {})
|
||||||
file = Tempfile.new('guard-jasmine-headless-webkit')
|
file = Tempfile.new('guard-jasmine-headless-webkit')
|
||||||
|
@ -47,5 +48,5 @@ module Guard
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
module Guard
|
|
||||||
module JasmineHeadlessWebkitVersion
|
|
||||||
VERSION = "0.3.1"
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,13 +1,11 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
require 'guard/jasmine-headless-webkit/runner'
|
|
||||||
require 'fakefs/spec_helpers'
|
|
||||||
|
|
||||||
describe Guard::JasmineHeadlessWebkitRunner do
|
describe Guard::JasmineHeadlessWebkit::Runner do
|
||||||
describe '.run' do
|
describe '.run' do
|
||||||
it 'should pass along options' do
|
it 'should pass along options' do
|
||||||
Jasmine::Headless::Runner.expects(:run).with(has_key(:full_run))
|
Jasmine::Headless::Runner.expects(:run).with(has_key(:full_run))
|
||||||
|
|
||||||
Guard::JasmineHeadlessWebkitRunner.run([], :full_run => false)
|
Guard::JasmineHeadlessWebkit::Runner.run([], :full_run => false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -26,7 +24,7 @@ describe Guard::JasmineHeadlessWebkitRunner do
|
||||||
it 'should notify with the right information' do
|
it 'should notify with the right information' do
|
||||||
Guard::Notifier.expects(:notify).with("1 test, 0 failures, 5.0 secs.", { :title => 'Jasmine results', :image => :success })
|
Guard::Notifier.expects(:notify).with("1 test, 0 failures, 5.0 secs.", { :title => 'Jasmine results', :image => :success })
|
||||||
|
|
||||||
Guard::JasmineHeadlessWebkitRunner.notify(file).should == []
|
Guard::JasmineHeadlessWebkit::Runner.notify(file).should == []
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -39,7 +37,7 @@ REPORT
|
||||||
it 'should notify with the right information' do
|
it 'should notify with the right information' do
|
||||||
Guard::Notifier.expects(:notify).with("1 test, 1 failures, 5.0 secs.", { :title => 'Jasmine results', :image => :failed })
|
Guard::Notifier.expects(:notify).with("1 test, 1 failures, 5.0 secs.", { :title => 'Jasmine results', :image => :failed })
|
||||||
|
|
||||||
Guard::JasmineHeadlessWebkitRunner.notify(file).should == [ 'file.js' ]
|
Guard::JasmineHeadlessWebkit::Runner.notify(file).should == [ 'file.js' ]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -49,7 +47,7 @@ REPORT
|
||||||
it 'should notify failure' do
|
it 'should notify failure' do
|
||||||
Guard::Notifier.expects(:notify).with("Spec runner interrupted!", { :title => 'Jasmine results', :image => :failed })
|
Guard::Notifier.expects(:notify).with("Spec runner interrupted!", { :title => 'Jasmine results', :image => :failed })
|
||||||
|
|
||||||
Guard::JasmineHeadlessWebkitRunner.notify(file).should be_false
|
Guard::JasmineHeadlessWebkit::Runner.notify(file).should be_false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
require 'guard/jasmine-headless-webkit'
|
|
||||||
require 'fakefs/spec_helpers'
|
|
||||||
|
|
||||||
describe Guard::JasmineHeadlessWebkit do
|
describe Guard::JasmineHeadlessWebkit do
|
||||||
let(:guard) { Guard::JasmineHeadlessWebkit.new([], options) }
|
let(:guard) { Guard::JasmineHeadlessWebkit.new([], options) }
|
||||||
|
@ -43,7 +41,7 @@ describe Guard::JasmineHeadlessWebkit do
|
||||||
|
|
||||||
context 'fails' do
|
context 'fails' do
|
||||||
it 'should return false' do
|
it 'should return false' do
|
||||||
Guard::JasmineHeadlessWebkitRunner.stubs(:run).returns(['file.js'])
|
Guard::JasmineHeadlessWebkit::Runner.stubs(:run).returns(['file.js'])
|
||||||
|
|
||||||
guard.run_all.should be_false
|
guard.run_all.should be_false
|
||||||
guard.files_to_rerun.should == ['file.js']
|
guard.files_to_rerun.should == ['file.js']
|
||||||
|
@ -52,7 +50,7 @@ describe Guard::JasmineHeadlessWebkit do
|
||||||
|
|
||||||
context 'succeeds' do
|
context 'succeeds' do
|
||||||
it 'should return true' do
|
it 'should return true' do
|
||||||
Guard::JasmineHeadlessWebkitRunner.stubs(:run).returns([])
|
Guard::JasmineHeadlessWebkit::Runner.stubs(:run).returns([])
|
||||||
|
|
||||||
guard.run_all.should be_true
|
guard.run_all.should be_true
|
||||||
guard.files_to_rerun.should == []
|
guard.files_to_rerun.should == []
|
||||||
|
@ -63,7 +61,7 @@ describe Guard::JasmineHeadlessWebkit do
|
||||||
let(:options) { { :all_on_start => false, :full_run => false } }
|
let(:options) { { :all_on_start => false, :full_run => false } }
|
||||||
|
|
||||||
it 'should only pass along jhw options' do
|
it 'should only pass along jhw options' do
|
||||||
Guard::JasmineHeadlessWebkitRunner.expects(:run).with([], :full_run => false)
|
Guard::JasmineHeadlessWebkit::Runner.expects(:run).with([], :full_run => false)
|
||||||
|
|
||||||
guard.run_all
|
guard.run_all
|
||||||
end
|
end
|
||||||
|
@ -90,7 +88,7 @@ describe Guard::JasmineHeadlessWebkit do
|
||||||
|
|
||||||
context 'two files' do
|
context 'two files' do
|
||||||
it "should only run one" do
|
it "should only run one" do
|
||||||
Guard::JasmineHeadlessWebkitRunner.expects(:run).with(absolute(one_file), {}).returns(one_file)
|
Guard::JasmineHeadlessWebkit::Runner.expects(:run).with(absolute(one_file), {}).returns(one_file)
|
||||||
|
|
||||||
guard.run_on_change(%w{test.js test.js}).should be_false
|
guard.run_on_change(%w{test.js test.js}).should be_false
|
||||||
guard.files_to_rerun.should == one_file
|
guard.files_to_rerun.should == one_file
|
||||||
|
@ -99,7 +97,7 @@ describe Guard::JasmineHeadlessWebkit do
|
||||||
|
|
||||||
context 'one file no priors' do
|
context 'one file no priors' do
|
||||||
it "should not run all" do
|
it "should not run all" do
|
||||||
Guard::JasmineHeadlessWebkitRunner.expects(:run).returns(one_file)
|
Guard::JasmineHeadlessWebkit::Runner.expects(:run).returns(one_file)
|
||||||
|
|
||||||
guard.run_on_change(one_file).should be_false
|
guard.run_on_change(one_file).should be_false
|
||||||
guard.files_to_rerun.should == one_file
|
guard.files_to_rerun.should == one_file
|
||||||
|
@ -109,7 +107,7 @@ describe Guard::JasmineHeadlessWebkit do
|
||||||
context 'one file one prior' do
|
context 'one file one prior' do
|
||||||
it "should not run all" do
|
it "should not run all" do
|
||||||
guard.instance_variable_set(:@files_to_rerun, [ "two.js" ])
|
guard.instance_variable_set(:@files_to_rerun, [ "two.js" ])
|
||||||
Guard::JasmineHeadlessWebkitRunner.expects(:run).with(absolute(one_file) + [ "two.js" ], {}).returns(one_file)
|
Guard::JasmineHeadlessWebkit::Runner.expects(:run).with(absolute(one_file) + [ "two.js" ], {}).returns(one_file)
|
||||||
|
|
||||||
guard.run_on_change(one_file).should be_false
|
guard.run_on_change(one_file).should be_false
|
||||||
guard.files_to_rerun.should == one_file
|
guard.files_to_rerun.should == one_file
|
||||||
|
@ -119,7 +117,7 @@ describe Guard::JasmineHeadlessWebkit do
|
||||||
context 'failed hard' do
|
context 'failed hard' do
|
||||||
it "should not run all" do
|
it "should not run all" do
|
||||||
guard.instance_variable_set(:@files_to_rerun, absolute(one_file))
|
guard.instance_variable_set(:@files_to_rerun, absolute(one_file))
|
||||||
Guard::JasmineHeadlessWebkitRunner.expects(:run).with(absolute(one_file), {}).returns(false)
|
Guard::JasmineHeadlessWebkit::Runner.expects(:run).with(absolute(one_file), {}).returns(false)
|
||||||
|
|
||||||
guard.run_on_change(one_file).should be_false
|
guard.run_on_change(one_file).should be_false
|
||||||
guard.files_to_rerun.should == absolute(one_file)
|
guard.files_to_rerun.should == absolute(one_file)
|
||||||
|
@ -128,7 +126,7 @@ describe Guard::JasmineHeadlessWebkit do
|
||||||
|
|
||||||
context 'succeed, but still do not run all' do
|
context 'succeed, but still do not run all' do
|
||||||
it "should run all" do
|
it "should run all" do
|
||||||
Guard::JasmineHeadlessWebkitRunner.expects(:run).returns([])
|
Guard::JasmineHeadlessWebkit::Runner.expects(:run).returns([])
|
||||||
|
|
||||||
guard.run_on_change(one_file).should be_true
|
guard.run_on_change(one_file).should be_true
|
||||||
guard.files_to_rerun.should == []
|
guard.files_to_rerun.should == []
|
||||||
|
@ -137,7 +135,7 @@ describe Guard::JasmineHeadlessWebkit do
|
||||||
|
|
||||||
context 'no files given, just run all' do
|
context 'no files given, just run all' do
|
||||||
it 'should run all but not run once' do
|
it 'should run all but not run once' do
|
||||||
Guard::JasmineHeadlessWebkitRunner.expects(:run).never
|
Guard::JasmineHeadlessWebkit::Runner.expects(:run).never
|
||||||
guard.expects(:run_all).once.returns(true)
|
guard.expects(:run_all).once.returns(true)
|
||||||
|
|
||||||
guard.run_on_change([]).should be_true
|
guard.run_on_change([]).should be_true
|
||||||
|
@ -147,7 +145,7 @@ describe Guard::JasmineHeadlessWebkit do
|
||||||
|
|
||||||
context "Files I don't care about given, ignore" do
|
context "Files I don't care about given, ignore" do
|
||||||
it 'should run all but not run once' do
|
it 'should run all but not run once' do
|
||||||
Guard::JasmineHeadlessWebkitRunner.expects(:run).never
|
Guard::JasmineHeadlessWebkit::Runner.expects(:run).never
|
||||||
guard.expects(:run_all).once
|
guard.expects(:run_all).once
|
||||||
|
|
||||||
guard.run_on_change(%w{test.jst})
|
guard.run_on_change(%w{test.jst})
|
||||||
|
@ -164,7 +162,7 @@ describe Guard::JasmineHeadlessWebkit do
|
||||||
|
|
||||||
context 'not a duplicate' do
|
context 'not a duplicate' do
|
||||||
it 'should expand the glob' do
|
it 'should expand the glob' do
|
||||||
Guard::JasmineHeadlessWebkitRunner.expects(:run).with(absolute(%w{file1.js file2.js}), {}).returns(false)
|
Guard::JasmineHeadlessWebkit::Runner.expects(:run).with(absolute(%w{file1.js file2.js}), {}).returns(false)
|
||||||
|
|
||||||
guard.run_on_change(%w{file*.js})
|
guard.run_on_change(%w{file*.js})
|
||||||
end
|
end
|
||||||
|
@ -173,7 +171,7 @@ describe Guard::JasmineHeadlessWebkit do
|
||||||
context 'a duplicate' do
|
context 'a duplicate' do
|
||||||
it 'should expand the glob and uniq' do
|
it 'should expand the glob and uniq' do
|
||||||
guard.instance_variable_set(:@files_to_rerun, absolute(%w{file1.js}))
|
guard.instance_variable_set(:@files_to_rerun, absolute(%w{file1.js}))
|
||||||
Guard::JasmineHeadlessWebkitRunner.expects(:run).with(absolute(%w{file1.js file2.js}), {}).returns(false)
|
Guard::JasmineHeadlessWebkit::Runner.expects(:run).with(absolute(%w{file1.js file2.js}), {}).returns(false)
|
||||||
|
|
||||||
guard.run_on_change(%w{file*.js})
|
guard.run_on_change(%w{file*.js})
|
||||||
end
|
end
|
||||||
|
@ -184,7 +182,7 @@ describe Guard::JasmineHeadlessWebkit do
|
||||||
context 'with run_before' do
|
context 'with run_before' do
|
||||||
context 'with failing command' do
|
context 'with failing command' do
|
||||||
before do
|
before do
|
||||||
Guard::JasmineHeadlessWebkitRunner.expects(:run).never
|
Guard::JasmineHeadlessWebkit::Runner.expects(:run).never
|
||||||
Guard::UI.expects(:info).with(regexp_matches(/false/))
|
Guard::UI.expects(:info).with(regexp_matches(/false/))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -197,7 +195,7 @@ describe Guard::JasmineHeadlessWebkit do
|
||||||
|
|
||||||
context 'with succeeding command' do
|
context 'with succeeding command' do
|
||||||
before do
|
before do
|
||||||
Guard::JasmineHeadlessWebkitRunner.expects(:run).once
|
Guard::JasmineHeadlessWebkit::Runner.expects(:run).once
|
||||||
Guard::UI.expects(:info).with(regexp_matches(/true/))
|
Guard::UI.expects(:info).with(regexp_matches(/true/))
|
||||||
Guard::UI.expects(:info).with(regexp_matches(/running all/))
|
Guard::UI.expects(:info).with(regexp_matches(/running all/))
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
require 'mocha'
|
require 'mocha'
|
||||||
require 'guard'
|
require 'guard'
|
||||||
|
require 'guard/jasmine-headless-webkit'
|
||||||
|
require 'fakefs/spec_helpers'
|
||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.mock_with :mocha
|
config.mock_with :mocha
|
||||||
|
|
Loading…
Reference in New Issue