guard-jasmine-headless-webkit 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in guard-jasmine-headless-webkit.gemspec
4
+ gemspec
5
+ gem 'guard'
6
+ gem 'rspec'
7
+ gem 'mocha'
data/Guardfile ADDED
@@ -0,0 +1,17 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec', :version => 2 do
5
+ watch(%r{^spec/.+_spec\.rb})
6
+ watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+
9
+ # Rails example
10
+ watch('spec/spec_helper.rb') { "spec" }
11
+ watch('config/routes.rb') { "spec/routing" }
12
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
13
+ watch(%r{^spec/.+_spec\.rb})
14
+ watch(%r{^app/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
15
+ watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
16
+ 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"] }
17
+ end
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # Guard support for jasmine-headless-webkit
2
+
3
+ Add running your Jasmine specs to your `Guardfile` via [`jasmine-headless-webkit`](http://github.com/johnbintz/jasmine-headless-webkit/). Nice!
4
+
5
+ guard 'jasmine-headless-webkit' do
6
+ watch(%r{^app/assets/javascripts/(.*)\..*}) { |m| newest_js_file("spec/javascripts/#{m[1]}_spec") }
7
+ end
8
+
9
+ `gem install guard-jasmine-headless-webkit` and then `guard init jasmine-headless-webkit` in your project directory to get started.
10
+ You should also put it in your `Gemfile` because, hey, why not, right?
11
+
12
+ ## `guard` options
13
+
14
+ * `:all_on_start => false` to not run everything when starting, just like `guard-rspec`
15
+
16
+ ## What's the deal with `newest_js_file`?
17
+
18
+ Since one could, theoretically, have a CoffeeScript app file and a JavaScript spec file (or vice versa), the search for the correct matching
19
+ file is a little more complicated. `newest_js_file` extends the Guard DSL to search the given path for the newest `.js` or `.coffee` file:
20
+
21
+ newest_js_file('spec/javascripts/models/my_model')
22
+ #=> search for Dir['spec/javascripts/models/my_model*.{js,coffee}'] and return the newest file found
23
+
24
+ If you 100% know you won't need that support, modify your `Guardfile` as appropriate.
25
+
26
+ ## ...and the `.jst` file search?
27
+
28
+ I use [Backbone.js](http://documentcloud.github.com/backbone/) a lot, and I put my Underscore view templates in `app/views/*.jst`
29
+ and mash them all together with [Jammit](https://github.com/documentcloud/jammit) for use in my apps. Feel free to change that, it's your `Guardfile` after all.
30
+ Or, try it. It's easy to do in your `assets.yml` file:
31
+
32
+ templates:
33
+ - app/views/*.jst
34
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "guard/jasmine-headless-webkit/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "guard-jasmine-headless-webkit"
7
+ s.version = Guard::JasmineHeadlessWebkitVersion::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["John Bintz"]
10
+ s.email = ["john@coswellproductions.com"]
11
+ s.homepage = ""
12
+ s.summary = %q{Run jasmine-headless-webkit using guard}
13
+ s.description = %q{Run jasmine-headless-webkit using guard}
14
+
15
+ s.rubyforge_project = "guard-jasmine-headless-webkit"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_dependency 'guard', '>= 0.2.2'
23
+ s.add_dependency 'jasmine-headless-webkit'
24
+ end
@@ -0,0 +1,34 @@
1
+ require 'guard'
2
+ require 'guard/guard'
3
+ require 'guard/jasmine-headless-webkit/runner'
4
+
5
+ module Guard
6
+ class JasmineHeadlessWebkit < Guard
7
+ def initialize(watchers = [], options = {})
8
+ super
9
+ @options = {
10
+ :all_on_start => true
11
+ }.merge(options)
12
+ end
13
+
14
+ def start
15
+ UI.info "Guard::JasmineHeadlessWebkit is running."
16
+ run_all if @options[:all_on_start]
17
+ end
18
+
19
+ def run_all
20
+ JasmineHeadlessWebkitRunner.run
21
+ end
22
+
23
+ def run_on_change(paths)
24
+ run_all if JasmineHeadlessWebkitRunner.run(paths) != 1
25
+ end
26
+ end
27
+
28
+ class Dsl
29
+ def newest_js_file(path)
30
+ Dir[path + '*.{js,coffee}'].sort { |left, right| File.mtime(right) <=> File.mtime(left) }.first
31
+ end
32
+ end
33
+ end
34
+
@@ -0,0 +1,11 @@
1
+ module Guard
2
+ class JasmineHeadlessWebkitRunner
3
+ class << self
4
+ def run(paths = [])
5
+ system %{jasmine-headless-webkit #{paths.join(" ")}}
6
+ $?.exitstatus
7
+ end
8
+ end
9
+ end
10
+ end
11
+
@@ -0,0 +1,15 @@
1
+ # Run JS and CoffeeScript files in a typical Rails 3.1 fashion, placing Underscore templates in app/views/*.jst
2
+ # Your spec files end with _spec.{js,coffee}.
3
+
4
+ spec_location = "spec/javascripts/%s_spec"
5
+
6
+ # uncomment if you use NerdCapsSpec.js
7
+ # spec_location = "spec/javascripts/%sSpec"
8
+
9
+ guard 'jasmine-headless-webkit' do
10
+ watch(%r{^app/views/.*\.jst})
11
+ watch(%r{^public/javascripts/(.*)\.js}) { |m| newest_js_file(spec_location % m[1]) }
12
+ watch(%r{^app/assets/javascripts/(.*)\.(js|coffee)}) { |m| newest_js_file(spec_location % m[1]) }
13
+ watch(%r{^spec/javascripts/(.*)_spec\..*}) { |m| newest_js_file(spec_location % m[1]) }
14
+ end
15
+
@@ -0,0 +1,5 @@
1
+ module Guard
2
+ module JasmineHeadlessWebkitVersion
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+ require 'guard/jasmine-headless-webkit'
3
+
4
+ describe Guard::JasmineHeadlessWebkit do
5
+ let(:guard) { Guard::JasmineHeadlessWebkit.new([], options) }
6
+
7
+ let(:options) { {} }
8
+
9
+ describe "#start" do
10
+ context 'no all on start' do
11
+ let(:options) { { :all_on_start => false } }
12
+
13
+ it "should not run all" do
14
+ guard.expects(:run_all).never
15
+ guard.start
16
+ end
17
+ end
18
+
19
+ context 'all on start' do
20
+ let(:options) { { :all_on_start => true } }
21
+
22
+ it "should not run all" do
23
+ guard.expects(:run_all).once
24
+ guard.start
25
+ end
26
+ end
27
+ end
28
+
29
+ describe '#run_on_change' do
30
+ context 'jhw call fails' do
31
+ it "should not run all" do
32
+ Guard::JasmineHeadlessWebkitRunner.expects(:run).returns(1)
33
+ guard.expects(:run_all).never
34
+
35
+ guard.run_on_change(%w{test})
36
+ end
37
+ end
38
+
39
+ context 'succeed, run all' do
40
+ it "should run all" do
41
+ Guard::JasmineHeadlessWebkitRunner.expects(:run).returns(0)
42
+ guard.expects(:run_all).once
43
+
44
+ guard.run_on_change(%w{test})
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,16 @@
1
+ require 'mocha'
2
+ require 'guard'
3
+
4
+ RSpec.configure do |config|
5
+ config.mock_with :mocha
6
+ end
7
+
8
+ module Guard
9
+ module UI
10
+ class << self
11
+ def info(*args)
12
+ end
13
+ end
14
+ end
15
+ end
16
+
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-jasmine-headless-webkit
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - John Bintz
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-05-24 00:00:00 -04:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: guard
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 0.2.2
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: jasmine-headless-webkit
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: "0"
36
+ type: :runtime
37
+ version_requirements: *id002
38
+ description: Run jasmine-headless-webkit using guard
39
+ email:
40
+ - john@coswellproductions.com
41
+ executables: []
42
+
43
+ extensions: []
44
+
45
+ extra_rdoc_files: []
46
+
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - Guardfile
51
+ - README.md
52
+ - Rakefile
53
+ - guard-jasmine-headless-webkit.gemspec
54
+ - lib/guard/jasmine-headless-webkit.rb
55
+ - lib/guard/jasmine-headless-webkit/runner.rb
56
+ - lib/guard/jasmine-headless-webkit/templates/Guardfile
57
+ - lib/guard/jasmine-headless-webkit/version.rb
58
+ - spec/lib/guard/jasmine-headless-webkit_spec.rb
59
+ - spec/spec_helper.rb
60
+ has_rdoc: true
61
+ homepage: ""
62
+ licenses: []
63
+
64
+ post_install_message:
65
+ rdoc_options: []
66
+
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: "0"
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: "0"
81
+ requirements: []
82
+
83
+ rubyforge_project: guard-jasmine-headless-webkit
84
+ rubygems_version: 1.6.2
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: Run jasmine-headless-webkit using guard
88
+ test_files:
89
+ - spec/lib/guard/jasmine-headless-webkit_spec.rb
90
+ - spec/spec_helper.rb