tdd 0.1.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +53 -17
- data/bin/tdd +48 -47
- data/lib/tdd.rb +5 -2
- data/lib/tdd/version.rb +1 -1
- metadata +2 -3
- data/lib/rego.rb +0 -55
data/README.md
CHANGED
@@ -1,29 +1,65 @@
|
|
1
|
-
|
1
|
+
tdd
|
2
|
+
===
|
2
3
|
|
3
|
-
|
4
|
+
Watch files and run test/unit or rspec tests when those files change.
|
4
5
|
|
5
|
-
|
6
|
+
Is it awesome?
|
7
|
+
--------------
|
8
|
+
Yes.
|
6
9
|
|
7
|
-
Add this line to your application's Gemfile:
|
8
10
|
|
9
|
-
|
11
|
+
Examples
|
12
|
+
--------
|
10
13
|
|
11
|
-
|
14
|
+
Using with test/unit:
|
12
15
|
|
13
|
-
$
|
16
|
+
$ tdd test/unit/some_unit_test.rb
|
14
17
|
|
15
|
-
|
18
|
+
Using with rspec:
|
16
19
|
|
17
|
-
$
|
20
|
+
$ tdd spec/some_spec.rb
|
18
21
|
|
19
|
-
|
22
|
+
You can pass arguments you would normally pass to `ruby -Itest` or `rspec`
|
23
|
+
|
24
|
+
$ tdd test/unit/some_unit_test.rb -n /some_test_name/
|
25
|
+
$ tdd spec/some_spec.rb:42 --fail-fast
|
20
26
|
|
21
|
-
|
27
|
+
By default, tdd will watch files in app, lib, config, test, and spec
|
28
|
+
directories, if they exist, and run your test command if any file being
|
29
|
+
watched changes.
|
22
30
|
|
23
|
-
|
31
|
+
You can specify which files to watch (note the double dashes `--`
|
32
|
+
separating the files to watch from the test file and options):
|
33
|
+
|
34
|
+
$ tdd lib/some_unit.rb config/setup.rb -- test/unit/some_unit.rb -n/some_test_name/
|
35
|
+
|
36
|
+
You can tell it to find a similarly named file to your test to watch
|
37
|
+
with glob mode:
|
38
|
+
|
39
|
+
$ tdd glob -- test/unit/some_unit_test.rb
|
40
|
+
|
41
|
+
This will look for `some_unit.rb` in your project and watch it for changes,
|
42
|
+
along with the test file.
|
43
|
+
|
44
|
+
In a Rails project you can ask tdd to watch view and controller files
|
45
|
+
related to a functional or controller test:
|
46
|
+
|
47
|
+
$ tdd controller -- test/functional/users_controller_test.rb
|
48
|
+
|
49
|
+
will watch all view files in app/views/users, the users_controller and the
|
50
|
+
test file for changes.
|
51
|
+
|
52
|
+
Isn't this what Guard does?
|
53
|
+
---------------------------
|
54
|
+
Yeah, but its more flexible. I found myself wanting to use rspec's
|
55
|
+
feature of running a single test, or group of tests, over and over while
|
56
|
+
I tdd'd a class. With Guard, I would have to change the Guardfile to
|
57
|
+
use different command line options for rspec. Maybe there's a way to
|
58
|
+
solve this now, but in general Guard is just too much overhead for me.
|
59
|
+
|
60
|
+
This library heavily borrows from rego by Ara Howard. Its a really
|
61
|
+
useful tool and I used it to watch project files and run tests when they
|
62
|
+
changed. But bouncing between projects that use test/unit and
|
63
|
+
rspec several times a day there was still overhead in typing out the
|
64
|
+
list of files to watch and the full test command for rego to work.
|
24
65
|
|
25
|
-
1. Fork it
|
26
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
-
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
-
5. Create new Pull Request
|
data/bin/tdd
CHANGED
@@ -1,47 +1,61 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
|
3
|
+
require 'tdd'
|
4
|
+
|
5
|
+
# The majority of this file has been adapted from Ara Howard's rego gem.
|
6
|
+
# You can find the source here: http://github.com/ahoward/rego.
|
7
|
+
|
3
8
|
Main {
|
4
9
|
|
5
10
|
name <<-__
|
6
11
|
|
7
|
-
|
12
|
+
tdd
|
8
13
|
|
9
14
|
__
|
10
15
|
|
11
16
|
description <<-__
|
12
17
|
|
13
|
-
|
18
|
+
tdd watches files and runs test/unit or rspec tests when they change.
|
14
19
|
__
|
15
20
|
|
16
21
|
examples <<-__
|
22
|
+
Using with test/unit:
|
23
|
+
|
24
|
+
$ tdd test/unit/some_unit_test.rb
|
25
|
+
|
26
|
+
Using with rspec:
|
27
|
+
|
28
|
+
$ tdd spec/some_spec.rb
|
29
|
+
|
30
|
+
You can pass arguments you would normally pass to `ruby -Itest` or `rspec`
|
31
|
+
|
32
|
+
$ tdd test/unit/some_unit_test.rb -n /some_test_name/
|
33
|
+
$ tdd spec/some_spec.rb:42 --fail-fast
|
34
|
+
|
35
|
+
By default, tdd will watch files in app, lib, config, test, and spec
|
36
|
+
directories, if they exist, and run your test command if any file being
|
37
|
+
watched changes.
|
38
|
+
|
39
|
+
You can specify which files to watch (note the double dashes `--`
|
40
|
+
separating the files to watch from the test file and options):
|
41
|
+
|
42
|
+
$ tdd lib/some_unit.rb config/setup.rb -- test/unit/some_unit.rb -n/some_test_name/
|
17
43
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
$ tdd lib/some_unit.rb config/setup.rb -- test/unit/some_unit.rb -n/some_test_name/
|
34
|
-
|
35
|
-
# You can tell it to find a similarly named file to your test to watch:
|
36
|
-
$ tdd glob -- test/unit/some_unit_test.rb
|
37
|
-
# will look for some_unit.rb in your project and watch it for changes, along
|
38
|
-
# with the test file.
|
39
|
-
|
40
|
-
# In a Rails project you can ask tdd to watch view and controller files
|
41
|
-
# related to a functional or controller test:
|
42
|
-
$ tdd controller -- test/functional/users_controller_test.rb
|
43
|
-
# will watch all view files in app/views/users, the users_controller and the
|
44
|
-
# test file for changes.
|
44
|
+
You can tell it to find a similarly named file to your test to watch
|
45
|
+
with glob mode:
|
46
|
+
|
47
|
+
$ tdd glob -- test/unit/some_unit_test.rb
|
48
|
+
|
49
|
+
This will look for `some_unit.rb` in your project and watch it for changes,
|
50
|
+
along with the test file.
|
51
|
+
|
52
|
+
In a Rails project you can ask tdd to watch view and controller files
|
53
|
+
related to a functional or controller test:
|
54
|
+
|
55
|
+
$ tdd controller -- test/functional/users_controller_test.rb
|
56
|
+
|
57
|
+
will watch all view files in app/views/users, the users_controller and the
|
58
|
+
test file for changes.
|
45
59
|
__
|
46
60
|
|
47
61
|
def run
|
@@ -140,20 +154,20 @@ Main {
|
|
140
154
|
line = '#' * 42
|
141
155
|
$running = false
|
142
156
|
|
143
|
-
|
157
|
+
tdd = proc do |*args|
|
144
158
|
entry = args.shift
|
145
159
|
cmd = entry ? @command.gsub(/@/, entry) : @command
|
146
160
|
puts line
|
147
|
-
say("#
|
161
|
+
say("# starting test run #{ n } @ #{ Time.now.strftime('%H:%M:%S') } - #{ cmd }", :color => :magenta)
|
148
162
|
puts
|
149
163
|
system(cmd)
|
150
164
|
puts
|
151
|
-
say("#
|
165
|
+
say("# finished test run #{ n } @ #{ Time.now.strftime('%H:%M:%S') } - #{ $?.exitstatus }", :color => :yellow)
|
152
166
|
puts
|
153
167
|
n.succ!
|
154
168
|
end
|
155
169
|
|
156
|
-
|
170
|
+
tdd[ false ]
|
157
171
|
|
158
172
|
fsevent.watch(directories) do |*args|
|
159
173
|
unless $running
|
@@ -177,7 +191,7 @@ Main {
|
|
177
191
|
|
178
192
|
unless before.mtime == after.mtime
|
179
193
|
stats[entry] = after
|
180
|
-
|
194
|
+
tdd[ entry ]
|
181
195
|
end
|
182
196
|
end
|
183
197
|
end
|
@@ -245,18 +259,5 @@ BEGIN {
|
|
245
259
|
send(method, parts.join)
|
246
260
|
end
|
247
261
|
end
|
248
|
-
|
249
|
-
require 'pathname'
|
250
|
-
this = Pathname.new(__FILE__).realpath.to_s
|
251
|
-
bindir = File.dirname(this)
|
252
|
-
rootdir = File.dirname(bindir)
|
253
|
-
libdir = File.join(rootdir, 'lib')
|
254
|
-
rego = File.join(libdir, 'rego.rb')
|
255
|
-
|
256
|
-
require(rego)
|
257
|
-
|
258
|
-
STDOUT.sync = true
|
259
|
-
STDERR.sync = true
|
260
|
-
STDIN.sync = true
|
261
262
|
}
|
262
263
|
|
data/lib/tdd.rb
CHANGED
data/lib/tdd/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tdd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: main
|
@@ -57,7 +57,6 @@ files:
|
|
57
57
|
- README.md
|
58
58
|
- Rakefile
|
59
59
|
- bin/tdd
|
60
|
-
- lib/rego.rb
|
61
60
|
- lib/tdd.rb
|
62
61
|
- lib/tdd/version.rb
|
63
62
|
- tdd.gemspec
|
data/lib/rego.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'time'
|
2
|
-
require 'pathname'
|
3
|
-
require 'yaml'
|
4
|
-
|
5
|
-
module Rego
|
6
|
-
Version = '1.0.42' unless defined?(Version)
|
7
|
-
|
8
|
-
def version
|
9
|
-
Rego::Version
|
10
|
-
end
|
11
|
-
|
12
|
-
def dependencies
|
13
|
-
{
|
14
|
-
'main' => [ 'main' , ' >= 4.8.1' ] ,
|
15
|
-
'rb-fsevent' => [ 'rb-fsevent' , ' >= 0.4.3.1' ]
|
16
|
-
}
|
17
|
-
end
|
18
|
-
|
19
|
-
def libdir(*args, &block)
|
20
|
-
@libdir ||= File.expand_path(__FILE__).sub(/\.rb$/,'')
|
21
|
-
args.empty? ? @libdir : File.join(@libdir, *args)
|
22
|
-
ensure
|
23
|
-
if block
|
24
|
-
begin
|
25
|
-
$LOAD_PATH.unshift(@libdir)
|
26
|
-
block.call()
|
27
|
-
ensure
|
28
|
-
$LOAD_PATH.shift()
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def load(*libs)
|
34
|
-
libs = libs.join(' ').scan(/[^\s+]+/)
|
35
|
-
Rego.libdir{ libs.each{|lib| Kernel.load(lib) } }
|
36
|
-
end
|
37
|
-
|
38
|
-
extend(Rego)
|
39
|
-
end
|
40
|
-
|
41
|
-
# gems
|
42
|
-
#
|
43
|
-
begin
|
44
|
-
require 'rubygems'
|
45
|
-
rescue LoadError
|
46
|
-
nil
|
47
|
-
end
|
48
|
-
|
49
|
-
if defined?(gem)
|
50
|
-
Rego.dependencies.each do |lib, dependency|
|
51
|
-
gem(*dependency)
|
52
|
-
require(lib)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|