guard-jasmine-headless-webkit 0.3.0 → 0.3.2

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/Gemfile CHANGED
@@ -2,10 +2,12 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in guard-jasmine-headless-webkit.gemspec
4
4
  gemspec
5
- gem 'guard', :git => 'https://github.com/guard/guard.git'
5
+ gem 'guard', :git => 'git://github.com/guard/guard.git'
6
6
  gem 'rspec'
7
7
  gem 'mocha'
8
- gem 'rake', '0.8.7'
8
+ gem 'rake', '0.9.2'
9
9
  gem 'growl'
10
10
  gem 'fakefs', :require => nil
11
11
  gem 'jasmine-headless-webkit', :path => '../jasmine-headless-webkit'
12
+ gem 'coffee-script'
13
+ gem 'guard-rspec'
data/README.md CHANGED
@@ -16,6 +16,7 @@ home folder's `.jasmine-headless-webkit` file.
16
16
 
17
17
  * `:all_on_start => false` to not run everything when starting, just like `guard-rspec`.
18
18
  * `:valid_extensions => %w{js coffee}` to only trigger `run_on_change` events for files with these extensions. Forces Guard to re-run all tests when any other matched file changes.
19
+ * All other options from `Jasmine::Headless::Runner`: (see the [list of available options](https://github.com/johnbintz/jasmine-headless-webkit/blob/master/lib/jasmine/headless/options.rb#L11A))
19
20
 
20
21
  ### Deprecated options
21
22
  * `:run_before => "<command to run>"` to run a command before running specs. If the command fails, the test run stops.
data/Rakefile CHANGED
@@ -13,27 +13,25 @@ require 'rspec/core/rake_task'
13
13
 
14
14
  RSpec::Core::RakeTask.new(:spec)
15
15
 
16
+ PLATFORMS = %w{1.8.7 1.9.2 ree 1.9.3-rc1}
17
+
18
+ def rvm_bundle(command = '')
19
+ Bundler.with_clean_env do
20
+ system %{bash -c 'unset BUNDLE_BIN_PATH && unset BUNDLE_GEMFILE && rvm #{PLATFORMS.join(',')} do bundle #{command}'}.tap { |o| p o }
21
+ end
22
+ end
23
+
24
+ class SpecFailure < StandardError; end
25
+ class BundleFailure < StandardError; end
26
+
16
27
  namespace :spec do
17
28
  desc "Run on three Rubies"
18
29
  task :platforms do
19
- current = %x{rvm-prompt v}
20
-
21
- fail = false
22
- %w{1.8.7 1.9.2 ree}.each do |version|
23
- puts "Switching to #{version}"
24
- Bundler.with_clean_env do
25
- system %{bash -c 'source ~/.rvm/scripts/rvm && rvm #{version} && bundle exec rake spec'}
26
- end
27
- if $?.exitstatus != 0
28
- fail = true
29
- break
30
- end
31
- end
32
-
33
- system %{rvm #{current}}
34
-
35
- exit (fail ? 1 : 0)
30
+ rvm_bundle "update"
31
+ rvm_bundle "exec rspec spec"
32
+ raise SpecError.new if $?.exitstatus != 0
36
33
  end
37
34
  end
38
35
 
39
36
  task :default => 'spec:platforms'
37
+
@@ -1,10 +1,8 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "guard/jasmine-headless-webkit/version"
4
2
 
5
3
  Gem::Specification.new do |s|
6
4
  s.name = "guard-jasmine-headless-webkit"
7
- s.version = Guard::JasmineHeadlessWebkitVersion::VERSION
5
+ s.version = '0.3.2'
8
6
  s.platform = Gem::Platform::RUBY
9
7
  s.authors = ["John Bintz"]
10
8
  s.email = ["john@coswellproductions.com"]
@@ -19,7 +17,7 @@ Gem::Specification.new do |s|
19
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
18
  s.require_paths = ["lib"]
21
19
 
22
- s.add_dependency 'guard', '>= 0.4.0'
23
- s.add_dependency 'jasmine-headless-webkit', '>= 0.7.0'
20
+ s.add_runtime_dependency 'guard', '>= 0.4.0'
21
+ s.add_runtime_dependency 'jasmine-headless-webkit', '>= 0.7.0'
24
22
  end
25
23
 
@@ -1,10 +1,11 @@
1
1
  require 'guard'
2
2
  require 'guard/guard'
3
- require 'guard/jasmine-headless-webkit/runner'
4
3
  require 'coffee-script'
5
4
 
6
5
  module Guard
7
6
  class JasmineHeadlessWebkit < Guard
7
+ autoload :Runner, 'guard/jasmine-headless-webkit/runner'
8
+
8
9
  DEFAULT_EXTENSIONS = %w{js coffee}
9
10
 
10
11
  ALL_SPECS_MESSAGE = "Guard::JasmineHeadlessWebkit running all specs..."
@@ -12,13 +13,18 @@ module Guard
12
13
 
13
14
  attr_reader :files_to_rerun
14
15
 
16
+ DEFAULT_OPTIONS = {
17
+ :all_on_start => true,
18
+ :run_before => false,
19
+ :valid_extensions => DEFAULT_EXTENSIONS
20
+ }
21
+
15
22
  def initialize(watchers = [], options = {})
16
23
  super
17
- @options = {
18
- :all_on_start => true,
19
- :run_before => false,
20
- :valid_extensions => DEFAULT_EXTENSIONS
21
- }.merge(options)
24
+
25
+ @options = DEFAULT_OPTIONS.merge(options)
26
+ @filtered_options = options
27
+ DEFAULT_OPTIONS.keys.each { |key| @filtered_options.delete(key) }
22
28
 
23
29
  UI.deprecation ":run_before is deprecated. Use guard-shell to do something beforehand. This will be removed in a future release." if @options[:run_before]
24
30
 
@@ -67,16 +73,14 @@ module Guard
67
73
  else
68
74
  UI.info(SOME_SPECS_MESSAGE % paths.join(' '))
69
75
  end
70
-
71
- if failed_files = JasmineHeadlessWebkitRunner.run(paths)
72
- @files_to_rerun = failed_files
73
- end
74
-
75
- failed_files && failed_files.empty?
76
+ failed_files = Runner.run(paths, @filtered_options)
77
+ @files_to_rerun = failed_files || paths
78
+
79
+ failed_files && @files_to_rerun.empty?
76
80
  end
77
81
 
78
82
  def filter_paths(paths)
79
- paths.find_all { |path| File.extname(path)[valid_extensions] }.uniq
83
+ paths.collect { |path| Dir[path] }.flatten.find_all { |path| File.extname(path)[valid_extensions] }.collect { |path| File.expand_path(path) }.uniq
80
84
  end
81
85
 
82
86
  def valid_extensions
@@ -2,49 +2,51 @@ require 'guard/notifier'
2
2
  require 'jasmine-headless-webkit'
3
3
 
4
4
  module Guard
5
- class JasmineHeadlessWebkitRunner
6
- class << self
7
- def run(paths = [])
8
- file = Tempfile.new('guard-jasmine-headless-webkit')
9
- file.close
5
+ class JasmineHeadlessWebkit
6
+ class Runner
7
+ class << self
8
+ def run(paths = [], options = {})
9
+ file = Tempfile.new('guard-jasmine-headless-webkit')
10
+ file.close
10
11
 
11
- Jasmine::Headless::Runner.run(:report => file.path, :colors => true, :files => paths)
12
+ options.merge!(:report => file.path, :colors => true, :files => paths)
12
13
 
13
- notify(file.path)
14
- end
14
+ Jasmine::Headless::Runner.run(options)
15
15
 
16
- def notify(file)
17
- if (report = Jasmine::Headless::Report.load(file)).valid?
18
- Notifier.notify(message(report.total, report.failed, report.time, report.has_used_console?), :title => 'Jasmine results', :image => image(report.has_used_console?, report.failed))
19
- report.failed_files
20
- else
21
- raise Jasmine::Headless::InvalidReport.new
16
+ notify(file.path)
22
17
  end
23
- rescue Jasmine::Headless::InvalidReport => e
24
- Notifier.notify('Spec runner interrupted!', :title => 'Jasmine results', :image => :failed)
25
- rescue Exception => e
26
- p e
27
- end
28
18
 
29
- private
30
- def message(total, fails, secs, any_console)
31
- total_word = (total.to_i == 1) ? "test" : "tests"
19
+ def notify(file)
20
+ if (report = Jasmine::Headless::Report.load(file)).valid?
21
+ Notifier.notify(message(report.total, report.failed, report.time, report.has_used_console?), :title => 'Jasmine results', :image => image(report.has_used_console?, report.failed))
22
+ report.failed_files
23
+ else
24
+ raise Jasmine::Headless::InvalidReport
25
+ end
26
+ rescue Jasmine::Headless::InvalidReport => e
27
+ Notifier.notify('Spec runner interrupted!', :title => 'Jasmine results', :image => :failed)
28
+ false
29
+ end
32
30
 
33
- "#{total} #{total_word}, #{fails} failures, #{secs} secs#{any_console ? ', console.log used' : ''}."
34
- end
31
+ private
32
+ def message(total, fails, secs, any_console)
33
+ total_word = (total.to_i == 1) ? "test" : "tests"
34
+
35
+ "#{total} #{total_word}, #{fails} failures, #{secs} secs#{any_console ? ', console.log used' : ''}."
36
+ end
35
37
 
36
- def image(any_console, fails)
37
- if any_console
38
- :pending
39
- else
40
- if fails.to_i == 0
41
- :success
38
+ def image(any_console, fails)
39
+ if any_console
40
+ :pending
42
41
  else
43
- :failed
42
+ if fails.to_i == 0
43
+ :success
44
+ else
45
+ :failed
46
+ end
44
47
  end
45
48
  end
46
49
  end
47
50
  end
48
51
  end
49
52
  end
50
-
@@ -1,8 +1,14 @@
1
1
  require 'spec_helper'
2
- require 'guard/jasmine-headless-webkit/runner'
3
- require 'fakefs/spec_helpers'
4
2
 
5
- describe Guard::JasmineHeadlessWebkitRunner do
3
+ describe Guard::JasmineHeadlessWebkit::Runner do
4
+ describe '.run' do
5
+ it 'should pass along options' do
6
+ Jasmine::Headless::Runner.expects(:run).with(has_key(:full_run))
7
+
8
+ Guard::JasmineHeadlessWebkit::Runner.run([], :full_run => false)
9
+ end
10
+ end
11
+
6
12
  describe '.notify' do
7
13
  include FakeFS::SpecHelpers
8
14
 
@@ -18,7 +24,7 @@ describe Guard::JasmineHeadlessWebkitRunner do
18
24
  it 'should notify with the right information' do
19
25
  Guard::Notifier.expects(:notify).with("1 test, 0 failures, 5.0 secs.", { :title => 'Jasmine results', :image => :success })
20
26
 
21
- Guard::JasmineHeadlessWebkitRunner.notify(file).should == []
27
+ Guard::JasmineHeadlessWebkit::Runner.notify(file).should == []
22
28
  end
23
29
  end
24
30
 
@@ -31,7 +37,7 @@ REPORT
31
37
  it 'should notify with the right information' do
32
38
  Guard::Notifier.expects(:notify).with("1 test, 1 failures, 5.0 secs.", { :title => 'Jasmine results', :image => :failed })
33
39
 
34
- Guard::JasmineHeadlessWebkitRunner.notify(file).should == [ 'file.js' ]
40
+ Guard::JasmineHeadlessWebkit::Runner.notify(file).should == [ 'file.js' ]
35
41
  end
36
42
  end
37
43
 
@@ -41,7 +47,7 @@ REPORT
41
47
  it 'should notify failure' do
42
48
  Guard::Notifier.expects(:notify).with("Spec runner interrupted!", { :title => 'Jasmine results', :image => :failed })
43
49
 
44
- Guard::JasmineHeadlessWebkitRunner.notify(file).should be_nil
50
+ Guard::JasmineHeadlessWebkit::Runner.notify(file).should be_false
45
51
  end
46
52
  end
47
53
  end
@@ -1,5 +1,4 @@
1
1
  require 'spec_helper'
2
- require 'guard/jasmine-headless-webkit'
3
2
 
4
3
  describe Guard::JasmineHeadlessWebkit do
5
4
  let(:guard) { Guard::JasmineHeadlessWebkit.new([], options) }
@@ -42,7 +41,7 @@ describe Guard::JasmineHeadlessWebkit do
42
41
 
43
42
  context 'fails' do
44
43
  it 'should return false' do
45
- Guard::JasmineHeadlessWebkitRunner.stubs(:run).returns(['file.js'])
44
+ Guard::JasmineHeadlessWebkit::Runner.stubs(:run).returns(['file.js'])
46
45
 
47
46
  guard.run_all.should be_false
48
47
  guard.files_to_rerun.should == ['file.js']
@@ -51,20 +50,45 @@ describe Guard::JasmineHeadlessWebkit do
51
50
 
52
51
  context 'succeeds' do
53
52
  it 'should return true' do
54
- Guard::JasmineHeadlessWebkitRunner.stubs(:run).returns([])
53
+ Guard::JasmineHeadlessWebkit::Runner.stubs(:run).returns([])
55
54
 
56
55
  guard.run_all.should be_true
57
56
  guard.files_to_rerun.should == []
58
57
  end
59
58
  end
59
+
60
+ context 'pass along jhw options' do
61
+ let(:options) { { :all_on_start => false, :full_run => false } }
62
+
63
+ it 'should only pass along jhw options' do
64
+ Guard::JasmineHeadlessWebkit::Runner.expects(:run).with([], :full_run => false)
65
+
66
+ guard.run_all
67
+ end
68
+ end
60
69
  end
61
70
 
62
71
  describe '#run_on_change' do
72
+ include FakeFS::SpecHelpers
73
+
63
74
  let(:one_file) { %w{test.js} }
64
75
 
76
+ def absolute(file)
77
+ case file
78
+ when Array
79
+ file.collect { |f| absolute(f) }
80
+ else
81
+ File.expand_path(file)
82
+ end
83
+ end
84
+
85
+ before do
86
+ File.open(one_file.first, 'wb')
87
+ end
88
+
65
89
  context 'two files' do
66
90
  it "should only run one" do
67
- Guard::JasmineHeadlessWebkitRunner.expects(:run).with(one_file).returns(one_file)
91
+ Guard::JasmineHeadlessWebkit::Runner.expects(:run).with(absolute(one_file), {}).returns(one_file)
68
92
 
69
93
  guard.run_on_change(%w{test.js test.js}).should be_false
70
94
  guard.files_to_rerun.should == one_file
@@ -73,7 +97,7 @@ describe Guard::JasmineHeadlessWebkit do
73
97
 
74
98
  context 'one file no priors' do
75
99
  it "should not run all" do
76
- Guard::JasmineHeadlessWebkitRunner.expects(:run).returns(one_file)
100
+ Guard::JasmineHeadlessWebkit::Runner.expects(:run).returns(one_file)
77
101
 
78
102
  guard.run_on_change(one_file).should be_false
79
103
  guard.files_to_rerun.should == one_file
@@ -83,7 +107,7 @@ describe Guard::JasmineHeadlessWebkit do
83
107
  context 'one file one prior' do
84
108
  it "should not run all" do
85
109
  guard.instance_variable_set(:@files_to_rerun, [ "two.js" ])
86
- Guard::JasmineHeadlessWebkitRunner.expects(:run).with(one_file + [ "two.js" ]).returns(one_file)
110
+ Guard::JasmineHeadlessWebkit::Runner.expects(:run).with(absolute(one_file) + [ "two.js" ], {}).returns(one_file)
87
111
 
88
112
  guard.run_on_change(one_file).should be_false
89
113
  guard.files_to_rerun.should == one_file
@@ -92,17 +116,17 @@ describe Guard::JasmineHeadlessWebkit do
92
116
 
93
117
  context 'failed hard' do
94
118
  it "should not run all" do
95
- guard.instance_variable_set(:@files_to_rerun, one_file)
96
- Guard::JasmineHeadlessWebkitRunner.expects(:run).with(one_file).returns(nil)
119
+ guard.instance_variable_set(:@files_to_rerun, absolute(one_file))
120
+ Guard::JasmineHeadlessWebkit::Runner.expects(:run).with(absolute(one_file), {}).returns(false)
97
121
 
98
122
  guard.run_on_change(one_file).should be_false
99
- guard.files_to_rerun.should == one_file
123
+ guard.files_to_rerun.should == absolute(one_file)
100
124
  end
101
125
  end
102
126
 
103
127
  context 'succeed, but still do not run all' do
104
128
  it "should run all" do
105
- Guard::JasmineHeadlessWebkitRunner.expects(:run).returns([])
129
+ Guard::JasmineHeadlessWebkit::Runner.expects(:run).returns([])
106
130
 
107
131
  guard.run_on_change(one_file).should be_true
108
132
  guard.files_to_rerun.should == []
@@ -111,7 +135,7 @@ describe Guard::JasmineHeadlessWebkit do
111
135
 
112
136
  context 'no files given, just run all' do
113
137
  it 'should run all but not run once' do
114
- Guard::JasmineHeadlessWebkitRunner.expects(:run).never
138
+ Guard::JasmineHeadlessWebkit::Runner.expects(:run).never
115
139
  guard.expects(:run_all).once.returns(true)
116
140
 
117
141
  guard.run_on_change([]).should be_true
@@ -121,19 +145,44 @@ describe Guard::JasmineHeadlessWebkit do
121
145
 
122
146
  context "Files I don't care about given, ignore" do
123
147
  it 'should run all but not run once' do
124
- Guard::JasmineHeadlessWebkitRunner.expects(:run).never
148
+ Guard::JasmineHeadlessWebkit::Runner.expects(:run).never
125
149
  guard.expects(:run_all).once
126
150
 
127
151
  guard.run_on_change(%w{test.jst})
128
152
  guard.files_to_rerun.should == []
129
153
  end
130
154
  end
155
+
156
+ context 'glob given' do
157
+ let(:files) { %w{file1.js file2.js other.js} }
158
+
159
+ before do
160
+ files.each { |file| File.open(file, 'wb') }
161
+ end
162
+
163
+ context 'not a duplicate' do
164
+ it 'should expand the glob' do
165
+ Guard::JasmineHeadlessWebkit::Runner.expects(:run).with(absolute(%w{file1.js file2.js}), {}).returns(false)
166
+
167
+ guard.run_on_change(%w{file*.js})
168
+ end
169
+ end
170
+
171
+ context 'a duplicate' do
172
+ it 'should expand the glob and uniq' do
173
+ guard.instance_variable_set(:@files_to_rerun, absolute(%w{file1.js}))
174
+ Guard::JasmineHeadlessWebkit::Runner.expects(:run).with(absolute(%w{file1.js file2.js}), {}).returns(false)
175
+
176
+ guard.run_on_change(%w{file*.js})
177
+ end
178
+ end
179
+ end
131
180
  end
132
181
 
133
182
  context 'with run_before' do
134
183
  context 'with failing command' do
135
184
  before do
136
- Guard::JasmineHeadlessWebkitRunner.expects(:run).never
185
+ Guard::JasmineHeadlessWebkit::Runner.expects(:run).never
137
186
  Guard::UI.expects(:info).with(regexp_matches(/false/))
138
187
  end
139
188
 
@@ -146,7 +195,7 @@ describe Guard::JasmineHeadlessWebkit do
146
195
 
147
196
  context 'with succeeding command' do
148
197
  before do
149
- Guard::JasmineHeadlessWebkitRunner.expects(:run).once
198
+ Guard::JasmineHeadlessWebkit::Runner.expects(:run).once
150
199
  Guard::UI.expects(:info).with(regexp_matches(/true/))
151
200
  Guard::UI.expects(:info).with(regexp_matches(/running all/))
152
201
  end
@@ -1,5 +1,7 @@
1
1
  require 'mocha'
2
2
  require 'guard'
3
+ require 'guard/jasmine-headless-webkit'
4
+ require 'fakefs/spec_helpers'
3
5
 
4
6
  RSpec.configure do |config|
5
7
  config.mock_with :mocha
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-jasmine-headless-webkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-12 00:00:00.000000000 -04:00
13
- default_executable:
12
+ date: 2011-11-03 00:00:00.000000000Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: guard
17
- requirement: &2166592000 !ruby/object:Gem::Requirement
16
+ requirement: &2162482180 !ruby/object:Gem::Requirement
18
17
  none: false
19
18
  requirements:
20
19
  - - ! '>='
@@ -22,10 +21,10 @@ dependencies:
22
21
  version: 0.4.0
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *2166592000
24
+ version_requirements: *2162482180
26
25
  - !ruby/object:Gem::Dependency
27
26
  name: jasmine-headless-webkit
28
- requirement: &2166591500 !ruby/object:Gem::Requirement
27
+ requirement: &2162481700 !ruby/object:Gem::Requirement
29
28
  none: false
30
29
  requirements:
31
30
  - - ! '>='
@@ -33,7 +32,7 @@ dependencies:
33
32
  version: 0.7.0
34
33
  type: :runtime
35
34
  prerelease: false
36
- version_requirements: *2166591500
35
+ version_requirements: *2162481700
37
36
  description: Run jasmine-headless-webkit using guard
38
37
  email:
39
38
  - john@coswellproductions.com
@@ -50,7 +49,6 @@ files:
50
49
  - lib/guard/jasmine-headless-webkit.rb
51
50
  - lib/guard/jasmine-headless-webkit/runner.rb
52
51
  - lib/guard/jasmine-headless-webkit/templates/Guardfile
53
- - lib/guard/jasmine-headless-webkit/version.rb
54
52
  - script/gemfile
55
53
  - script/hooks/pre-commit
56
54
  - script/initialize-environment
@@ -58,7 +56,6 @@ files:
58
56
  - spec/lib/guard/jasmine-headless-webkit/runner_spec.rb
59
57
  - spec/lib/guard/jasmine-headless-webkit_spec.rb
60
58
  - spec/spec_helper.rb
61
- has_rdoc: true
62
59
  homepage: ''
63
60
  licenses: []
64
61
  post_install_message:
@@ -79,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
76
  version: '0'
80
77
  requirements: []
81
78
  rubyforge_project: guard-jasmine-headless-webkit
82
- rubygems_version: 1.6.2
79
+ rubygems_version: 1.8.11
83
80
  signing_key:
84
81
  specification_version: 3
85
82
  summary: Run jasmine-headless-webkit using guard
@@ -1,5 +0,0 @@
1
- module Guard
2
- module JasmineHeadlessWebkitVersion
3
- VERSION = "0.3.0"
4
- end
5
- end