tdd 2.0.3 → 2.0.4
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.
- checksums.yaml +4 -4
- data/README.md +51 -22
- data/bin/tdd +101 -8
- data/lib/tdd/version.rb +1 -1
- data/tdd.gemspec +2 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 863069f0064d687d78e650b01f33d0419a297c7f
|
4
|
+
data.tar.gz: 63b348bc4c11460cf2d65506bfa4dbda3deec025
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ca2dd2d3c6d6bd07cfe6f4e9a58711b8836cc359d7c7cb699be21f0320233c6b57a7d01d3a0b227cb12b0c00a32d17224905627dbac08766ff9435cc6db0c39
|
7
|
+
data.tar.gz: 29db08f5c4ca3dffcf0b14b76ef208e111738b2c14fffd1f63db059fc12ae138a5e1d8c316d199d8f10ffbaa79a7b0d29b340b137f75dfe64a436dd284e87cdc
|
data/README.md
CHANGED
@@ -4,53 +4,69 @@ tdd
|
|
4
4
|
[](http://badge.fury.io/rb/tdd)
|
5
5
|
[](https://codeclimate.com/github/ubermajestix/tdd)
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
Is it awesome?
|
10
|
-
--------------
|
11
|
-
Yes.
|
12
|
-
|
7
|
+
####A simple command line tool for running tests when files change.
|
8
|
+
#####Yes, it is awesome. :red_circle: :green_heart: :repeat:
|
13
9
|
|
14
10
|
Examples
|
15
11
|
--------
|
16
12
|
|
17
|
-
|
13
|
+
###Test::Unit
|
18
14
|
|
19
15
|
$ tdd test/unit/some_unit_test.rb
|
20
16
|
|
21
|
-
|
17
|
+
###RSpec
|
22
18
|
|
23
19
|
$ tdd spec/some_spec.rb
|
24
20
|
# Run all specs
|
25
21
|
$ tdd spec
|
26
22
|
|
27
|
-
|
23
|
+
###Rake
|
28
24
|
|
29
25
|
$ tdd rake test:functional
|
30
26
|
$ tdd rake spec
|
31
27
|
|
32
|
-
|
28
|
+
###Pass framework specific arguments
|
29
|
+
You can pass arguments you would normally pass to `ruby -Itest` or `rspec`, note the double-dash "--".
|
33
30
|
|
34
31
|
$ tdd -- test/unit/some_unit_test.rb -n /some_test_name/
|
35
32
|
$ tdd -- spec/some_spec.rb:42 --fail-fast
|
36
33
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
34
|
+
###Globs by default
|
35
|
+
By default, tdd will search for similarly named files to your test to watch. tdd will look for `some_unit.rb`
|
36
|
+
in your project and watch it for changes, along with the test file.
|
37
|
+
|
38
|
+
$ tdd -- test/unit/some_unit.rb
|
39
|
+
Running: ruby -Itest test/unit/some_unit_test.rb
|
40
|
+
Watching:
|
41
|
+
/Users/ubermajestix/some_project/lib/some_unit.rb
|
42
|
+
/Users/ubermajestix/some_project/lib/modules/plugins/stuff/some_unit.rb
|
43
|
+
/Users/ubermajestix/some_project/test/unit/some_unit_test.rb
|
44
|
+
|
45
|
+
###All of the files
|
46
|
+
Run tdd in the "all" mode to watch all files in app, lib, config, test, and spec
|
47
|
+
directories, if they exist. The double-dash "--" seperates tdd's modes from the testing command.
|
48
|
+
|
49
|
+
$ tdd all -- test/unit/some_unit_test.rb
|
50
|
+
Running: ruby -Itest test/unit/some_unit_test.rb
|
51
|
+
Watching 3417 files in app/ lib/ config/ test/ spec/
|
52
|
+
|
53
|
+
###Some of the files
|
54
|
+
You can specify which files to watch, again, note the double-dash "--"
|
42
55
|
separating the files to watch from the test file and options):
|
43
56
|
|
44
|
-
$ tdd lib/some_unit.rb config/setup.rb -- test/unit/
|
57
|
+
$ tdd lib/some_unit.rb config/setup.rb -- test/unit/some_unit_test.rb -n/some_test_name/
|
58
|
+
###Wildcard the files
|
59
|
+
You can use wildcards in any of the watched filepaths:
|
45
60
|
|
46
|
-
|
47
|
-
with glob mode:
|
61
|
+
$ tdd lib/other_class.rb app/models/*class.rb -- test/unit/some_class_test.rb -n/some_test_name/
|
48
62
|
|
49
|
-
|
63
|
+
###Respects gitignore
|
64
|
+
By default tdd ignores any files ignored by git, either through the local .gitignore
|
65
|
+
file or the global ~/.gitignore_global . You can turn this off by passing --gitignore=false:
|
50
66
|
|
51
|
-
|
52
|
-
along with the test file.
|
67
|
+
$ tdd --gitignore=false some_file.rb -- test/unit/some_unit.rb -n/some_test_name/
|
53
68
|
|
69
|
+
###Weird Rails specific mode
|
54
70
|
In a Rails project you can ask tdd to watch view and controller files
|
55
71
|
related to a functional or controller test:
|
56
72
|
|
@@ -59,6 +75,13 @@ related to a functional or controller test:
|
|
59
75
|
will watch all view files in app/views/users, the users_controller and the
|
60
76
|
test file for changes.
|
61
77
|
|
78
|
+
###Now with more Growl
|
79
|
+
Supports Growl notifs. To enable, pass in --growl like so:
|
80
|
+
|
81
|
+
$ tdd controller --growl -- spec/controllers/users_controller_spec.rb
|
82
|
+
|
83
|
+
In Growl's preferences you can enable/disable both 'passed' and 'failed' notifs.
|
84
|
+
|
62
85
|
Isn't this what Guard does?
|
63
86
|
---------------------------
|
64
87
|
Yeah, but its more flexible. I found myself wanting to use rspec's
|
@@ -67,9 +90,15 @@ I tdd'd a class. With Guard, I would have to change the Guardfile to
|
|
67
90
|
use different command line options for rspec. Maybe there's a way to
|
68
91
|
solve this now, but in general Guard is just too much overhead for me.
|
69
92
|
|
70
|
-
This library heavily borrows from rego by Ara Howard. Its a really
|
93
|
+
This library heavily borrows from [rego by Ara Howard](http://github.com/ahoward/rego). Its a really
|
71
94
|
useful tool and I used it to watch project files and run tests when they
|
72
95
|
changed. But bouncing between projects that use test/unit and
|
73
96
|
rspec several times a day there was still overhead in typing out the
|
74
97
|
list of files to watch and the full test command for rego to work.
|
98
|
+
Thus, tdd was born.
|
99
|
+
|
100
|
+
Contributors
|
101
|
+
----
|
102
|
+
* [ubermajestix](http://ubermajestix.com)
|
103
|
+
* [Dave Sims](https://github.com/davesims)
|
75
104
|
|
data/bin/tdd
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'tdd'
|
4
|
+
require 'ruby_gntp'
|
4
5
|
|
5
6
|
# The majority of this file has been adapted from Ara Howard's rego gem.
|
6
7
|
# You can find the source here: http://github.com/ahoward/rego.
|
@@ -49,6 +50,11 @@ command if any file being watched changes.
|
|
49
50
|
/Users/ubermajestix/work/awesome_app/test/unit/some_class_test.rb
|
50
51
|
##########################################
|
51
52
|
|
53
|
+
tdd also ignores, by default, any files ignored by git, either through the local .gitignore
|
54
|
+
file or the global ~/.gitignore_global. You can turn this off by passing --gitignore=false:
|
55
|
+
|
56
|
+
$ tdd --gitignore=false some_file.rb -- test/unit/some_unit.rb -n/some_test_name/
|
57
|
+
|
52
58
|
You can specify additional files to watch (note the double dashes `--`
|
53
59
|
separating the files to watch from the test file and options):
|
54
60
|
|
@@ -61,6 +67,16 @@ separating the files to watch from the test file and options):
|
|
61
67
|
/Users/ubermajestix/work/awesome_app/test/unit/some_class_test.rb
|
62
68
|
##########################################
|
63
69
|
|
70
|
+
You can use wildcards in any of the watched filepaths:
|
71
|
+
|
72
|
+
$ tdd lib/other_class.rb app/models/*class.rb -- test/unit/some_class_test.rb -n/some_test_name/
|
73
|
+
Running: ruby -I test test/unit/some_class_test.rb -n/some_test_name/
|
74
|
+
Watching:
|
75
|
+
/Users/ubermajestix/work/awesome_app/app/models/some_class.rb
|
76
|
+
/Users/ubermajestix/work/awesome_app/app/models/some_other_class.rb
|
77
|
+
/Users/ubermajestix/work/awesome_app/app/models/some_nifty_class.rb
|
78
|
+
/Users/ubermajestix/work/awesome_app/app/models/some_hoopy_class.rb
|
79
|
+
##########################################
|
64
80
|
|
65
81
|
In a Rails project you can ask tdd to watch view and controller files
|
66
82
|
related to a functional or controller test:
|
@@ -76,37 +92,99 @@ related to a functional or controller test:
|
|
76
92
|
/Users/ubermajestix/work/awesome_rails_app/spec/controllers/users_controller_spec.rb
|
77
93
|
##########################################
|
78
94
|
|
95
|
+
Supports Growl notifs. To enable, pass in --growl like so:
|
79
96
|
|
97
|
+
$ tdd controller --growl -- spec/controllers/users_controller_spec.rb
|
98
|
+
|
99
|
+
In Growl's preferences you can enable/disable both 'passed' and 'failed' notifs.
|
80
100
|
__
|
81
101
|
|
102
|
+
option('growl'){
|
103
|
+
default false
|
104
|
+
cast :boolean
|
105
|
+
description "Send growl notifications for finished tests."
|
106
|
+
}
|
107
|
+
|
108
|
+
option('gitignore'){
|
109
|
+
argument :required
|
110
|
+
default true
|
111
|
+
cast :boolean
|
112
|
+
description "Don't watch files/dirs if they are ignored by git. Defaults to true."
|
113
|
+
}
|
114
|
+
|
82
115
|
def run
|
83
116
|
print_usage_and_exit if ARGV.empty?
|
117
|
+
parse_options
|
84
118
|
parse_the_command_line
|
85
119
|
print_a_summary_of_watched_files
|
120
|
+
register_growl if @use_growl
|
86
121
|
loop_watching_files_and_running_commands
|
87
122
|
end
|
88
123
|
|
124
|
+
def register_growl
|
125
|
+
@growl = GNTP.new("tdd")
|
126
|
+
@growl.register({
|
127
|
+
:notifications => [
|
128
|
+
{ :name => "passed", :enabled => true, },
|
129
|
+
{ :name => "failed", :enabled => true, }
|
130
|
+
]
|
131
|
+
})
|
132
|
+
end
|
133
|
+
|
89
134
|
def print_usage_and_exit
|
90
135
|
puts usage['examples']
|
91
136
|
exit 1
|
92
137
|
end
|
93
138
|
|
139
|
+
def parse_options
|
140
|
+
@gitignore = params['gitignore'].value
|
141
|
+
@use_growl = params['growl'].value
|
142
|
+
ARGV.delete_if{|arg| arg =~ /--gitignore.*|--growl.*/}
|
143
|
+
end
|
144
|
+
|
94
145
|
def parse_the_command_line
|
95
146
|
@paths, @command = Tdd::CommandLineParser.parse
|
96
147
|
@paths = %w[.] if @paths.empty?
|
148
|
+
expand_all_file_paths_in_array(@paths)
|
149
|
+
|
150
|
+
if @gitignore
|
151
|
+
say("ignoring gitignore files...", :color => :yellow)
|
152
|
+
@paths = @paths - git_ignored
|
153
|
+
end
|
154
|
+
end
|
97
155
|
|
98
|
-
|
99
|
-
@
|
100
|
-
|
101
|
-
|
102
|
-
|
156
|
+
def git_ignored
|
157
|
+
@all_git_ignored ||= %w(~/.gitignore_global .gitignore).reduce([]) do |all_ignored, file|
|
158
|
+
if File.exists?(file = File.expand_path(file))
|
159
|
+
all_ignored += Pathname.new(file).read.split("\n").reject{|i| i =~ /^#.*|(^\s*$)/}
|
160
|
+
end
|
161
|
+
all_ignored
|
162
|
+
end
|
163
|
+
expand_all_file_paths_in_array(@all_git_ignored)
|
164
|
+
end
|
165
|
+
|
166
|
+
def expand_all_file_paths_in_array(paths)
|
167
|
+
paths.map! do |path|
|
168
|
+
if test(?d, path)
|
169
|
+
[path, Dir.glob(File.join(path, '**/**'))]
|
170
|
+
elsif path =~ /\*/
|
171
|
+
Dir.glob(path)
|
172
|
+
else
|
173
|
+
path
|
174
|
+
end
|
175
|
+
end
|
176
|
+
paths.flatten!
|
177
|
+
paths.compact!
|
178
|
+
paths.uniq!
|
179
|
+
paths.map! do |path|
|
103
180
|
begin
|
104
181
|
Pathname.new(path).realpath.to_s
|
105
182
|
rescue Object
|
106
183
|
nil
|
107
184
|
end
|
108
185
|
end
|
109
|
-
|
186
|
+
paths.compact!
|
187
|
+
paths
|
110
188
|
end
|
111
189
|
|
112
190
|
def print_a_summary_of_watched_files
|
@@ -121,6 +199,17 @@ related to a functional or controller test:
|
|
121
199
|
end
|
122
200
|
end
|
123
201
|
|
202
|
+
def growl(name, title, text, sticky = false)
|
203
|
+
if @growl
|
204
|
+
@growl.notify({
|
205
|
+
:name => name,
|
206
|
+
:title => title,
|
207
|
+
:text => text,
|
208
|
+
:sticky => sticky,
|
209
|
+
})
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
124
213
|
def loop_watching_files_and_running_commands
|
125
214
|
directories = []
|
126
215
|
files = []
|
@@ -154,13 +243,17 @@ related to a functional or controller test:
|
|
154
243
|
say("# starting test run #{ n } @ #{ Time.now.strftime('%H:%M:%S') } - #{ @command }", :color => :magenta)
|
155
244
|
say("# #{files.size > 1 ? 'files' : 'file'} changed: #{files.join(', ')}", :color => :magenta) if files && files.any?
|
156
245
|
puts
|
157
|
-
|
158
|
-
|
246
|
+
tests_out = `#{@command}`
|
247
|
+
tests_pass = $?.success?
|
248
|
+
puts tests_out
|
249
|
+
|
159
250
|
say("# finished test run #{ n } @ #{ Time.now.strftime('%H:%M:%S') } - #{ $?.exitstatus }", :color => :yellow)
|
160
251
|
if tests_pass
|
161
252
|
system("command -v blink1-tool > /dev/null && blink1-tool -d0 --rgb 0,255,0 --blink 3 > /dev/null &")
|
253
|
+
growl("passed", "tdd - Tests Passed", tests_out)
|
162
254
|
else
|
163
255
|
system("command -v blink1-tool > /dev/null && blink1-tool -d0 --rgb 255,0,0 --blink 3 > /dev/null &")
|
256
|
+
growl("failed", "tdd - Tests Failed", tests_out, true)
|
164
257
|
end
|
165
258
|
puts
|
166
259
|
n.succ!
|
data/lib/tdd/version.rb
CHANGED
data/tdd.gemspec
CHANGED
@@ -14,7 +14,9 @@ Gem::Specification.new do |gem|
|
|
14
14
|
gem.name = "tdd"
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = Tdd::VERSION
|
17
|
+
|
17
18
|
|
18
19
|
gem.add_runtime_dependency "main", "~> 5.0"
|
19
20
|
gem.add_runtime_dependency "rb-fsevent", "~> 0.9"
|
21
|
+
gem.add_runtime_dependency "ruby_gntp"
|
20
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tdd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Montgomery
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: main
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.9'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: ruby_gntp
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: Fire up that tdd loop
|
42
56
|
email:
|
43
57
|
- tyler.a.montgomery@gmail.com
|