git-approvals 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -0
- data/README.md +8 -5
- data/Rakefile +6 -1
- data/git-approvals.gemspec +3 -1
- data/lib/git/approvals.rb +6 -5
- data/lib/git/approvals/approval.rb +6 -0
- data/lib/git/approvals/html_formatter.rb +23 -0
- data/lib/git/approvals/version.rb +1 -1
- data/spec/fixtures/input.html +1 -0
- data/spec/fixtures/output.html +4 -0
- data/spec/git/approvals/formatter_spec.rb +3 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/coveralls.rb +2 -0
- metadata +43 -3
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
Simple git-powered approval tests.
|
4
4
|
|
5
|
+
[![Build Status](https://travis-ci.org/jeremyruppel/git-approvals.png)](https://travis-ci.org/jeremyruppel/git-approvals)
|
6
|
+
[![Coverage Status](https://coveralls.io/repos/jeremyruppel/git-approvals/badge.png?branch=master)](https://coveralls.io/r/jeremyruppel/git-approvals?branch=master)
|
7
|
+
|
5
8
|
## Installation
|
6
9
|
|
7
10
|
Add this line to your application's Gemfile:
|
@@ -55,11 +58,11 @@ describe Foo do
|
|
55
58
|
end
|
56
59
|
```
|
57
60
|
|
58
|
-
The result of `Foo.bar` will be written to `spec/foo_spec/
|
61
|
+
The result of `Foo.bar` will be written to `spec/foo_spec/foo_bar`.
|
59
62
|
The test will fail because the file is not checked in to your git repo,
|
60
63
|
meaning you haven't approved it yet, so add it to approve it:
|
61
64
|
|
62
|
-
`git add spec/foo_spec/foo_bar
|
65
|
+
`git add spec/foo_spec/foo_bar`
|
63
66
|
|
64
67
|
Another test run shows that the test now passes. On the next test run, the
|
65
68
|
same file will be written out. If git says the file has changed, the
|
@@ -71,8 +74,8 @@ The `verify` method accepts the same options hash as the Approval constructor.
|
|
71
74
|
|
72
75
|
The following options are supported:
|
73
76
|
|
74
|
-
- `:format`: specifies the format to use when writing out the approved file. The format
|
75
|
-
- `:filename`: specifies the filename of the approved file.
|
77
|
+
- `:format`: specifies the format to use when writing out the approved file. The format can be inferred from the extension of the approved file, but if you specify it here, it will change the extension to match. This option accepts any extension that is registered with [tilt][tilt].
|
78
|
+
- `:filename`: specifies the base filename of the approved file.
|
76
79
|
|
77
80
|
### Formatters
|
78
81
|
|
@@ -83,7 +86,7 @@ The following options are supported:
|
|
83
86
|
- `js` pretty-prints JavaScript source using [uglifier][uglifier].
|
84
87
|
- `css` pretty-prints CSS source using [SASS][sass].
|
85
88
|
|
86
|
-
The format
|
89
|
+
The format is determined by checking the `:format` key of the options hash, then the extension of the approved filename. If neither are present, the file will be written as plain text.
|
87
90
|
|
88
91
|
## Contributing
|
89
92
|
|
data/Rakefile
CHANGED
data/git-approvals.gemspec
CHANGED
@@ -24,11 +24,13 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency 'awesome_print', '~> 1.1.0'
|
25
25
|
spec.add_development_dependency 'uglifier', '~> 2.1.1'
|
26
26
|
spec.add_development_dependency 'sass', '~> 3.2.9'
|
27
|
+
spec.add_development_dependency 'nokogiri', '~> 1.6.0'
|
27
28
|
|
28
29
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
29
30
|
spec.add_development_dependency 'rspec', '~> 2.13.0'
|
30
31
|
spec.add_development_dependency 'guard-rspec', '~> 2.5.2'
|
31
32
|
spec.add_development_dependency 'rb-fsevent', '~> 0.9'
|
32
|
-
spec.add_development_dependency '
|
33
|
+
spec.add_development_dependency 'coveralls'
|
33
34
|
spec.add_development_dependency 'rake'
|
35
|
+
spec.add_development_dependency 'pry'
|
34
36
|
end
|
data/lib/git/approvals.rb
CHANGED
@@ -3,11 +3,12 @@ require 'git/approvals/version'
|
|
3
3
|
module Git
|
4
4
|
module Approvals
|
5
5
|
autoload :Approval, 'git/approvals/approval'
|
6
|
-
autoload :AwesomePrintFormatter, 'git/approvals/awesome_print_formatter
|
7
|
-
autoload :
|
8
|
-
autoload :
|
9
|
-
autoload :
|
10
|
-
autoload :
|
6
|
+
autoload :AwesomePrintFormatter, 'git/approvals/awesome_print_formatter'
|
7
|
+
autoload :HTMLFormatter, 'git/approvals/html_formatter'
|
8
|
+
autoload :JSONFormatter, 'git/approvals/json_formatter'
|
9
|
+
autoload :PlainFormatter, 'git/approvals/plain_formatter'
|
10
|
+
autoload :SassFormatter, 'git/approvals/sass_formatter'
|
11
|
+
autoload :UglifierFormatter, 'git/approvals/uglifier_formatter'
|
11
12
|
autoload :Utils, 'git/approvals/utils'
|
12
13
|
end
|
13
14
|
end
|
@@ -53,8 +53,14 @@ module Git
|
|
53
53
|
# Register all formatters as tilt templates.
|
54
54
|
Tilt.register PlainFormatter, ''
|
55
55
|
Tilt.register AwesomePrintFormatter, 'txt'
|
56
|
+
Tilt.register HTMLFormatter, 'html'
|
56
57
|
Tilt.register JSONFormatter, 'json'
|
57
58
|
Tilt.register UglifierFormatter, 'js'
|
58
59
|
Tilt.register SassFormatter, 'css'
|
60
|
+
|
61
|
+
# FIXME there is already a template registered for 'html',
|
62
|
+
# so we need to prefer ours here. There has to be a better
|
63
|
+
# way to avoid that conflict though.
|
64
|
+
Tilt.prefer HTMLFormatter, 'html'
|
59
65
|
end
|
60
66
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'tilt'
|
2
|
+
|
3
|
+
module Git
|
4
|
+
module Approvals
|
5
|
+
class HTMLFormatter < Tilt::Template
|
6
|
+
|
7
|
+
def self.engine_initialized?
|
8
|
+
defined?(::Nokogiri)
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize_engine
|
12
|
+
require_template_library 'nokogiri'
|
13
|
+
end
|
14
|
+
|
15
|
+
def prepare
|
16
|
+
end
|
17
|
+
|
18
|
+
def evaluate( context, locals, &block )
|
19
|
+
Nokogiri::XML( context ).to_xhtml :indent => 2
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<output><h1>Git + Approvals</h1><p>Pretty <strong>dope.</strong></p></output>
|
@@ -16,6 +16,9 @@ end
|
|
16
16
|
describe Git::Approvals::JSONFormatter do
|
17
17
|
include_examples 'formatter', '.json'
|
18
18
|
end
|
19
|
+
describe Git::Approvals::HTMLFormatter do
|
20
|
+
include_examples 'formatter', '.html'
|
21
|
+
end
|
19
22
|
describe Git::Approvals::UglifierFormatter do
|
20
23
|
include_examples 'formatter', '.js'
|
21
24
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-approvals
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
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-
|
12
|
+
date: 2013-08-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: tilt
|
@@ -75,6 +75,22 @@ dependencies:
|
|
75
75
|
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: 3.2.9
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: nokogiri
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.6.0
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.6.0
|
78
94
|
- !ruby/object:Gem::Dependency
|
79
95
|
name: bundler
|
80
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,7 +156,7 @@ dependencies:
|
|
140
156
|
- !ruby/object:Gem::Version
|
141
157
|
version: '0.9'
|
142
158
|
- !ruby/object:Gem::Dependency
|
143
|
-
name:
|
159
|
+
name: coveralls
|
144
160
|
requirement: !ruby/object:Gem::Requirement
|
145
161
|
none: false
|
146
162
|
requirements:
|
@@ -171,6 +187,22 @@ dependencies:
|
|
171
187
|
- - ! '>='
|
172
188
|
- !ruby/object:Gem::Version
|
173
189
|
version: '0'
|
190
|
+
- !ruby/object:Gem::Dependency
|
191
|
+
name: pry
|
192
|
+
requirement: !ruby/object:Gem::Requirement
|
193
|
+
none: false
|
194
|
+
requirements:
|
195
|
+
- - ! '>='
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: '0'
|
198
|
+
type: :development
|
199
|
+
prerelease: false
|
200
|
+
version_requirements: !ruby/object:Gem::Requirement
|
201
|
+
none: false
|
202
|
+
requirements:
|
203
|
+
- - ! '>='
|
204
|
+
- !ruby/object:Gem::Version
|
205
|
+
version: '0'
|
174
206
|
description: Simple git-powered approval tests. With RSpec integration.
|
175
207
|
email:
|
176
208
|
- jeremy.ruppel@gmail.com
|
@@ -182,6 +214,7 @@ files:
|
|
182
214
|
- .gitignore
|
183
215
|
- .pryrc
|
184
216
|
- .rspec
|
217
|
+
- .travis.yml
|
185
218
|
- Gemfile
|
186
219
|
- Guardfile
|
187
220
|
- LICENSE.txt
|
@@ -193,6 +226,7 @@ files:
|
|
193
226
|
- lib/git/approvals.rb
|
194
227
|
- lib/git/approvals/approval.rb
|
195
228
|
- lib/git/approvals/awesome_print_formatter.rb
|
229
|
+
- lib/git/approvals/html_formatter.rb
|
196
230
|
- lib/git/approvals/json_formatter.rb
|
197
231
|
- lib/git/approvals/plain_formatter.rb
|
198
232
|
- lib/git/approvals/rspec.rb
|
@@ -203,10 +237,12 @@ files:
|
|
203
237
|
- lib/rspec/approvals.rb
|
204
238
|
- spec/fixtures/input
|
205
239
|
- spec/fixtures/input.css
|
240
|
+
- spec/fixtures/input.html
|
206
241
|
- spec/fixtures/input.js
|
207
242
|
- spec/fixtures/input.json
|
208
243
|
- spec/fixtures/output
|
209
244
|
- spec/fixtures/output.css
|
245
|
+
- spec/fixtures/output.html
|
210
246
|
- spec/fixtures/output.js
|
211
247
|
- spec/fixtures/output.json
|
212
248
|
- spec/fixtures/output.txt
|
@@ -217,6 +253,7 @@ files:
|
|
217
253
|
- spec/git/approvals/rspec_spec/rspec_integration/verify/passes_when_unchanged
|
218
254
|
- spec/git/approvals/utils_spec.rb
|
219
255
|
- spec/spec_helper.rb
|
256
|
+
- spec/support/coveralls.rb
|
220
257
|
homepage: https://github.com/jeremyruppel/git-approvals
|
221
258
|
licenses:
|
222
259
|
- MIT
|
@@ -245,10 +282,12 @@ summary: Simple git-powered approval tests.
|
|
245
282
|
test_files:
|
246
283
|
- spec/fixtures/input
|
247
284
|
- spec/fixtures/input.css
|
285
|
+
- spec/fixtures/input.html
|
248
286
|
- spec/fixtures/input.js
|
249
287
|
- spec/fixtures/input.json
|
250
288
|
- spec/fixtures/output
|
251
289
|
- spec/fixtures/output.css
|
290
|
+
- spec/fixtures/output.html
|
252
291
|
- spec/fixtures/output.js
|
253
292
|
- spec/fixtures/output.json
|
254
293
|
- spec/fixtures/output.txt
|
@@ -259,4 +298,5 @@ test_files:
|
|
259
298
|
- spec/git/approvals/rspec_spec/rspec_integration/verify/passes_when_unchanged
|
260
299
|
- spec/git/approvals/utils_spec.rb
|
261
300
|
- spec/spec_helper.rb
|
301
|
+
- spec/support/coveralls.rb
|
262
302
|
has_rdoc:
|