clash 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +88 -1
- data/bin/clash +117 -0
- data/clash.gemspec +5 -0
- data/lib/clash.rb +10 -2
- data/lib/clash/diff.rb +110 -0
- data/lib/clash/helpers.rb +34 -0
- data/lib/clash/test.rb +129 -0
- data/lib/clash/tests.rb +58 -0
- data/lib/clash/version.rb +1 -1
- data/test/.clash.yml +14 -0
- data/test/Gemfile +4 -0
- data/test/_plugins/feed/config.yml +1 -0
- data/test/_test.yml +1 -0
- data/test/a.txt +5 -0
- data/test/a/1.txt +17 -0
- data/test/a/2.txt +2 -0
- data/test/b.txt +5 -0
- data/test/b/1.txt +17 -0
- data/test/b/2.txt +2 -0
- data/test/c.txt +4 -0
- data/test/c/1.txt +17 -0
- data/test/c/2.txt +3 -0
- metadata +92 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a969d31ec8e0bcf1c77d5e833a0c26c64d64943
|
4
|
+
data.tar.gz: 74eb10c9644a5dd2fbcfe0850bdfa535cb669ed8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa5e1e84f305381673abfbb14796d040306910af540af05439eee4a21d85dd75afaa8c6e549ef9457043f67b1d2bfe579394714676196f3f852d68d05ce9ce7c
|
7
|
+
data.tar.gz: 7a312c1e095626a8a984cac7503340c0e46376656bb4a3e92b12bd44522c6ca76ac3d6f8ec83930460a24d568110e72693a8736ce4936e6bfe696a7e4f1a1ec6
|
data/README.md
CHANGED
@@ -18,7 +18,94 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
```
|
22
|
+
clash [test(s)] [options]
|
23
|
+
```
|
24
|
+
|
25
|
+
To run only specific tests, pass test numbers separated by commas.
|
26
|
+
|
27
|
+
```
|
28
|
+
$ clash 1 # run only the first test
|
29
|
+
$ clash 2,3 # run the second and third tests
|
30
|
+
```
|
31
|
+
|
32
|
+
### CLI options
|
33
|
+
|
34
|
+
```
|
35
|
+
-f, --file FILE Use a specific test file (default: .clash.yml)
|
36
|
+
-c, --context NUMBER On diff errors, show NUMBER of lines of surrounding context (default: 2)
|
37
|
+
-h, --help show this message
|
38
|
+
```
|
39
|
+
|
40
|
+
## Configuration
|
41
|
+
|
42
|
+
Clash reads its configuration from a .clash.yml file in the root of your project. Use the --file
|
43
|
+
option to choose a different configuration file.
|
44
|
+
|
45
|
+
Simple configuration:
|
46
|
+
Clash will build the site with Jekyll, and compare the contents of _site/ to expected/.
|
47
|
+
|
48
|
+
```
|
49
|
+
build: true
|
50
|
+
compare: _site, expected
|
51
|
+
```
|
52
|
+
|
53
|
+
### Configuration options
|
54
|
+
|
55
|
+
| Option | Type | Description |
|
56
|
+
|:-----------------|:---------------|:---------------------------------------------------------|
|
57
|
+
| name | String | Include a descriptive name with test output. |
|
58
|
+
| before | String/Array | Run system command(s) before running tests. |
|
59
|
+
| build | Boolean | Build the site with Jekyll. |
|
60
|
+
| config | Hash | Configure Jekyll, Octopress or Ink plugins. (Info below) |
|
61
|
+
| compare | String/Array | Compare files or directories. e.g. "a.md, b.md" |
|
62
|
+
| enforce_missing | String/Array | Ensure that these files are not found. |
|
63
|
+
| after | String/Array | Run system command(s) after running tests. |
|
64
|
+
|
65
|
+
Note: in the table above, String/Array means a single argument can be a string, but mutliples
|
66
|
+
can be passed as an array. For example:
|
67
|
+
|
68
|
+
```yaml
|
69
|
+
compare: _site, expected # Compare two directories
|
70
|
+
compare: # Compare mutiple items
|
71
|
+
- _site/index.html, expected/index.html
|
72
|
+
- _site/atom.xml, expected/atom.xml
|
73
|
+
- _site/posts, expected/posts
|
74
|
+
```
|
75
|
+
|
76
|
+
To run multiple tests each test should be an array, for example:
|
77
|
+
|
78
|
+
```
|
79
|
+
-
|
80
|
+
name: Check site build
|
81
|
+
build: true
|
82
|
+
compare: _site, _expected
|
83
|
+
-
|
84
|
+
name: Check asset compression
|
85
|
+
compare: _cdn_build, _cdn_expected
|
86
|
+
```
|
87
|
+
|
88
|
+
Note: When running multiple tests, adding a name can help the reading of test failures.
|
89
|
+
|
90
|
+
### Configuring Jekyll, Octopress and Octopress Ink plugins
|
91
|
+
|
92
|
+
```
|
93
|
+
build: true
|
94
|
+
config:
|
95
|
+
jekyll:
|
96
|
+
- _configs/config.yml
|
97
|
+
- _configs/test1.yml
|
98
|
+
octopress: _configs/octopress.yml
|
99
|
+
feed: _configs/feed.yml
|
100
|
+
```
|
101
|
+
|
102
|
+
In this example:
|
103
|
+
|
104
|
+
- Jekyll will build with `--config _configs/config.yml,_configs/test1.yml`
|
105
|
+
- _configs/octopress.yml will be copied to ./_octopress.yml (and removed after tests)
|
106
|
+
- _configs/feed.yml will be copied to ./_plugins/feed/config.yml (and removed after tests)
|
107
|
+
|
108
|
+
This will not overwrite existing files as they will be backed up an restored after tests.
|
22
109
|
|
23
110
|
## Contributing
|
24
111
|
|
data/bin/clash
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(File.expand_path("../lib", File.dirname(__FILE__)))
|
4
|
+
|
5
|
+
require 'clash'
|
6
|
+
require 'optparse'
|
7
|
+
|
8
|
+
options = {}
|
9
|
+
|
10
|
+
OptionParser.new do |opts|
|
11
|
+
opts.banner = "Usage: clash [options]"
|
12
|
+
|
13
|
+
opts.on("-f FILE", "--file FILE", "Set test file (default: .clash.yml).") do |f|
|
14
|
+
options[:file] = f
|
15
|
+
end
|
16
|
+
|
17
|
+
opts.on("-c", "--context NUMBER", Integer, "Number of lines of context on a diff") do |context|
|
18
|
+
options[:context] = context
|
19
|
+
end
|
20
|
+
|
21
|
+
opts.on("-h", "--help", "Show help message") do |h|
|
22
|
+
options[:help] = h
|
23
|
+
end
|
24
|
+
|
25
|
+
end.parse!
|
26
|
+
|
27
|
+
if !ARGV.empty?
|
28
|
+
# Parse input `clash 1 2 3` and `clash 1,2,3` the same
|
29
|
+
#
|
30
|
+
options[:only] = ARGV.join(',').split(',').map{ |n| n.to_i }
|
31
|
+
end
|
32
|
+
|
33
|
+
if options[:help]
|
34
|
+
puts <<-HELP
|
35
|
+
clash #{Clash::VERSION} -- Clash is a diff based testing suite for static sites.
|
36
|
+
|
37
|
+
Usage:
|
38
|
+
|
39
|
+
clash [test(s)] [options]
|
40
|
+
|
41
|
+
To run only specific tests, pass test numbers separated by commas.
|
42
|
+
|
43
|
+
`clash 1` # run only the first test
|
44
|
+
`clash 2,3` # run the second and third tests
|
45
|
+
|
46
|
+
Options:
|
47
|
+
|
48
|
+
-f, --file FILE Use a specific test file (default: .clash.yml)
|
49
|
+
-c, --context NUMBER On diff errors, show NUMBER of lines of surrounding context (default: 2)
|
50
|
+
-h, --help show this message
|
51
|
+
|
52
|
+
Configuration:
|
53
|
+
|
54
|
+
Clash reads its configuration from a .clash.yml file in the root of your project. Use the --file
|
55
|
+
option to choose a different configuration file.
|
56
|
+
|
57
|
+
Simple configuration:
|
58
|
+
Clash will build the site with Jekyll, and compare the contents of _site/ to expected/.
|
59
|
+
|
60
|
+
build: true
|
61
|
+
compare: _site, expected
|
62
|
+
|
63
|
+
Full configuration:
|
64
|
+
|
65
|
+
| Option | Type | Description |
|
66
|
+
|:-----------------|:---------------|:---------------------------------------------------------|
|
67
|
+
| before | String/Array | Run system command(s) before running tests. |
|
68
|
+
| build | Boolean | Build the site with Jekyll. |
|
69
|
+
| config | Hash | Configure Jekyll, Octopress or Ink plugins. (Info below) |
|
70
|
+
| compare | String/Array | Compare files or directories. e.g. "a.md, b.md" |
|
71
|
+
| enforce_missing | String/Array | Ensure that these files are not found. |
|
72
|
+
| after | String/Array | Run system command(s) after running tests. |
|
73
|
+
|
74
|
+
Note: in the table above, String/Array means a single argument can be a string, but mutliples
|
75
|
+
can be passed as an array. For example:
|
76
|
+
|
77
|
+
compare: _site, expected # Compare two directories
|
78
|
+
compare: # Compare mutiple items
|
79
|
+
- _site/index.html, expected/index.html
|
80
|
+
- _site/atom.xml, expected/atom.xml
|
81
|
+
- _site/posts, expected/posts
|
82
|
+
|
83
|
+
|
84
|
+
To run multiple tests each test should be an array, for example:
|
85
|
+
|
86
|
+
-
|
87
|
+
name: Check site build
|
88
|
+
build: true
|
89
|
+
compare: _site, _expected
|
90
|
+
-
|
91
|
+
name: Check asset compression
|
92
|
+
compare: _cdn_build, _cdn_expected
|
93
|
+
|
94
|
+
Note: When running multiple tests, adding a name can help the reading of test failures.
|
95
|
+
|
96
|
+
|
97
|
+
Configuring Jekyll, Octopress and Octopress Ink plugins:
|
98
|
+
|
99
|
+
build: true
|
100
|
+
config:
|
101
|
+
jekyll:
|
102
|
+
- _configs/config.yml
|
103
|
+
- _configs/test1.yml
|
104
|
+
octopress: _configs/octopress.yml
|
105
|
+
feed: _configs/feed.yml
|
106
|
+
|
107
|
+
In this example:
|
108
|
+
|
109
|
+
- Jekyll will build with `--config _configs/config.yml,_configs/test1.yml`
|
110
|
+
- _configs/octopress.yml will be copied to ./_octopress.yml (and removed after tests)
|
111
|
+
- _configs/feed.yml will be copied to ./_plugins/feed/config.yml (and removed after tests)
|
112
|
+
|
113
|
+
This will not overwrite existing files as they will be backed up an restored after tests.
|
114
|
+
HELP
|
115
|
+
else
|
116
|
+
Clash::Tests.new(options).run
|
117
|
+
end
|
data/clash.gemspec
CHANGED
@@ -18,6 +18,11 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.add_runtime_dependency "diffy", "~> 3.0"
|
22
|
+
spec.add_runtime_dependency "safe_yaml", "~> 1.0"
|
23
|
+
spec.add_runtime_dependency "colorator", "~> 0.1"
|
24
|
+
|
21
25
|
spec.add_development_dependency "bundler", "~> 1.6"
|
22
26
|
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency "pry-debugger"
|
23
28
|
end
|
data/lib/clash.rb
CHANGED
@@ -1,5 +1,13 @@
|
|
1
|
-
require
|
1
|
+
require 'clash/version'
|
2
|
+
require 'colorator'
|
3
|
+
require 'find'
|
4
|
+
require 'safe_yaml'
|
5
|
+
require 'diffy'
|
2
6
|
|
3
7
|
module Clash
|
4
|
-
|
8
|
+
|
9
|
+
autoload :Tests, 'clash/tests'
|
10
|
+
autoload :Test, 'clash/test'
|
11
|
+
autoload :Diff, 'clash/diff'
|
12
|
+
autoload :Helpers, 'clash/helpers'
|
5
13
|
end
|
data/lib/clash/diff.rb
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
module Clash
|
2
|
+
class Diff
|
3
|
+
include Helpers
|
4
|
+
|
5
|
+
def initialize(a, b, options={})
|
6
|
+
@diffs = {}
|
7
|
+
@a = a
|
8
|
+
@b = b
|
9
|
+
@context = options[:context] || 2
|
10
|
+
end
|
11
|
+
|
12
|
+
def diff
|
13
|
+
if File.directory?(@a)
|
14
|
+
diff_dirs(@a, @b)
|
15
|
+
else
|
16
|
+
diff_files(@a, @b)
|
17
|
+
end
|
18
|
+
|
19
|
+
@diffs
|
20
|
+
end
|
21
|
+
|
22
|
+
def diff_files(a, b)
|
23
|
+
if exists(a) && exists(b)
|
24
|
+
diffy = Diffy::Diff.new(a,b, :source => 'files', :context => @context)
|
25
|
+
file_diff = diffy.to_a
|
26
|
+
|
27
|
+
if !file_diff.empty?
|
28
|
+
file_diff = format_diff(file_diff)
|
29
|
+
@diffs["Compared #{colorize(a, 'yellow')} to #{colorize(b,'yellow')}"] = file_diff
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Recursively diff common files between dir1 and dir2
|
35
|
+
#
|
36
|
+
def diff_dirs(dir1, dir2)
|
37
|
+
mattching_dir_files(dir1, dir2).each do |file|
|
38
|
+
a = File.join(dir1, file)
|
39
|
+
b = File.join(dir2, file)
|
40
|
+
diff_files(a,b)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Return files that exist in both directories (without dir names)
|
45
|
+
#
|
46
|
+
def mattching_dir_files(dir1, dir2)
|
47
|
+
dir1_files = dir_files(dir1).map {|f| f.sub(dir1,'') }
|
48
|
+
dir2_files = dir_files(dir2).map {|f| f.sub(dir2,'') }
|
49
|
+
|
50
|
+
matches = dir1_files & dir2_files
|
51
|
+
|
52
|
+
unique_files(dir1, dir1_files, matches)
|
53
|
+
unique_files(dir2, dir2_files, matches)
|
54
|
+
|
55
|
+
matches
|
56
|
+
end
|
57
|
+
|
58
|
+
# Find all files in a given directory
|
59
|
+
#
|
60
|
+
def dir_files(dir)
|
61
|
+
Find.find(dir).to_a.reject!{|f| File.directory?(f) }
|
62
|
+
end
|
63
|
+
|
64
|
+
# Find files which aren't common to both directories
|
65
|
+
#
|
66
|
+
def unique_files(dir, dir_files, common_files)
|
67
|
+
unique = dir_files - common_files
|
68
|
+
if !unique.empty?
|
69
|
+
@test_failures << colorize("Files missing from #{dir}/", 'red')
|
70
|
+
unique.each {|f| @test_failures << "- #{f}"}
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def exists(f)
|
75
|
+
file_exists = File.exists?(f)
|
76
|
+
|
77
|
+
if !file_exists
|
78
|
+
@test_failures << "#{colorize('File not found:', 'red')} #{f}"
|
79
|
+
end
|
80
|
+
|
81
|
+
file_exists
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
def format_diff(diff)
|
86
|
+
count = 0
|
87
|
+
|
88
|
+
diff = diff.map { |line|
|
89
|
+
case line
|
90
|
+
when /^\+/ then
|
91
|
+
count = 0
|
92
|
+
colorize(line, 'green')
|
93
|
+
when /^-/ then
|
94
|
+
count = 0
|
95
|
+
colorize(line, 'red')
|
96
|
+
else
|
97
|
+
if count == @context
|
98
|
+
count = 0
|
99
|
+
"...\n#{line}"
|
100
|
+
else
|
101
|
+
count += 1
|
102
|
+
line
|
103
|
+
end
|
104
|
+
end
|
105
|
+
}
|
106
|
+
diff.join('')
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Clash
|
2
|
+
module Helpers
|
3
|
+
def default_array(option)
|
4
|
+
o = option || []
|
5
|
+
o = [o] unless o.is_a?(Array)
|
6
|
+
o
|
7
|
+
end
|
8
|
+
|
9
|
+
def colorize(str, color)
|
10
|
+
if STDOUT.tty?
|
11
|
+
str.send(color)
|
12
|
+
else
|
13
|
+
str
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Print a single character without a newline
|
18
|
+
#
|
19
|
+
def pout(str)
|
20
|
+
print str
|
21
|
+
if STDOUT.tty?
|
22
|
+
$stdout.flush
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def print_fail
|
27
|
+
pout colorize('F', 'red')
|
28
|
+
end
|
29
|
+
|
30
|
+
def print_pass
|
31
|
+
pout colorize('.', 'green')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/clash/test.rb
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
module Clash
|
2
|
+
class Test
|
3
|
+
attr_accessor :title
|
4
|
+
|
5
|
+
include Helpers
|
6
|
+
|
7
|
+
def initialize(options={})
|
8
|
+
@test_failures = []
|
9
|
+
@options = options
|
10
|
+
@options['config'] ||= {}
|
11
|
+
@cleanup = []
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
system_cmd(@options['before'])
|
16
|
+
config
|
17
|
+
build if @options['build']
|
18
|
+
cleanup_config
|
19
|
+
compare
|
20
|
+
enforce_missing
|
21
|
+
print_result
|
22
|
+
system_cmd(@options['after'])
|
23
|
+
results
|
24
|
+
end
|
25
|
+
|
26
|
+
def config
|
27
|
+
@options['config'].each do |name, file|
|
28
|
+
case name
|
29
|
+
when 'jekyll' then next
|
30
|
+
when 'octopress' then config_octopress(file)
|
31
|
+
else config_plugin(name, file)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def cleanup_config
|
37
|
+
@cleanup.each do |file|
|
38
|
+
if File.extname(file) == '.bak'
|
39
|
+
FileUtils.mv(file, file.sub(/\.bak$/,''), force: true)
|
40
|
+
else
|
41
|
+
FileUtils.rm(file)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def config_octopress(file)
|
47
|
+
copy_config(file, '_octopress.yml')
|
48
|
+
end
|
49
|
+
|
50
|
+
def config_plugin(name, file)
|
51
|
+
copy_config(file, "_plugins/#{name}/config.yml")
|
52
|
+
end
|
53
|
+
|
54
|
+
def copy_config(file, target)
|
55
|
+
if File.exists?(file)
|
56
|
+
# Make a backup of existing files first
|
57
|
+
#
|
58
|
+
if File.exists?(target)
|
59
|
+
FileUtils.mv target, "#{target}.bak"
|
60
|
+
@cleanup << "#{target}.bak"
|
61
|
+
else
|
62
|
+
@cleanup << target
|
63
|
+
end
|
64
|
+
|
65
|
+
FileUtils.mkdir_p(File.dirname(target))
|
66
|
+
FileUtils.cp file, target
|
67
|
+
else
|
68
|
+
@test_failures << "Config file: #{file} cannot be found.\n"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def build
|
73
|
+
if jekyll_config = @options['config']['jekyll']
|
74
|
+
configs = default_array(jekyll_config).join(',')
|
75
|
+
system("jekyll build --trace --config #{configs}")
|
76
|
+
else
|
77
|
+
system("jekyll build --trace")
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def system_cmd(cmds)
|
82
|
+
cmds = default_array(cmds)
|
83
|
+
cmds.each {|cmd| system(cmd) }
|
84
|
+
end
|
85
|
+
|
86
|
+
def compare
|
87
|
+
default_array(@options['compare']).each do |files|
|
88
|
+
f = files.split(',')
|
89
|
+
diff = Diff.new(f[0].strip, f[1].strip, context: @options['context']).diff
|
90
|
+
diff.each do |title, diff|
|
91
|
+
@test_failures << "#{title}\n#{diff}\n"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def enforce_missing
|
97
|
+
default_array(@options['enforce_missing']).each do |files|
|
98
|
+
if File.exists?(file)
|
99
|
+
@test_failures << "File #{file} shouldn't exist."
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def print_result
|
105
|
+
if @test_failures.empty?
|
106
|
+
print_pass
|
107
|
+
else
|
108
|
+
print_fail
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def results
|
113
|
+
if !@test_failures.empty?
|
114
|
+
@test_failures.unshift(test_title)
|
115
|
+
@test_failures
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_title
|
120
|
+
title = colorize("Test ##{@options['index']}", 'bold')
|
121
|
+
title << " - #{@options['title']}" unless @options['title'].nil?
|
122
|
+
<<-HERE
|
123
|
+
Failed #{title}
|
124
|
+
========================================================
|
125
|
+
HERE
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
end
|
data/lib/clash/tests.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
module Clash
|
2
|
+
class Tests
|
3
|
+
include Helpers
|
4
|
+
|
5
|
+
def initialize(options={})
|
6
|
+
@options = options
|
7
|
+
|
8
|
+
@options[:file] ||= '.clash.yml'
|
9
|
+
@options[:context] ||= 2
|
10
|
+
@options[:only] = default_array(@options[:only])
|
11
|
+
|
12
|
+
@tests = default_array(SafeYAML.load_file(@options[:file]))
|
13
|
+
end
|
14
|
+
|
15
|
+
def run
|
16
|
+
@results = {}
|
17
|
+
@passed = []
|
18
|
+
@failed = []
|
19
|
+
@tests.each_with_index do |options, index|
|
20
|
+
|
21
|
+
# If tests are limited, only run specified tests
|
22
|
+
#
|
23
|
+
next if !@options[:only].empty? && !@options[:only].include?(index + 1)
|
24
|
+
|
25
|
+
options['index'] = index + 1
|
26
|
+
options['context'] = @options[:context]
|
27
|
+
|
28
|
+
results = Test.new(options).run
|
29
|
+
|
30
|
+
if results.nil?
|
31
|
+
@passed << index + 1
|
32
|
+
else
|
33
|
+
@failed << index + 1
|
34
|
+
@results[index + 1] = results
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
print_results
|
39
|
+
end
|
40
|
+
|
41
|
+
def print_results
|
42
|
+
puts "" # newline
|
43
|
+
|
44
|
+
if @results.empty?
|
45
|
+
puts colorize("Passed #{@passed.size} of #{@passed.size} tests", "green")
|
46
|
+
else
|
47
|
+
@results.each do |test, results|
|
48
|
+
if !results.empty?
|
49
|
+
puts "\n#{results.join('')}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
puts "#{colorize("Passed #{@passed.size}", "green")}: Tests: #{@passed.join(',')}"
|
54
|
+
puts "#{colorize("Failed #{@failed.size}", "red")}: Tests: #{@failed.join(',')}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/lib/clash/version.rb
CHANGED
data/test/.clash.yml
ADDED
data/test/Gemfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
name: Clashing
|
data/test/_test.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
name: Clash
|
data/test/a.txt
ADDED
data/test/a/1.txt
ADDED
data/test/a/2.txt
ADDED
data/test/b.txt
ADDED
data/test/b/1.txt
ADDED
data/test/b/2.txt
ADDED
data/test/c.txt
ADDED
data/test/c/1.txt
ADDED
data/test/c/2.txt
ADDED
metadata
CHANGED
@@ -1,15 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Mathis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: diffy
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: safe_yaml
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: colorator
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.1'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.1'
|
13
55
|
- !ruby/object:Gem::Dependency
|
14
56
|
name: bundler
|
15
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,10 +80,25 @@ dependencies:
|
|
38
80
|
- - ">="
|
39
81
|
- !ruby/object:Gem::Version
|
40
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry-debugger
|
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'
|
41
97
|
description: A diff based testing framework for static sites.
|
42
98
|
email:
|
43
99
|
- brandon@imathis.com
|
44
|
-
executables:
|
100
|
+
executables:
|
101
|
+
- clash
|
45
102
|
extensions: []
|
46
103
|
extra_rdoc_files: []
|
47
104
|
files:
|
@@ -50,9 +107,27 @@ files:
|
|
50
107
|
- LICENSE.txt
|
51
108
|
- README.md
|
52
109
|
- Rakefile
|
110
|
+
- bin/clash
|
53
111
|
- clash.gemspec
|
54
112
|
- lib/clash.rb
|
113
|
+
- lib/clash/diff.rb
|
114
|
+
- lib/clash/helpers.rb
|
115
|
+
- lib/clash/test.rb
|
116
|
+
- lib/clash/tests.rb
|
55
117
|
- lib/clash/version.rb
|
118
|
+
- test/.clash.yml
|
119
|
+
- test/Gemfile
|
120
|
+
- test/_plugins/feed/config.yml
|
121
|
+
- test/_test.yml
|
122
|
+
- test/a.txt
|
123
|
+
- test/a/1.txt
|
124
|
+
- test/a/2.txt
|
125
|
+
- test/b.txt
|
126
|
+
- test/b/1.txt
|
127
|
+
- test/b/2.txt
|
128
|
+
- test/c.txt
|
129
|
+
- test/c/1.txt
|
130
|
+
- test/c/2.txt
|
56
131
|
homepage: https://github.com/imathis/clash
|
57
132
|
licenses:
|
58
133
|
- MIT
|
@@ -77,4 +152,17 @@ rubygems_version: 2.2.2
|
|
77
152
|
signing_key:
|
78
153
|
specification_version: 4
|
79
154
|
summary: A diff based testing framework for static sites.
|
80
|
-
test_files:
|
155
|
+
test_files:
|
156
|
+
- test/.clash.yml
|
157
|
+
- test/Gemfile
|
158
|
+
- test/_plugins/feed/config.yml
|
159
|
+
- test/_test.yml
|
160
|
+
- test/a.txt
|
161
|
+
- test/a/1.txt
|
162
|
+
- test/a/2.txt
|
163
|
+
- test/b.txt
|
164
|
+
- test/b/1.txt
|
165
|
+
- test/b/2.txt
|
166
|
+
- test/c.txt
|
167
|
+
- test/c/1.txt
|
168
|
+
- test/c/2.txt
|