yeah, it's working

This commit is contained in:
John Bintz 2011-05-23 21:28:01 -04:00
parent a0a8cf213b
commit 00fbd41f07
10 changed files with 109 additions and 6 deletions

View File

@ -2,3 +2,6 @@ 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'
gem 'rspec'
gem 'mocha'

17
Guardfile Normal file
View File

@ -0,0 +1,17 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'rspec', :version => 2 do
watch(%r{^spec/.+_spec\.rb})
watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch('spec/spec_helper.rb') { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
watch(%r{^spec/.+_spec\.rb})
watch(%r{^app/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
end

0
README.md Normal file
View File

View File

@ -4,7 +4,7 @@ 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::JasmineHeadlessWebkit::VERSION s.version = Guard::JasmineHeadlessWebkitVersion::VERSION
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"]

View File

@ -1,5 +1,6 @@
require 'guard' require 'guard'
require 'guard/guard' require 'guard/guard'
require 'guard/jasmine-headless-webkit/runner'
module Guard module Guard
class JasmineHeadlessWebkit < Guard class JasmineHeadlessWebkit < Guard
@ -16,13 +17,11 @@ module Guard
end end
def run_all def run_all
system %{jasmine-headless-webkit} JasmineHeadlessWebkitRunner.run
end end
def run_on_change(paths) def run_on_change(paths)
system %{jasmine-headless-webkit #{paths.join(" ")}} run_all if JasmineHeadlessWebkitRunner.run(paths) != 1
run_all if $?.exitstatus != 1
end end
end end

View File

@ -0,0 +1,11 @@
module Guard
class JasmineHeadlessWebkitRunner
class << self
def run(paths = [])
system %{jasmine-headless-webkit #{paths.join(" ")}}
$?.exitstatus
end
end
end
end

View File

@ -0,0 +1,9 @@
# Run JS and CoffeeScript files in a typical Rails 3.1 fashion, placing Underscore templates in app/views/*.jst
guard 'jasmine-headless-webkit' do
watch(%r{^app/views/.*\.jst})
watch(%r{^public/javascripts/(.*)\.js}) { |m| newest_js_file("spec/javascripts/#{m[1]}") }
watch(%r{^app/assets/javascripts/(.*)\.(js|coffee)}) { |m| newest_js_file("spec/javascripts/#{m[1]}") }
watch(%r{^spec/javascripts/(.*)_spec\..*}) { |m| newest_js_file("spec/javascripts/#{m[1]}") }
end

View File

@ -1,5 +1,5 @@
module Guard module Guard
module JasmineHeadlessWebkit module JasmineHeadlessWebkitVersion
VERSION = "0.0.1" VERSION = "0.0.1"
end end
end end

View File

@ -0,0 +1,48 @@
require 'spec_helper'
require 'guard/jasmine-headless-webkit'
describe Guard::JasmineHeadlessWebkit do
let(:guard) { Guard::JasmineHeadlessWebkit.new([], options) }
let(:options) { {} }
describe "#start" do
context 'no all on start' do
let(:options) { { :all_on_start => false } }
it "should not run all" do
guard.expects(:run_all).never
guard.start
end
end
context 'all on start' do
let(:options) { { :all_on_start => true } }
it "should not run all" do
guard.expects(:run_all).once
guard.start
end
end
end
describe '#run_on_change' do
context 'jhw call fails' do
it "should not run all" do
Guard::JasmineHeadlessWebkitRunner.expects(:run).returns(1)
guard.expects(:run_all).never
guard.run_on_change(%w{test})
end
end
context 'succeed, run all' do
it "should run all" do
Guard::JasmineHeadlessWebkitRunner.expects(:run).returns(0)
guard.expects(:run_all).once
guard.run_on_change(%w{test})
end
end
end
end

16
spec/spec_helper.rb Normal file
View File

@ -0,0 +1,16 @@
require 'mocha'
require 'guard'
RSpec.configure do |config|
config.mock_with :mocha
end
module Guard
module UI
class << self
def info(*args)
end
end
end
end