approvals 0.0.16 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/approvals.gemspec +1 -1
- data/lib/approvals/namers/directory_namer.rb +15 -4
- data/lib/approvals/version.rb +1 -1
- data/spec/approvals_spec.rb +4 -3
- data/spec/configuration_spec.rb +2 -2
- data/spec/dotfile_spec.rb +3 -3
- data/spec/executable_spec.rb +2 -2
- data/spec/extensions/rspec_approvals_spec.rb +2 -2
- data/spec/namers/default_namer_spec.rb +5 -3
- data/spec/namers/directory_namer_spec.rb +3 -3
- data/spec/namers/rspec_namer_spec.rb +3 -3
- data/spec/namers_spec.rb +2 -2
- data/spec/reporters/first_working_reporter_spec.rb +5 -5
- data/spec/reporters/html_image_reporter_spec.rb +1 -1
- data/spec/reporters/image_magick_reporter_spec.rb +1 -1
- data/spec/reporters/launcher_spec.rb +5 -7
- data/spec/reporters/reporter_spec.rb +3 -3
- data/spec/scrubber_spec.rb +4 -4
- data/spec/spec_helper.rb +1 -1
- data/spec/system_command_spec.rb +2 -2
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6df7476eb9432577895df3170adc9653d7f7615f
|
4
|
+
data.tar.gz: 1ea30b6816e7282509c98524394ba9e76d787a27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2945a8151ca583748a19ea37448723a63fb0f9cb6eefc427cf2fa8a368b4d7372199231de86a7614e3e3746f9d9a1881b2f1e2bff23e6f2a1a16b55931446953
|
7
|
+
data.tar.gz: 478fbaf9846755cedb47216ccbec95f879faeee7ad1728b794992e9ae39b7653bfdb40dd0979f73c6c5a779dab63f1f4cedf91958f8bc4a20e7058ba16fe515a
|
data/approvals.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
21
|
s.require_paths = ["lib"]
|
22
22
|
|
23
|
-
s.add_development_dependency 'rspec', '~>
|
23
|
+
s.add_development_dependency 'rspec', '~> 3.1'
|
24
24
|
s.add_development_dependency 'json', '~> 1.8'
|
25
25
|
s.add_dependency 'thor', '~> 0.18'
|
26
26
|
s.add_dependency 'nokogiri', '~> 1.6'
|
@@ -12,11 +12,22 @@ module Approvals
|
|
12
12
|
parts = [ ]
|
13
13
|
metadata = example.metadata
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
approvals_path = lambda do |metadata|
|
16
|
+
description = normalize metadata[:description]
|
17
|
+
example_group = if metadata.key?(:example_group)
|
18
|
+
metadata[:example_group]
|
19
|
+
else
|
20
|
+
metadata[:parent_example_group]
|
21
|
+
end
|
18
22
|
|
19
|
-
|
23
|
+
if example_group
|
24
|
+
[approvals_path[example_group], description].join('/')
|
25
|
+
else
|
26
|
+
description
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
approvals_path[example.metadata]
|
20
31
|
end
|
21
32
|
end
|
22
33
|
end
|
data/lib/approvals/version.rb
CHANGED
data/spec/approvals_spec.rb
CHANGED
@@ -6,10 +6,11 @@ describe Approvals do
|
|
6
6
|
let(:namer) { |example| Approvals::Namers::RSpecNamer.new(example) }
|
7
7
|
|
8
8
|
it "fails" do
|
9
|
-
Approvals::Dotfile.
|
10
|
-
|
9
|
+
allow(Approvals::Dotfile).to receive(:path).and_return('/dev/null')
|
10
|
+
|
11
|
+
expect do
|
11
12
|
Approvals.verify "this one doesn't exist", :namer => namer
|
12
|
-
|
13
|
+
end.to raise_error Approvals::ApprovalError
|
13
14
|
end
|
14
15
|
|
15
16
|
it "verifies a string" do
|
data/spec/configuration_spec.rb
CHANGED
@@ -4,7 +4,7 @@ require 'approvals/configuration'
|
|
4
4
|
describe Approvals::Configuration do
|
5
5
|
|
6
6
|
it "defaults to 'fixtures/approvals/'" do
|
7
|
-
Approvals.configuration.approvals_path.
|
7
|
+
expect(Approvals.configuration.approvals_path).to eq('fixtures/approvals/')
|
8
8
|
end
|
9
9
|
|
10
10
|
describe "when set" do
|
@@ -21,7 +21,7 @@ describe Approvals::Configuration do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "overrides the output directory" do
|
24
|
-
Approvals.configuration.approvals_path.
|
24
|
+
expect(Approvals.configuration.approvals_path).to eq('output/dir/')
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
data/spec/dotfile_spec.rb
CHANGED
@@ -5,18 +5,18 @@ describe Approvals::Dotfile do
|
|
5
5
|
let(:dotfile) { '/tmp/.approvals' }
|
6
6
|
|
7
7
|
before(:each) do
|
8
|
-
Approvals::Dotfile.
|
8
|
+
allow(Approvals::Dotfile).to receive(:path).and_return dotfile
|
9
9
|
Approvals::Dotfile.reset
|
10
10
|
end
|
11
11
|
|
12
12
|
it "appends the text" do
|
13
13
|
Approvals::Dotfile.append('text')
|
14
|
-
File.readlines(dotfile).map(&:chomp).
|
14
|
+
expect(File.readlines(dotfile).map(&:chomp)).to eq ['text']
|
15
15
|
end
|
16
16
|
|
17
17
|
it "appends the text exactly once" do
|
18
18
|
Approvals::Dotfile.append('text')
|
19
19
|
Approvals::Dotfile.append('text')
|
20
|
-
File.readlines(dotfile).map(&:chomp).
|
20
|
+
expect(File.readlines(dotfile).map(&:chomp)).to eq ['text']
|
21
21
|
end
|
22
22
|
end
|
data/spec/executable_spec.rb
CHANGED
@@ -5,13 +5,13 @@ describe Approvals::Executable do
|
|
5
5
|
|
6
6
|
it "reflects the its value in inspect" do
|
7
7
|
executable = Approvals::Executable.new('SELECT 1')
|
8
|
-
executable.inspect.
|
8
|
+
expect(executable.inspect).to eq 'SELECT 1'
|
9
9
|
end
|
10
10
|
|
11
11
|
it "takes a block" do
|
12
12
|
executable = Approvals::Executable.new('SELECT 1') do |command|
|
13
13
|
"execute query: #{command}"
|
14
14
|
end
|
15
|
-
executable.on_failure.call('SELECT 1').
|
15
|
+
expect(executable.on_failure.call('SELECT 1')).to eq 'execute query: SELECT 1'
|
16
16
|
end
|
17
17
|
end
|
@@ -67,13 +67,13 @@ shared_context 'verify examples' do
|
|
67
67
|
|
68
68
|
specify "a failure diff" do
|
69
69
|
::RSpec.configuration.diff_on_approval_failure = true
|
70
|
-
::RSpec::Expectations.
|
70
|
+
expect(::RSpec::Expectations).to receive(:fail_with)
|
71
71
|
verify { 'no.' }
|
72
72
|
::RSpec.configuration.diff_on_approval_failure = false
|
73
73
|
end
|
74
74
|
|
75
75
|
specify "a failure diff", :diff_on_approval_failure => true do
|
76
|
-
::RSpec::Expectations.
|
76
|
+
expect(::RSpec::Expectations).to receive(:fail_with)
|
77
77
|
verify { 'no.' }
|
78
78
|
end
|
79
79
|
end
|
@@ -7,7 +7,7 @@ describe Approvals::Namers::DefaultNamer do
|
|
7
7
|
subject { Approvals::Namers::DefaultNamer.new("a f!$^%&*(unky name") }
|
8
8
|
|
9
9
|
it "normalizes the name" do
|
10
|
-
subject.name.
|
10
|
+
expect(subject.name).to eq 'a_funky_name'
|
11
11
|
end
|
12
12
|
|
13
13
|
context "when configured" do
|
@@ -24,12 +24,14 @@ describe Approvals::Namers::DefaultNamer do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it "uses the approvals output dir" do
|
27
|
-
subject.output_dir.
|
27
|
+
expect(subject.output_dir).to eq 'path/to/files/'
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
it "must have a name" do
|
32
|
-
|
32
|
+
expect do
|
33
|
+
Approvals::Namers::DefaultNamer.new nil
|
34
|
+
end.to raise_error ArgumentError
|
33
35
|
end
|
34
36
|
|
35
37
|
end
|
@@ -4,11 +4,11 @@ require 'approvals/rspec'
|
|
4
4
|
describe Approvals::Namers::DirectoryNamer do
|
5
5
|
|
6
6
|
it "uses non-$%^&*funky example description" do |example|
|
7
|
-
Approvals::Namers::DirectoryNamer.new(example).name.
|
7
|
+
expect(Approvals::Namers::DirectoryNamer.new(example).name).to eq 'approvals_namers_directorynamer/uses_non_funky_example_description'
|
8
8
|
end
|
9
9
|
|
10
10
|
it "has a decent default" do |example|
|
11
|
-
Approvals::Namers::DirectoryNamer.new(example).output_dir.
|
11
|
+
expect(Approvals::Namers::DirectoryNamer.new(example).output_dir).to eq 'spec/fixtures/approvals/'
|
12
12
|
end
|
13
13
|
|
14
14
|
context "when RSpec is configured" do
|
@@ -25,7 +25,7 @@ describe Approvals::Namers::DirectoryNamer do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it "uses the rspec config option" do |example|
|
28
|
-
Approvals::Namers::DirectoryNamer.new(example).output_dir.
|
28
|
+
expect(Approvals::Namers::DirectoryNamer.new(example).output_dir).to eq 'spec/output/dir/'
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -3,11 +3,11 @@ require 'spec_helper'
|
|
3
3
|
describe Approvals::Namers::RSpecNamer do
|
4
4
|
|
5
5
|
it "uses non-$%^&*funky example description" do |example|
|
6
|
-
Approvals::Namers::RSpecNamer.new(example).name.
|
6
|
+
expect(Approvals::Namers::RSpecNamer.new(example).name).to eq 'approvals_namers_rspecnamer_uses_non_funky_example_description'
|
7
7
|
end
|
8
8
|
|
9
9
|
it "has a decent default" do |example|
|
10
|
-
Approvals::Namers::RSpecNamer.new(example).output_dir.
|
10
|
+
expect(Approvals::Namers::RSpecNamer.new(example).output_dir).to eq 'spec/fixtures/approvals/'
|
11
11
|
end
|
12
12
|
|
13
13
|
context "when RSpec is configured" do
|
@@ -24,7 +24,7 @@ describe Approvals::Namers::RSpecNamer do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it "uses the rspec config option" do |example|
|
27
|
-
Approvals::Namers::RSpecNamer.new(example).output_dir.
|
27
|
+
expect(Approvals::Namers::RSpecNamer.new(example).output_dir).to eq 'spec/output/dir/'
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
data/spec/namers_spec.rb
CHANGED
@@ -5,12 +5,12 @@ describe Approvals::Namers do
|
|
5
5
|
|
6
6
|
it "uses the RSpecNamer" do |example|
|
7
7
|
approval = Approvals::Approval.new("naming with rspec namer", :namer => Approvals::Namers::RSpecNamer.new(example))
|
8
|
-
approval.name.
|
8
|
+
expect(approval.name).to eq("approvals_namers_uses_the_rspecnamer")
|
9
9
|
end
|
10
10
|
|
11
11
|
it "uses the DefaultNamer" do
|
12
12
|
approval = Approvals::Approval.new("naming with default namer", :name => "a name")
|
13
|
-
approval.name.
|
13
|
+
expect(approval.name).to eq("a_name")
|
14
14
|
end
|
15
15
|
|
16
16
|
end
|
@@ -10,20 +10,20 @@ describe Approvals::Reporters::FirstWorkingReporter do
|
|
10
10
|
|
11
11
|
it "when at least one reporter works it is working" do
|
12
12
|
reporter = Approvals::Reporters::FirstWorkingReporter.new(no, yes)
|
13
|
-
reporter.
|
13
|
+
expect(reporter).to be_working_in_this_environment
|
14
14
|
end
|
15
15
|
|
16
16
|
it "when no reporters work it's not working" do
|
17
17
|
reporter = Approvals::Reporters::FirstWorkingReporter.new(no, no)
|
18
|
-
reporter.
|
18
|
+
expect(reporter).not_to be_working_in_this_environment
|
19
19
|
end
|
20
20
|
|
21
21
|
it "calls the first working reporter" do
|
22
22
|
working = Approvals::Reporters::FirstWorkingReporter.new(no, yes, yes_too)
|
23
23
|
|
24
|
-
no.
|
25
|
-
yes.
|
26
|
-
yes_too.
|
24
|
+
expect(no).not_to receive(:report)
|
25
|
+
expect(yes).to receive(:report)
|
26
|
+
expect(yes_too).not_to receive(:report)
|
27
27
|
|
28
28
|
working.report("r", "a")
|
29
29
|
end
|
@@ -8,7 +8,7 @@ describe Approvals::Reporters::HtmlImageReporter do
|
|
8
8
|
|
9
9
|
it "creates the template" do
|
10
10
|
scrubber = Approvals::Scrubber.new(subject.html("spec/fixtures/one.png", "spec/fixtures/two.png"))
|
11
|
-
scrubber.to_s.
|
11
|
+
expect(scrubber.to_s).to eq('<html><head><title>Approval</title></head><body><center><table style="text-align: center;" border="1"><tr><td><img src="file://{{current_dir}}/spec/fixtures/one.png"></td><td><img src="file://{{current_dir}}/spec/fixtures/two.png"></td></tr><tr><td>received</td><td>approved</td></tr></table></center></body></html>')
|
12
12
|
end
|
13
13
|
|
14
14
|
# verify "creates the appropriate command", :format => :html do
|
@@ -2,25 +2,23 @@ require 'spec_helper'
|
|
2
2
|
require 'approvals/reporters/launcher'
|
3
3
|
|
4
4
|
describe Approvals::Reporters::Launcher do
|
5
|
-
|
6
|
-
|
7
5
|
it "has a vimdiff launcher" do
|
8
|
-
|
6
|
+
expect(described_class.vimdiff.call('one', 'two')).to eq("vimdiff one two")
|
9
7
|
end
|
10
8
|
|
11
9
|
it "has an opendiff launcher" do
|
12
|
-
|
10
|
+
expect(described_class.opendiff.call('one', 'two')).to eq("opendiff one two")
|
13
11
|
end
|
14
12
|
|
15
13
|
it "has a diffmerge launcher" do
|
16
|
-
|
14
|
+
expect(described_class.diffmerge.call('one', 'two')).to match(/DiffMerge.*\"one\"\ \"two\"/)
|
17
15
|
end
|
18
16
|
|
19
17
|
it "has a tortoisediff launcher" do
|
20
|
-
|
18
|
+
expect(described_class.tortoisediff.call('one', 'two')).to match(/TortoiseMerge.exe.*one.*two/)
|
21
19
|
end
|
22
20
|
|
23
21
|
it "has a filelauncher launcher" do
|
24
|
-
|
22
|
+
expect(described_class.filelauncher.call('one', 'two')).to eq("open one")
|
25
23
|
end
|
26
24
|
end
|
@@ -4,7 +4,7 @@ require 'approvals/reporters'
|
|
4
4
|
describe Approvals::Reporters::Reporter do
|
5
5
|
|
6
6
|
it "is not approved by default" do
|
7
|
-
Approvals::Reporters::Reporter.new.
|
7
|
+
expect(Approvals::Reporters::Reporter.new).not_to be_approved_when_reported
|
8
8
|
end
|
9
9
|
|
10
10
|
it "takes a launcher" do
|
@@ -12,10 +12,10 @@ describe Approvals::Reporters::Reporter do
|
|
12
12
|
"echo \"mv #{received} #{approved}\""
|
13
13
|
}
|
14
14
|
|
15
|
-
Approvals::Reporters::Reporter.new(&move).launcher.call('received.txt', 'approved.txt').
|
15
|
+
expect(Approvals::Reporters::Reporter.new(&move).launcher.call('received.txt', 'approved.txt')).to eq("echo \"mv received.txt approved.txt\"")
|
16
16
|
end
|
17
17
|
|
18
18
|
it "defaults to the default OpenDiff launcher" do
|
19
|
-
Approvals::Reporters::Reporter.new.launcher.
|
19
|
+
expect(Approvals::Reporters::Reporter.new.launcher).to eq(Approvals::Reporters::Launcher.opendiff)
|
20
20
|
end
|
21
21
|
end
|
data/spec/scrubber_spec.rb
CHANGED
@@ -8,19 +8,19 @@ describe Approvals::Scrubber do
|
|
8
8
|
subject { Approvals::Scrubber.new("I am currently at #{path}") }
|
9
9
|
|
10
10
|
it "has a sensible to_s" do
|
11
|
-
subject.to_s.
|
11
|
+
expect(subject.to_s).to eq("I am currently at {{current_dir}}")
|
12
12
|
end
|
13
13
|
|
14
14
|
it "unscrubs" do
|
15
|
-
subject.unscrub.
|
15
|
+
expect(subject.unscrub).to eq("I am currently at #{path}")
|
16
16
|
end
|
17
17
|
|
18
18
|
it "unscrubs any old string" do
|
19
|
-
subject.unscrub("Hoy, where's {{current_dir}}?").
|
19
|
+
expect(subject.unscrub("Hoy, where's {{current_dir}}?")).to eq("Hoy, where's #{path}?")
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
it "overrides default hash" do
|
24
|
-
Approvals::Scrubber.new("oh, my GAWD", {"deity" => "GAWD"}).to_s.
|
24
|
+
expect(Approvals::Scrubber.new("oh, my GAWD", {"deity" => "GAWD"}).to_s).to eq('oh, my {{deity}}')
|
25
25
|
end
|
26
26
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/system_command_spec.rb
CHANGED
@@ -4,10 +4,10 @@ require 'approvals/system_command'
|
|
4
4
|
describe Approvals::SystemCommand, "#exists?" do
|
5
5
|
|
6
6
|
it "does" do
|
7
|
-
Approvals::SystemCommand.exists?("ls").
|
7
|
+
expect(Approvals::SystemCommand.exists?("ls")).to be_truthy
|
8
8
|
end
|
9
9
|
|
10
10
|
it "does not" do
|
11
|
-
Approvals::SystemCommand.exists?("absolutelydoesnotexistonyoursystem").
|
11
|
+
expect(Approvals::SystemCommand.exists?("absolutelydoesnotexistonyoursystem")).to be_falsey
|
12
12
|
end
|
13
13
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: approvals
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Katrina Owen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '3.1'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '3.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -204,3 +204,4 @@ signing_key:
|
|
204
204
|
specification_version: 4
|
205
205
|
summary: Approval Tests for Ruby
|
206
206
|
test_files: []
|
207
|
+
has_rdoc:
|