guard-focus 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 +4 -0
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/Gemfile +3 -0
- data/README.md +61 -0
- data/Rakefile +1 -0
- data/guard-focus.gemspec +26 -0
- data/lib/guard/focus.rb +55 -0
- data/lib/guard/focus/libraries.rb +26 -0
- data/lib/guard/focus/templates/Guardfile +10 -0
- data/lib/guard/focus/version.rb +5 -0
- metadata +69 -0
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use --create 1.9.2@guard-focus
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Guard::Focus
|
2
|
+
|
3
|
+
Guard::Focus allows you to automatically run RSpec and Cucumber features in a
|
4
|
+
style one might call "Focus Driven Development".
|
5
|
+
|
6
|
+
It replaces guard-rspec & guard-cucumber with a stripped down version that will
|
7
|
+
run with `--tag @focus` if any examples or scenarios are tagged with `focus`.
|
8
|
+
|
9
|
+
It is currently very early stage with no tests. It has been verfied to work on
|
10
|
+
only one machine & project. As I put it through it's paces on other projects at
|
11
|
+
Hashrocket I hope to improve this situation. If you take it for a spin I'd love
|
12
|
+
to hear any problems/feedback.
|
13
|
+
|
14
|
+
|
15
|
+
## Features
|
16
|
+
|
17
|
+
Guard::Focus is very minimal. It only has 3 features:
|
18
|
+
|
19
|
+
* If a file change results in running a spec/feature without a `focus` tag, it
|
20
|
+
will run with `rspec spec/path_to_file_spec.rb`
|
21
|
+
* If a file change results in running a spec/feature that contains a `focus`
|
22
|
+
tag it will run with `--tag @focus appended.`
|
23
|
+
* When running all guards via `enter` it will run with the focus tag if any of
|
24
|
+
the specs/features contains a focus tag. If not, the suite will be run
|
25
|
+
normally.
|
26
|
+
|
27
|
+
## Install
|
28
|
+
|
29
|
+
Install gem directly:
|
30
|
+
|
31
|
+
$ gem install guard-focus
|
32
|
+
|
33
|
+
Or add it to your Gemfile:
|
34
|
+
|
35
|
+
group :test, :development do
|
36
|
+
gem 'guard-focus'
|
37
|
+
end
|
38
|
+
|
39
|
+
## Guardfile
|
40
|
+
|
41
|
+
Guard::Focus comes with a Guardfile template you can install with:
|
42
|
+
|
43
|
+
$ guard init focus
|
44
|
+
|
45
|
+
It gives you focused guards for both rspec & cucumber.
|
46
|
+
|
47
|
+
guard 'focus', on: :rspec do
|
48
|
+
watch(%r{^spec/.+_spec\.rb})
|
49
|
+
watch(%r{^app/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
|
50
|
+
watch(%r{^lib/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
|
51
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb}) { |m| "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb" }
|
52
|
+
end
|
53
|
+
|
54
|
+
guard 'focus', on: :cucumber do
|
55
|
+
watch(%r{^features/.+\.feature$})
|
56
|
+
end
|
57
|
+
|
58
|
+
## Credits & Thanks
|
59
|
+
|
60
|
+
* [Veezus Kriest](http://twitter.com/veezus): When I first said "I'd autotest if..." he made it so in his 'testify' watchr config.
|
61
|
+
* [Dave Lyon](htt://twitter.com/daveisonthego): For his 'vanguard' implementation using guard-rspec & guard-cucumber.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/guard-focus.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "guard/focus/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "guard-focus"
|
7
|
+
s.version = Guard::FocusVersion::VERSION
|
8
|
+
s.authors = ["Lar Van Der Jagt"]
|
9
|
+
s.email = ["lar@hashrocket.com"]
|
10
|
+
s.homepage = "http://github.com/supaspoida/guard-focus"
|
11
|
+
s.summary = %q{Autorun your specs & features with focus tags}
|
12
|
+
s.description = %q{Replaces guard-rspec & guard-cucumber with a stripped down
|
13
|
+
version that will run with --tag @focus if any examples or
|
14
|
+
scenarios are tagged with 'focus'.}
|
15
|
+
|
16
|
+
s.rubyforge_project = "guard-focus"
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
|
23
|
+
# specify any dependencies here; for example:
|
24
|
+
# s.add_development_dependency "rspec"
|
25
|
+
s.add_runtime_dependency "guard"
|
26
|
+
end
|
data/lib/guard/focus.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'guard'
|
2
|
+
require 'guard/guard'
|
3
|
+
require 'forwardable'
|
4
|
+
|
5
|
+
module Guard
|
6
|
+
class Focus < Guard
|
7
|
+
autoload :Libraries, 'guard/focus/libraries'
|
8
|
+
|
9
|
+
extend Forwardable
|
10
|
+
|
11
|
+
def_delegators :library, :base_path, :executable, :extension, :focus_regexp
|
12
|
+
|
13
|
+
attr_reader :paths, :focused, :library
|
14
|
+
|
15
|
+
def initialize(watchers=[], options={})
|
16
|
+
super
|
17
|
+
@library = Libraries[options[:on]]
|
18
|
+
end
|
19
|
+
|
20
|
+
def run_all
|
21
|
+
success?([base_path])
|
22
|
+
end
|
23
|
+
|
24
|
+
def run_on_change(files)
|
25
|
+
success?(files)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def command
|
31
|
+
['time', executable, paths.join(' '), options].compact * ' '
|
32
|
+
end
|
33
|
+
|
34
|
+
def has_focus?(file)
|
35
|
+
begin
|
36
|
+
File.read(file) =~ focus_regexp
|
37
|
+
rescue Errno::EISDIR => e
|
38
|
+
Dir.glob("#{file}/**/*#{extension}").any? &method(:has_focus?)
|
39
|
+
rescue Errno::ENOENT => e
|
40
|
+
UI.debug "\e[31mMissing directory: #{base_path}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def options
|
45
|
+
'--tag @focus' if focused
|
46
|
+
end
|
47
|
+
|
48
|
+
def success?(paths)
|
49
|
+
@paths = paths
|
50
|
+
@focused = paths.any? &method(:has_focus?)
|
51
|
+
UI.info "\nRunning: \e[33m#{command}\n"
|
52
|
+
system command
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
module Guard
|
4
|
+
class Focus
|
5
|
+
class Libraries < OpenStruct
|
6
|
+
def self.cucumber
|
7
|
+
new base_path: 'features',
|
8
|
+
focus_regexp: /^\s*@focus/,
|
9
|
+
executable: 'cucumber',
|
10
|
+
extension: '.feature'
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.rspec
|
14
|
+
new base_path: 'spec',
|
15
|
+
focus_regexp: /^\s*(describe|context|it).*?(:focus|focus:)/,
|
16
|
+
executable: 'rspec',
|
17
|
+
extension: '_spec.rb'
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.[](name)
|
21
|
+
{ cucumber: cucumber,
|
22
|
+
rspec: rspec }[name]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
guard 'focus', on: :rspec do
|
2
|
+
watch(%r{^spec/.+_spec\.rb})
|
3
|
+
watch(%r{^app/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
|
4
|
+
watch(%r{^lib/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
|
5
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb}) { |m| "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb" }
|
6
|
+
end
|
7
|
+
|
8
|
+
guard 'focus', on: :cucumber do
|
9
|
+
watch(%r{^features/.+\.feature$})
|
10
|
+
end
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: guard-focus
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Lar Van Der Jagt
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-10-17 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: guard
|
16
|
+
requirement: &2153281120 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2153281120
|
25
|
+
description: ! "Replaces guard-rspec & guard-cucumber with a stripped down\n version
|
26
|
+
that will run with --tag @focus if any examples or\n scenarios
|
27
|
+
are tagged with 'focus'."
|
28
|
+
email:
|
29
|
+
- lar@hashrocket.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- .gitignore
|
35
|
+
- .rspec
|
36
|
+
- .rvmrc
|
37
|
+
- Gemfile
|
38
|
+
- README.md
|
39
|
+
- Rakefile
|
40
|
+
- guard-focus.gemspec
|
41
|
+
- lib/guard/focus.rb
|
42
|
+
- lib/guard/focus/libraries.rb
|
43
|
+
- lib/guard/focus/templates/Guardfile
|
44
|
+
- lib/guard/focus/version.rb
|
45
|
+
homepage: http://github.com/supaspoida/guard-focus
|
46
|
+
licenses: []
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
requirements: []
|
64
|
+
rubyforge_project: guard-focus
|
65
|
+
rubygems_version: 1.8.10
|
66
|
+
signing_key:
|
67
|
+
specification_version: 3
|
68
|
+
summary: Autorun your specs & features with focus tags
|
69
|
+
test_files: []
|