guard-konacha-version 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 97191ad4c0b0ba7ffd6bb1680b8802311123ab26
4
+ data.tar.gz: 67a4a45338f04b767fa51f9981ba52f211c38bed
5
+ SHA512:
6
+ metadata.gz: eb4cc4251ab87f6e14d5c8f8b14d101ef35a097ef6cdea990629a2d5c7d8c442e8ffa0ffb92caf732a09be13263a76eb95e5b2cc168626392b64e09425ce8446
7
+ data.tar.gz: c8932db69d57b36995139dd5d7f2708b9f3e5551886455c7cfd40fcabaae941a3099e6bfc99c80f38b33caac76cbc11dad66b130d42f6ee6474377ed6854deb8
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ coverage
2
+ pkg
3
+ *.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --format progress
data/.travis.yml ADDED
@@ -0,0 +1,16 @@
1
+ language: ruby
2
+ before_install:
3
+ - travis_retry gem install bundler
4
+ rvm:
5
+ - 2.0.0
6
+ - 2.1
7
+ - ruby-head
8
+ - jruby
9
+ - rbx-2
10
+ gemfile:
11
+ - Gemfile
12
+ matrix:
13
+ allow_failures:
14
+ - rvm: rbx-2
15
+ # Use the faster container based infrastructure.
16
+ sudo: false
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rdoc'
4
+
5
+ # Specify your gem's dependencies in guard-konacha-rails.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,214 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ guard-konacha-version (1.1.0)
5
+ guard (>= 2)
6
+ guard-compat
7
+ konacha (>= 3.0)
8
+ rails (>= 4.2)
9
+
10
+ GEM
11
+ remote: http://rubygems.org/
12
+ specs:
13
+ actionmailer (4.2.0)
14
+ actionpack (= 4.2.0)
15
+ actionview (= 4.2.0)
16
+ activejob (= 4.2.0)
17
+ mail (~> 2.5, >= 2.5.4)
18
+ rails-dom-testing (~> 1.0, >= 1.0.5)
19
+ actionpack (4.2.0)
20
+ actionview (= 4.2.0)
21
+ activesupport (= 4.2.0)
22
+ rack (~> 1.6.0)
23
+ rack-test (~> 0.6.2)
24
+ rails-dom-testing (~> 1.0, >= 1.0.5)
25
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
26
+ actionview (4.2.0)
27
+ activesupport (= 4.2.0)
28
+ builder (~> 3.1)
29
+ erubis (~> 2.7.0)
30
+ rails-dom-testing (~> 1.0, >= 1.0.5)
31
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
32
+ activejob (4.2.0)
33
+ activesupport (= 4.2.0)
34
+ globalid (>= 0.3.0)
35
+ activemodel (4.2.0)
36
+ activesupport (= 4.2.0)
37
+ builder (~> 3.1)
38
+ activerecord (4.2.0)
39
+ activemodel (= 4.2.0)
40
+ activesupport (= 4.2.0)
41
+ arel (~> 6.0)
42
+ activesupport (4.2.0)
43
+ i18n (~> 0.7)
44
+ json (~> 1.7, >= 1.7.7)
45
+ minitest (~> 5.1)
46
+ thread_safe (~> 0.3, >= 0.3.4)
47
+ tzinfo (~> 1.1)
48
+ arel (6.0.0)
49
+ builder (3.2.2)
50
+ capybara (2.4.4)
51
+ mime-types (>= 1.16)
52
+ nokogiri (>= 1.3.3)
53
+ rack (>= 1.0.0)
54
+ rack-test (>= 0.5.4)
55
+ xpath (~> 2.0)
56
+ celluloid (0.16.0)
57
+ timers (~> 4.0.0)
58
+ cliver (0.3.2)
59
+ coderay (1.1.0)
60
+ colorize (0.7.5)
61
+ coveralls (0.7.8)
62
+ multi_json (~> 1.10)
63
+ rest-client (~> 1.7)
64
+ simplecov (~> 0.9.1)
65
+ term-ansicolor (~> 1.3)
66
+ thor (~> 0.19.1)
67
+ diff-lcs (1.2.5)
68
+ docile (1.1.5)
69
+ erubis (2.7.0)
70
+ ffi (1.9.6)
71
+ formatador (0.2.5)
72
+ globalid (0.3.0)
73
+ activesupport (>= 4.1.0)
74
+ guard (2.11.1)
75
+ formatador (>= 0.2.4)
76
+ listen (~> 2.7)
77
+ lumberjack (~> 1.0)
78
+ nenv (~> 0.1)
79
+ notiffany (~> 0.0)
80
+ pry (>= 0.9.12)
81
+ shellany (~> 0.0)
82
+ thor (>= 0.18.1)
83
+ guard-compat (1.2.1)
84
+ hike (1.2.3)
85
+ hitimes (1.2.2)
86
+ i18n (0.7.0)
87
+ json (1.8.2)
88
+ konacha (3.3.0)
89
+ actionpack (>= 3.1, < 5)
90
+ capybara
91
+ colorize
92
+ railties (>= 3.1, < 5)
93
+ sprockets
94
+ listen (2.8.5)
95
+ celluloid (>= 0.15.2)
96
+ rb-fsevent (>= 0.9.3)
97
+ rb-inotify (>= 0.9)
98
+ loofah (2.0.1)
99
+ nokogiri (>= 1.5.9)
100
+ lumberjack (1.0.9)
101
+ mail (2.6.3)
102
+ mime-types (>= 1.16, < 3)
103
+ method_source (0.8.2)
104
+ mime-types (2.4.3)
105
+ mini_portile (0.6.2)
106
+ minitest (5.5.1)
107
+ multi_json (1.10.1)
108
+ nenv (0.2.0)
109
+ netrc (0.10.2)
110
+ nokogiri (1.6.6.2)
111
+ mini_portile (~> 0.6.0)
112
+ notiffany (0.0.3)
113
+ nenv (~> 0.1)
114
+ shellany (~> 0.0)
115
+ poltergeist (1.5.1)
116
+ capybara (~> 2.1)
117
+ cliver (~> 0.3.1)
118
+ multi_json (~> 1.0)
119
+ websocket-driver (>= 0.2.0)
120
+ pry (0.10.1)
121
+ coderay (~> 1.1.0)
122
+ method_source (~> 0.8.1)
123
+ slop (~> 3.4)
124
+ rack (1.6.0)
125
+ rack-test (0.6.3)
126
+ rack (>= 1.0)
127
+ rails (4.2.0)
128
+ actionmailer (= 4.2.0)
129
+ actionpack (= 4.2.0)
130
+ actionview (= 4.2.0)
131
+ activejob (= 4.2.0)
132
+ activemodel (= 4.2.0)
133
+ activerecord (= 4.2.0)
134
+ activesupport (= 4.2.0)
135
+ bundler (>= 1.3.0, < 2.0)
136
+ railties (= 4.2.0)
137
+ sprockets-rails
138
+ rails-deprecated_sanitizer (1.0.3)
139
+ activesupport (>= 4.2.0.alpha)
140
+ rails-dom-testing (1.0.5)
141
+ activesupport (>= 4.2.0.beta, < 5.0)
142
+ nokogiri (~> 1.6.0)
143
+ rails-deprecated_sanitizer (>= 1.0.1)
144
+ rails-html-sanitizer (1.0.1)
145
+ loofah (~> 2.0)
146
+ railties (4.2.0)
147
+ actionpack (= 4.2.0)
148
+ activesupport (= 4.2.0)
149
+ rake (>= 0.8.7)
150
+ thor (>= 0.18.1, < 2.0)
151
+ rake (10.4.2)
152
+ rb-fsevent (0.9.4)
153
+ rb-inotify (0.9.5)
154
+ ffi (>= 0.5.0)
155
+ rdoc (4.2.0)
156
+ json (~> 1.4)
157
+ rest-client (1.7.2)
158
+ mime-types (>= 1.16, < 3.0)
159
+ netrc (~> 0.7)
160
+ rspec (3.1.0)
161
+ rspec-core (~> 3.1.0)
162
+ rspec-expectations (~> 3.1.0)
163
+ rspec-mocks (~> 3.1.0)
164
+ rspec-core (3.1.7)
165
+ rspec-support (~> 3.1.0)
166
+ rspec-expectations (3.1.2)
167
+ diff-lcs (>= 1.2.0, < 2.0)
168
+ rspec-support (~> 3.1.0)
169
+ rspec-mocks (3.1.3)
170
+ rspec-support (~> 3.1.0)
171
+ rspec-support (3.1.2)
172
+ shellany (0.0.1)
173
+ simplecov (0.9.1)
174
+ docile (~> 1.1.0)
175
+ multi_json (~> 1.0)
176
+ simplecov-html (~> 0.8.0)
177
+ simplecov-html (0.8.0)
178
+ slop (3.6.0)
179
+ sprockets (2.12.3)
180
+ hike (~> 1.2)
181
+ multi_json (~> 1.0)
182
+ rack (~> 1.0)
183
+ tilt (~> 1.1, != 1.3.0)
184
+ sprockets-rails (2.2.4)
185
+ actionpack (>= 3.0)
186
+ activesupport (>= 3.0)
187
+ sprockets (>= 2.8, < 4.0)
188
+ term-ansicolor (1.3.0)
189
+ tins (~> 1.0)
190
+ thor (0.19.1)
191
+ thread_safe (0.3.4)
192
+ tilt (1.4.1)
193
+ timecop (0.7.1)
194
+ timers (4.0.1)
195
+ hitimes
196
+ tins (1.3.3)
197
+ tzinfo (1.2.2)
198
+ thread_safe (~> 0.1)
199
+ websocket-driver (0.5.1)
200
+ websocket-extensions (>= 0.1.0)
201
+ websocket-extensions (0.1.1)
202
+ xpath (2.0.0)
203
+ nokogiri (~> 1.3)
204
+
205
+ PLATFORMS
206
+ ruby
207
+
208
+ DEPENDENCIES
209
+ coveralls
210
+ guard-konacha-version!
211
+ poltergeist
212
+ rdoc
213
+ rspec (>= 3)
214
+ timecop
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Leonid Beder
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new('spec')
6
+ Bundler::GemHelper.install_tasks
7
+
8
+ task :default => :spec
data/Readme.md ADDED
@@ -0,0 +1,51 @@
1
+ # Rediska
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/guard-konacha-rails.png)](http://badge.fury.io/rb/guard-konacha-rails)
4
+ [![Build Status](https://travis-ci.org/lbeder/guard-konacha-rails.png)](https://travis-ci.org/lbeder/guard-konacha-rails)
5
+ [![Dependency Status](https://gemnasium.com/lbeder/guard-konacha-rails.png)](https://gemnasium.com/lbeder/guard-konacha-rails)
6
+ [![Coverage Status](https://coveralls.io/repos/lbeder/guard-konacha-rails/badge.png)](https://coveralls.io/r/lbeder/guard-konacha-rails)
7
+
8
+ Automatically run your [Konacha](https://github.com/jfirebaugh/konacha) tests through [Guard](https://github.com/guard/guard/).
9
+
10
+ ## Setup
11
+
12
+ If you are using bundler add guard-konacha-rails to your Gemfile:
13
+
14
+ ``` ruby
15
+ gem 'guard-konacha-rails'
16
+ ```
17
+
18
+ Then run:
19
+
20
+ ```bash
21
+ $ bundle install
22
+ ```
23
+
24
+ Otherwise install the gem:
25
+
26
+ ```bash
27
+ $ gem install guard-konacha-rails
28
+ ```
29
+
30
+ ## License
31
+
32
+ The MIT License (MIT)
33
+
34
+ Copyright (c) 2013
35
+
36
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
37
+ this software and associated documentation files (the "Software"), to deal in
38
+ the Software without restriction, including without limitation the rights to
39
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
40
+ the Software, and to permit persons to whom the Software is furnished to do so,
41
+ subject to the following conditions:
42
+
43
+ The above copyright notice and this permission notice shall be included in all
44
+ copies or substantial portions of the Software.
45
+
46
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
47
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
48
+ FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
49
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
50
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
51
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ $:.push File.expand_path('../lib', __FILE__)
2
+ require 'guard/konacha/rails/version'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'guard-konacha-version'
6
+ s.version = Guard::KonachaRails::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ['Leonid Beder']
9
+ s.email = ['leonid.beder@gmail.com']
10
+ s.license = 'MIT'
11
+ s.homepage = 'https://github.com/lbeder/guard-konacha-rails'
12
+ s.summary = 'Guard plugin for the konacha testing framework'
13
+ s.description = 'Guard plugin for the konacha testing framework.'
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ['lib']
19
+
20
+ s.add_dependency 'guard', '>= 2'
21
+ s.add_dependency 'rails', '>= 4.2'
22
+ s.add_dependency 'konacha', '>= 3.0'
23
+ s.add_dependency 'guard-compat'
24
+
25
+ s.add_development_dependency 'rspec', '>= 3'
26
+ s.add_development_dependency 'coveralls'
27
+ s.add_development_dependency 'timecop'
28
+ s.add_development_dependency 'poltergeist'
29
+ end
@@ -0,0 +1,33 @@
1
+ require 'guard/konacha/rails/formatter'
2
+ require 'guard/konacha/rails/runner'
3
+ require 'guard/konacha/rails/server'
4
+
5
+ require 'guard/compat/plugin'
6
+ require 'rails'
7
+ require 'konacha'
8
+
9
+ module Guard
10
+ module KonachaRails
11
+ class Plugin < Guard::Plugin
12
+ attr_accessor :runner
13
+
14
+ def initialize(options = {})
15
+ super
16
+
17
+ @runner = Runner.new(options)
18
+ end
19
+
20
+ def start
21
+ runner.start
22
+ end
23
+
24
+ def run_all
25
+ runner.run
26
+ end
27
+
28
+ def run_on_changes(paths = [])
29
+ runner.run(paths)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,71 @@
1
+ require 'rails'
2
+ require 'konacha'
3
+
4
+ module Guard
5
+ module KonachaRails
6
+ class Formatter < ::Konacha::Formatter
7
+ def initialize
8
+ super($stdout)
9
+ end
10
+
11
+ def reset
12
+ io.puts('')
13
+ @examples = []
14
+ end
15
+
16
+ def dump_summary(duration, example_count, failure_count, pending_count); end
17
+ def dump_failures; end
18
+ def dump_pending; end
19
+
20
+ def success?
21
+ failed_examples.empty?
22
+ end
23
+
24
+ def any?
25
+ @examples.any?
26
+ end
27
+
28
+ def write_summary
29
+ return unless any?
30
+
31
+ io.puts('')
32
+ io.puts [
33
+ failed_examples_message,
34
+ pending_examples_message
35
+ ].reject(&:empty?).join("\n\n")
36
+ io.puts('')
37
+ io.puts summary_line
38
+ end
39
+
40
+ def summary_line
41
+ "#{examples.size} examples, #{failed_examples.size} failed, #{pending_examples.size} pending"
42
+ end
43
+
44
+ private
45
+
46
+ def failed_examples
47
+ @examples.select(&:failed?).select(&:exception)
48
+ end
49
+
50
+ def pending_examples
51
+ @examples.select(&:pending?)
52
+ end
53
+
54
+ def failed_examples_message
55
+ failed_examples.map { |e| failure_message(e) }.join("\n\n")
56
+ end
57
+
58
+ def failure_message(example)
59
+ " \xE2\x9C\x96 ".red + "#{example.metadata['path']}\n" + super
60
+ end
61
+
62
+ def pending_examples_message
63
+ pending_examples.map { |e| pending_message(e) }.join("\n\n")
64
+ end
65
+
66
+ def pending_message(example)
67
+ " \xE2\x97\x8B ".yellow + "#{example.metadata['path']}\n" + super
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,93 @@
1
+ module Guard
2
+ module KonachaRails
3
+ class Runner
4
+ DEFAULT_OPTIONS = {
5
+ run_all_on_start: true,
6
+ notification: true,
7
+ rails_environment_file: './config/environment'
8
+ }.freeze
9
+
10
+ attr_reader :options, :formatter
11
+
12
+ def initialize(options = {})
13
+ @options = DEFAULT_OPTIONS.merge(options)
14
+
15
+ # Require project's rails environment file to load Konacha configuration.
16
+ require_rails_environment
17
+ raise 'Konacha not loaded' unless defined? ::Konacha
18
+
19
+ # Custom formatter to handle multiple runs.
20
+ @formatter = Formatter.new
21
+ ::Konacha.config.formatters = [@formatter]
22
+
23
+ # Reusable session to increase performance.
24
+ @session = Capybara::Session.new(::Konacha.driver, Server.new)
25
+
26
+ ::Konacha.mode = :runner
27
+
28
+ UI.info 'Guard::Konacha Initialized'
29
+ end
30
+
31
+ def start
32
+ run if options[:run_all_on_start]
33
+ end
34
+
35
+ def run(paths = [''])
36
+ formatter.reset
37
+
38
+ paths.each do |path|
39
+ if path.empty? or File.exists? real_path path
40
+ runner.run konacha_path(path)
41
+ end
42
+ end
43
+
44
+ formatter.write_summary
45
+ notify
46
+ rescue => e
47
+ UI.error(e)
48
+ end
49
+
50
+ private
51
+
52
+ def require_rails_environment
53
+ if @options[:rails_environment_file]
54
+ require @options[:rails_environment_file]
55
+ else
56
+ dir = '.'
57
+ while File.expand_path(dir) != '/' do
58
+ env_file = File.join(dir, 'config/environment.rb')
59
+ if File.exist?(env_file)
60
+ require File.expand_path(env_file)
61
+
62
+ break
63
+ end
64
+ dir = File.join(dir, '..')
65
+ end
66
+ end
67
+ end
68
+
69
+ def runner
70
+ ::Konacha::Runner.new(@session)
71
+ end
72
+
73
+ def konacha_path(path)
74
+ '/' + path.gsub(/^#{::Konacha.config[:spec_dir]}\/?/, '').gsub(/\.coffee$/, '').gsub(/\.js$/, '')
75
+ end
76
+
77
+ def real_path(path)
78
+ ::Rails.root.join(::Konacha.config[:spec_dir] + konacha_path(path) + (path[/\.js(\.coffee)?$/] || '')).to_s
79
+ end
80
+
81
+ def unique_id
82
+ "#{Time.now.to_i}#{rand(100)}"
83
+ end
84
+
85
+ def notify
86
+ if options[:notification]
87
+ image = @formatter.success? ? :success : :failed
88
+ ::Guard::Notifier.notify(@formatter.summary_line, title: 'Konacha Specs', image: image)
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,31 @@
1
+ require 'rack/builder'
2
+
3
+ module Guard
4
+ module KonachaRails
5
+ class Server < ::Rack::Builder
6
+ def self.new
7
+ super do
8
+ use CacheBuster
9
+
10
+ run ::Konacha.application
11
+ end
12
+ end
13
+
14
+ class CacheBuster
15
+ def initialize(app)
16
+ @app = app
17
+ end
18
+
19
+ def call(env)
20
+ status, headers, body = @app.call(env)
21
+
22
+ headers.delete('Last-Modified')
23
+ headers.delete('ETag')
24
+ headers.delete('Cache-Control')
25
+
26
+ [status, headers, body]
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,10 @@
1
+ ### Guard::Konacha
2
+ # available options:
3
+ # - :run_all_on_start, defaults to true
4
+ # - :notification, defaults to true
5
+ # - :rails_environment_file, location of rails environment file,
6
+ # should be able to find it automatically
7
+ guard :konacha do
8
+ watch(%r{^app/assets/javascripts/(.*)\.js(\.coffee)?$}) { |m| "#{m[1]}_spec.js" }
9
+ watch(%r{^spec/javascripts/.+_spec(\.js|\.js\.coffee)$})
10
+ end
@@ -0,0 +1,5 @@
1
+ module Guard
2
+ module KonachaRails
3
+ VERSION = '1.1.0'.freeze
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Dummy::Application
@@ -0,0 +1,11 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ Bundler.require(:default, ::Rails.env)
6
+
7
+ module Dummy
8
+ class Application < ::Rails::Application
9
+ config.assets.enabled = true
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ require 'rubygems'
2
+
3
+ # Set up gems listed in the Gemfile.
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
5
+
6
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Dummy::Application.initialize!
@@ -0,0 +1,27 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Do not eager load in development.
10
+ config.eager_load = false
11
+
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Print deprecation notices to the Rails logger
17
+ config.active_support.deprecation = :log
18
+
19
+ # Only use best-standards-support built into browsers
20
+ config.action_dispatch.best_standards_support = :builtin
21
+
22
+ # Do not compress assets
23
+ config.assets.compress = false
24
+
25
+ # Expands the lines which load the assets
26
+ config.assets.debug = true
27
+ end
@@ -0,0 +1,5 @@
1
+ require 'capybara/poltergeist'
2
+
3
+ Konacha.configure do |config|
4
+ config.driver = :poltergeist
5
+ end if defined?(Konacha)
@@ -0,0 +1,12 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure your secret_key_base is kept private
11
+ # if you're sharing your code publicly.
12
+ Dummy::Application.config.secret_key_base = '5a0339f1e762dc48bf321540ed76855703a60dd523c42ec8c8af9044326707aa8f76f46efab628b91469de554e259e577bfb8ebb35828ca62bb55bcdcd6e1a41'
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe Guard::KonachaRails::Plugin do
4
+ rails_env_file = File.expand_path('../../../dummy/config/environment', __FILE__)
5
+ subject { Guard::KonachaRails::Plugin.new(rails_environment_file: rails_env_file) }
6
+
7
+ before do
8
+ # Silence UI.info output.
9
+ allow(::Guard::UI).to receive(:info).and_return(true)
10
+ end
11
+
12
+ describe '#initialize' do
13
+ it 'instantiates Runner with given options' do
14
+ expect(Guard::KonachaRails::Runner).to receive(:new).with(rails_environment_file: nil,
15
+ spec_dir: 'spec/assets')
16
+
17
+ Guard::KonachaRails::Plugin.new(rails_environment_file: nil, spec_dir: 'spec/assets')
18
+ end
19
+ end
20
+
21
+ describe '#start' do
22
+ it 'starts the runner' do
23
+ expect(subject.runner).to receive(:start)
24
+
25
+ subject.start
26
+ end
27
+ end
28
+
29
+ describe '#run_all' do
30
+ it 'calls #run' do
31
+ expect(subject.runner).to receive(:run).with(no_args)
32
+
33
+ subject.run_all
34
+ end
35
+ end
36
+
37
+ describe '#run_on_changes' do
38
+ it 'calls #run with file name' do
39
+ expect(subject.runner).to receive(:run).with(['file_name.js'])
40
+
41
+ subject.run_on_changes(['file_name.js'])
42
+ end
43
+
44
+ it 'calls #run with paths' do
45
+ expect(subject.runner).to receive(:run).with(['spec/controllers', 'spec/requests'])
46
+
47
+ subject.run_on_changes(['spec/controllers', 'spec/requests'])
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,76 @@
1
+ require 'spec_helper'
2
+
3
+ describe Guard::KonachaRails::Formatter do
4
+ let(:formatter) { Guard::KonachaRails::Formatter.new }
5
+
6
+ it 'should respond not implemented base class methods' do
7
+ expect(formatter).to respond_to(:dump_summary).with(4).arguments
8
+ expect(formatter).to respond_to(:dump_failures)
9
+ expect(formatter).to respond_to(:dump_pending)
10
+ end
11
+
12
+ describe('#reset') do
13
+ it 'should respond to reset' do
14
+ expect(formatter).to respond_to(:reset)
15
+ end
16
+ end
17
+
18
+ describe('#write_summary') do
19
+ MockException = Struct.new(:message, :backtrace)
20
+ Example = Struct.new(:full_description, :exception, :metadata, :failed?, :pending?)
21
+
22
+ def create_example(options)
23
+ example = Example.new(options[:message], options[:exception], {}, options[:failed?],
24
+ options[:pending?])
25
+
26
+ def example.failed?; self[:failed?]; end
27
+ def example.pending?; self[:pending?]; end
28
+
29
+ example
30
+ end
31
+
32
+ let(:failure) do
33
+ create_example({
34
+ message: 'Bad',
35
+ exception: MockException.new('Exception', nil),
36
+ failed?: true,
37
+ pending?: false
38
+ })
39
+ end
40
+
41
+ let(:success) do
42
+ create_example({
43
+ message: 'Good',
44
+ failed?: false,
45
+ pending?: false
46
+ })
47
+ end
48
+ let(:pending) do
49
+ create_example({
50
+ message: 'OK',
51
+ failed?: false,
52
+ pending?: true
53
+ })
54
+ end
55
+
56
+ let(:io) { double('IO', :tty? => true) }
57
+
58
+ before do
59
+ allow(formatter).to receive(:io) { io }
60
+ end
61
+
62
+ it 'should examples to output' do
63
+ expect(io).to receive(:write).with('F'.red).ordered
64
+ expect(io).to receive(:write).with('.'.green).ordered
65
+ expect(io).to receive(:write).with('P'.yellow).ordered
66
+
67
+ expect(io).to receive(:puts).with(any_args).at_least(:once)
68
+
69
+ formatter.example_failed(failure)
70
+ formatter.example_passed(success)
71
+ formatter.example_pending(pending)
72
+
73
+ formatter.write_summary
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,81 @@
1
+ require 'spec_helper'
2
+
3
+ describe Guard::KonachaRails::Runner do
4
+ let(:rails_env_file) { File.expand_path('../../../../dummy/config/environment', __FILE__) }
5
+ let(:runner_options) { { rails_environment_file: rails_env_file } }
6
+ let(:runner) { Guard::KonachaRails::Runner.new(runner_options) }
7
+
8
+ before do
9
+ # Silence Ui.info output.
10
+ allow(::Guard::UI).to receive(:info).and_return(true)
11
+ end
12
+
13
+ describe '#initialize' do
14
+ it 'should have default options and allow overrides' do
15
+ expect(runner.options).to eq(Guard::KonachaRails::Runner::DEFAULT_OPTIONS.merge(runner_options))
16
+ end
17
+
18
+ it 'should set Konacha mode to runner' do
19
+ expect(::Konacha.mode).to eq(:runner)
20
+ end
21
+ end
22
+
23
+ describe '#start' do
24
+ describe 'with run_all_on_start set to true' do
25
+ let(:runner_options) { super().merge(run_all_on_start: true) }
26
+ it 'should run all if :run_all_on_start option set to true' do
27
+ expect(runner).to receive(:run).with(no_args)
28
+
29
+ runner.start
30
+ end
31
+ end
32
+
33
+ describe 'with run_all_on_start set to false' do
34
+ let(:runner_options) { super().merge(run_all_on_start: false) }
35
+ it 'should run all if :run_all_on_start option set to true' do
36
+ expect(runner).not_to receive(:run)
37
+
38
+ runner.start
39
+ end
40
+ end
41
+ end
42
+
43
+ describe '#run' do
44
+ let(:konacha_runner) { double('konacha runner') }
45
+ let(:konacha_formatter) { double('konacha formatter') }
46
+
47
+ before do
48
+ allow(runner).to receive(:runner) { konacha_runner }
49
+ allow(konacha_formatter).to receive(:any?) { true }
50
+ end
51
+
52
+ it 'should run each path through runner and format results' do
53
+ allow(File).to receive(:exists?) { true }
54
+ allow(runner).to receive(:formatter) { konacha_formatter }
55
+ expect(konacha_formatter).to receive(:reset)
56
+ expect(konacha_runner).to receive(:run).with('/1')
57
+ expect(konacha_runner).to receive(:run).with('/foo/bar')
58
+ expect(konacha_formatter).to receive(:write_summary)
59
+
60
+ runner.run(['spec/javascripts/1.js', 'spec/javascripts/foo/bar.js'])
61
+ end
62
+
63
+ it 'should run each path with a valid extension' do
64
+ expect(File).to receive(:exists?).with(::Rails.root.join('spec/javascripts/1.js').to_s).and_return(true)
65
+ expect(File).to receive(:exists?).with(::Rails.root.join('spec/javascripts/foo/bar.js.coffee').to_s).and_return(true)
66
+ expect(konacha_runner).to receive(:run).with('/1')
67
+ expect(konacha_runner).to receive(:run).with('/foo/bar')
68
+
69
+ runner.run(['spec/javascripts/1.js', 'spec/javascripts/foo/bar.js.coffee'])
70
+ end
71
+
72
+ it 'should run when called with no arguemnts' do
73
+ allow(runner).to receive(:formatter) { konacha_formatter }
74
+ expect(konacha_formatter).to receive(:write_summary)
75
+ expect(konacha_formatter).to receive(:reset)
76
+ expect(konacha_runner).to receive(:run)
77
+
78
+ runner.run
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe Guard::KonachaRails::Server do
4
+ describe '#new' do
5
+ it 'should use CacheBuster' do
6
+ expect_any_instance_of(Guard::KonachaRails::Server).to receive(:use).with(Guard::KonachaRails::Server::CacheBuster)
7
+ expect_any_instance_of(Guard::KonachaRails::Server).to receive(:run).with(::Konacha.application)
8
+
9
+ Guard::KonachaRails::Server.new
10
+ end
11
+ end
12
+
13
+ describe Guard::KonachaRails::Server::CacheBuster do
14
+ include Rack::Test::Methods
15
+
16
+ let(:app) do
17
+ Guard::KonachaRails::Server::CacheBuster.new(lambda { |env|
18
+ [
19
+ 200,
20
+ {
21
+ 'Content-Type' => 'text/plain',
22
+ 'Last-Modified' => 'Wed, 09 Apr 2008 23:55:38 GMT',
23
+ 'ETag' => '123456789',
24
+ 'Cache-Control' => 'max-age=290304000, public'
25
+ },
26
+ ['Hello']
27
+ ]
28
+ })
29
+ end
30
+
31
+ it 'should remove caching headers' do
32
+ get '/'
33
+
34
+ expect(last_response.headers['Last-Modified']).to be_nil
35
+ expect(last_response.headers['ETag']).to be_nil
36
+ expect(last_response.headers['Cache-Control']).to be_nil
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,18 @@
1
+ ENV['RAILS_ENV'] ||= 'test'
2
+
3
+ require 'rspec'
4
+ require 'coveralls'
5
+ require 'timecop'
6
+ require 'guard/konacha/konacha'
7
+ require 'guard/compat/test/helper'
8
+
9
+ Coveralls.wear!
10
+
11
+ module Guard
12
+ module UI
13
+ extend self
14
+
15
+ def error(*args)
16
+ end
17
+ end
18
+ end
metadata ADDED
@@ -0,0 +1,195 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-konacha-version
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Leonid Beder
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: guard
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '4.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '4.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: konacha
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-compat
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: coveralls
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: timecop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: poltergeist
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Guard plugin for the konacha testing framework.
126
+ email:
127
+ - leonid.beder@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - ".rspec"
134
+ - ".travis.yml"
135
+ - Gemfile
136
+ - Gemfile.lock
137
+ - LICENSE
138
+ - Rakefile
139
+ - Readme.md
140
+ - guard-konacha-rails.gemspec
141
+ - lib/guard/konacha/konacha.rb
142
+ - lib/guard/konacha/rails/formatter.rb
143
+ - lib/guard/konacha/rails/runner.rb
144
+ - lib/guard/konacha/rails/server.rb
145
+ - lib/guard/konacha/rails/templates/Guardfile
146
+ - lib/guard/konacha/rails/version.rb
147
+ - spec/dummy/config.ru
148
+ - spec/dummy/config/application.rb
149
+ - spec/dummy/config/boot.rb
150
+ - spec/dummy/config/environment.rb
151
+ - spec/dummy/config/environments/development.rb
152
+ - spec/dummy/config/initializers/konacha.rb
153
+ - spec/dummy/config/initializers/secret_token.rb
154
+ - spec/guard/konacha/konacha_spec.rb
155
+ - spec/guard/konacha/rails/formatter_spec.rb
156
+ - spec/guard/konacha/rails/runner_spec.rb
157
+ - spec/guard/konacha/rails/server_spec.rb
158
+ - spec/spec_helper.rb
159
+ homepage: https://github.com/lbeder/guard-konacha-rails
160
+ licenses:
161
+ - MIT
162
+ metadata: {}
163
+ post_install_message:
164
+ rdoc_options: []
165
+ require_paths:
166
+ - lib
167
+ required_ruby_version: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ required_rubygems_version: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: '0'
177
+ requirements: []
178
+ rubyforge_project:
179
+ rubygems_version: 2.4.5
180
+ signing_key:
181
+ specification_version: 4
182
+ summary: Guard plugin for the konacha testing framework
183
+ test_files:
184
+ - spec/dummy/config.ru
185
+ - spec/dummy/config/application.rb
186
+ - spec/dummy/config/boot.rb
187
+ - spec/dummy/config/environment.rb
188
+ - spec/dummy/config/environments/development.rb
189
+ - spec/dummy/config/initializers/konacha.rb
190
+ - spec/dummy/config/initializers/secret_token.rb
191
+ - spec/guard/konacha/konacha_spec.rb
192
+ - spec/guard/konacha/rails/formatter_spec.rb
193
+ - spec/guard/konacha/rails/runner_spec.rb
194
+ - spec/guard/konacha/rails/server_spec.rb
195
+ - spec/spec_helper.rb