approvals 0.0.1 → 0.0.2
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.
- data/.travis.yml +1 -0
- data/README.md +3 -5
- data/TODO +1 -2
- data/approvals.gemspec +1 -1
- data/bin/approvals +0 -1
- data/lib/approvals.rb +1 -0
- data/lib/approvals/approval.rb +4 -2
- data/lib/approvals/configuration.rb +1 -1
- data/lib/approvals/reporters.rb +11 -0
- data/lib/approvals/reporters/diff_reporter/diffmerge_reporter.rb +18 -0
- data/lib/approvals/reporters/diff_reporter/opendiff_reporter.rb +18 -0
- data/lib/approvals/reporters/diff_reporter/tortoisediff_reporter.rb +18 -0
- data/lib/approvals/reporters/diff_reporter/vimdiff_reporter.rb +18 -0
- data/lib/approvals/reporters/filelauncher_reporter.rb +18 -0
- data/lib/approvals/reporters/image_reporter.rb +0 -3
- data/lib/approvals/reporters/image_reporter/image_magick_reporter.rb +1 -1
- data/lib/approvals/reporters/launcher.rb +49 -0
- data/lib/approvals/reporters/reporter.rb +30 -0
- data/lib/approvals/utilities/cli.rb +3 -2
- data/lib/approvals/writer.rb +1 -0
- data/lib/approvals/writers/hash_writer.rb +16 -0
- data/lib/approvals/writers/text_writer.rb +1 -1
- data/spec/approvals_spec.rb +10 -0
- data/spec/configuration_spec.rb +2 -2
- data/spec/fixtures/approvals/approvals_fails.approved.txt +0 -0
- data/spec/fixtures/approvals/approvals_verifies_a_complex_object.approved.txt +1 -1
- data/spec/fixtures/approvals/approvals_verifies_a_hash.approved.txt +6 -0
- data/spec/fixtures/approvals/approvals_verifies_a_string.approved.txt +1 -1
- data/spec/fixtures/approvals/verifies_a_complex_object.approved.txt +1 -1
- data/spec/fixtures/approvals/verifies_a_string.approved.txt +1 -1
- data/spec/fixtures/one.txt +1 -0
- data/spec/fixtures/two.txt +1 -0
- data/spec/namers/default_namer_spec.rb +2 -3
- data/spec/namers/rspec_namer_spec.rb +3 -4
- data/spec/namers_spec.rb +1 -2
- data/spec/reporters/first_working_reporter_spec.rb +4 -4
- data/spec/reporters/html_image_reporter_spec.rb +2 -3
- data/spec/reporters/image_magick_reporter_spec.rb +1 -2
- data/spec/reporters/launcher_spec.rb +25 -0
- data/spec/reporters/opendiff_reporter_spec.rb +15 -0
- data/spec/reporters/reporter_spec.rb +20 -0
- data/spec/utilities/dotfile_spec.rb +5 -6
- data/spec/utilities/executable_spec.rb +2 -3
- data/spec/utilities/scrubber_spec.rb +2 -3
- data/spec/utilities/system_command_spec.rb +2 -3
- metadata +24 -10
- data/lib/approvals/writers.rb +0 -5
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -14,7 +14,7 @@ See [ApprovalTests](http://www.approvaltests.com) for videos and additional docu
|
|
14
14
|
Also, check out Herding Code's [podcast #117](http://t.co/GLn88R5) in
|
15
15
|
which Llewellyn Falco is interviewed about approvals.
|
16
16
|
|
17
|
-
[](http://travis-ci.org/kytrinyx/approvals)
|
18
18
|
|
19
19
|
## Configuration
|
20
20
|
|
@@ -32,14 +32,12 @@ The default location for the output files is
|
|
32
32
|
|
33
33
|
This will raise an `ApprovalError` in the case of a failure.
|
34
34
|
|
35
|
-
The `:
|
35
|
+
The default writer uses the `:to_s` method on the subject will be used to generate the output for
|
36
36
|
the `received` file. For custom complex objects you will need to override
|
37
|
-
`:to_s`
|
37
|
+
`:to_s` to get helpful output, rather than the default:
|
38
38
|
|
39
39
|
#<Object:0x0000010105ea40> # or whatever the object id is
|
40
40
|
|
41
|
-
Note: `:inspect` uses `:to_s` unless it has been specifically defined to do something else.
|
42
|
-
|
43
41
|
The first time the approval is run, a file will be created with the contents of the subject of your approval:
|
44
42
|
|
45
43
|
the_name_of_the_approval.received.txt # or .json, .html, .xml as appropriate
|
data/TODO
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
[ ] add
|
2
|
-
Approvals.verify(something, :name => 'the name of this test')
|
1
|
+
[ ] add cucumber support (namer + extension + features)
|
data/approvals.gemspec
CHANGED
data/bin/approvals
CHANGED
data/lib/approvals.rb
CHANGED
data/lib/approvals/approval.rb
CHANGED
@@ -56,13 +56,15 @@ module Approvals
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def fail_with(message)
|
59
|
+
FileUtils.touch(approved_path) unless File.exists? approved_path
|
60
|
+
|
61
|
+
Dotfile.append(diff_path)
|
62
|
+
|
59
63
|
if subject.respond_to?(:on_failure)
|
60
64
|
subject.on_failure.call(approved_text) if approved?
|
61
65
|
subject.on_failure.call(received_text)
|
62
66
|
end
|
63
67
|
|
64
|
-
Dotfile.append(diff_path)
|
65
|
-
|
66
68
|
raise ApprovalError.new("Approval Error: #{message}")
|
67
69
|
end
|
68
70
|
|
data/lib/approvals/reporters.rb
CHANGED
@@ -1,3 +1,14 @@
|
|
1
1
|
require 'singleton'
|
2
2
|
require 'approvals/reporters/first_working_reporter'
|
3
|
+
|
3
4
|
require 'approvals/reporters/image_reporter'
|
5
|
+
require 'approvals/reporters/image_reporter/image_magick_reporter'
|
6
|
+
require 'approvals/reporters/image_reporter/html_image_reporter'
|
7
|
+
|
8
|
+
require 'approvals/reporters/launcher'
|
9
|
+
require 'approvals/reporters/reporter'
|
10
|
+
require 'approvals/reporters/diff_reporter/opendiff_reporter'
|
11
|
+
require 'approvals/reporters/diff_reporter/vimdiff_reporter'
|
12
|
+
require 'approvals/reporters/diff_reporter/diffmerge_reporter'
|
13
|
+
require 'approvals/reporters/diff_reporter/tortoisediff_reporter'
|
14
|
+
require 'approvals/reporters/filelauncher_reporter'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Approvals
|
2
|
+
module Reporters
|
3
|
+
class DiffmergeReporter < Reporter
|
4
|
+
include Singleton
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def report(received, approved)
|
8
|
+
self.instance.report(received, approved)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def default_launcher
|
13
|
+
Launcher.diffmerge
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Approvals
|
2
|
+
module Reporters
|
3
|
+
class OpendiffReporter < Reporter
|
4
|
+
include Singleton
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def report(received, approved)
|
8
|
+
self.instance.report(received, approved)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def default_launcher
|
13
|
+
Launcher.opendiff
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Approvals
|
2
|
+
module Reporters
|
3
|
+
class TortoisediffReporter < Reporter
|
4
|
+
include Singleton
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def report(received, approved)
|
8
|
+
self.instance.report(received, approved)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def default_launcher
|
13
|
+
Launcher.tortoisediff
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Approvals
|
2
|
+
module Reporters
|
3
|
+
class VimdiffReporter < Reporter
|
4
|
+
include Singleton
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def report(received, approved)
|
8
|
+
self.instance.report(received, approved)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def default_launcher
|
13
|
+
Launcher.vimdiff
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Approvals
|
2
|
+
module Reporters
|
3
|
+
class FilelauncherReporter < Reporter
|
4
|
+
include Singleton
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def report(received, approved = nil)
|
8
|
+
self.instance.report(received, approved)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def default_launcher
|
13
|
+
Launcher.filelauncher
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
|
2
|
+
module Approvals
|
3
|
+
module Reporters
|
4
|
+
module Launcher
|
5
|
+
|
6
|
+
class << self
|
7
|
+
REPORTERS = [:opendiff, :diffmerge, :vimdiff, :tortoisediff, :filelauncher]
|
8
|
+
|
9
|
+
def memoized(instance_variable)
|
10
|
+
unless self.instance_variable_get(instance_variable)
|
11
|
+
value = yield
|
12
|
+
self.instance_variable_set(instance_variable, value)
|
13
|
+
end
|
14
|
+
self.instance_variable_get(instance_variable)
|
15
|
+
end
|
16
|
+
|
17
|
+
REPORTERS.each do |name|
|
18
|
+
define_method name do
|
19
|
+
memoized(:"@#{name}") do
|
20
|
+
lambda {|received, approved|
|
21
|
+
self.send("#{name}_command".to_sym, received, approved)
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def opendiff_command(received, approved)
|
28
|
+
"opendiff #{received} #{approved}"
|
29
|
+
end
|
30
|
+
|
31
|
+
def diffmerge_command(received, approved)
|
32
|
+
"/Applications/DiffMerge.app/Contents/MacOS/DiffMerge --nosplash \"#{received}\" \"#{approved}\""
|
33
|
+
end
|
34
|
+
|
35
|
+
def vimdiff_command(received, approved)
|
36
|
+
"vimdiff #{received} #{approved}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def tortoisediff_command(received, approved)
|
40
|
+
"C:\\Program Files\\TortoiseSVN\\bin\\TortoiseMerge.exe #{received} #{approved}"
|
41
|
+
end
|
42
|
+
|
43
|
+
def filelauncher_command(received, approved)
|
44
|
+
"open #{received}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Approvals
|
2
|
+
module Reporters
|
3
|
+
class Reporter
|
4
|
+
|
5
|
+
attr_reader :launcher
|
6
|
+
|
7
|
+
def initialize(&launcher)
|
8
|
+
@launcher = launcher || default_launcher
|
9
|
+
end
|
10
|
+
|
11
|
+
def report(received, approved)
|
12
|
+
launch(received, approved)
|
13
|
+
end
|
14
|
+
|
15
|
+
def approved_when_reported?
|
16
|
+
false
|
17
|
+
end
|
18
|
+
|
19
|
+
def default_launcher
|
20
|
+
Launcher.opendiff
|
21
|
+
end
|
22
|
+
|
23
|
+
protected
|
24
|
+
|
25
|
+
def launch(received, approved)
|
26
|
+
exec launcher.call(received, approved)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# don't require the approvals library here, as it will reset the dotfile.
|
2
|
+
# or find a better way to reset the dotfile before a run.
|
1
3
|
module Approvals
|
2
4
|
class CLI < Thor
|
3
5
|
|
@@ -5,7 +7,6 @@ module Approvals
|
|
5
7
|
method_option :diff, :type => :string, :default => 'vimdiff', :aliases => '-d', :desc => 'The difftool to use'
|
6
8
|
method_option :ask, :type => :boolean, :default => false, :aliases => "-a", :desc => 'Offer to approve the received file for you.'
|
7
9
|
def verify
|
8
|
-
|
9
10
|
approvals = File.read('.approvals').split("\n")
|
10
11
|
|
11
12
|
rejected = []
|
@@ -13,7 +14,7 @@ module Approvals
|
|
13
14
|
system("#{options[:diff]} #{approval}")
|
14
15
|
|
15
16
|
if options[:ask] && yes?("Approve?")
|
16
|
-
|
17
|
+
system("mv #{approval}")
|
17
18
|
else
|
18
19
|
rejected << approval
|
19
20
|
end
|
data/lib/approvals/writer.rb
CHANGED
data/spec/approvals_spec.rb
CHANGED
@@ -24,6 +24,16 @@ describe Approvals do
|
|
24
24
|
Approvals.verify array, :namer => namer
|
25
25
|
end
|
26
26
|
|
27
|
+
it "verifies a hash" do
|
28
|
+
hash = {
|
29
|
+
:meal => 'breakfast',
|
30
|
+
:proteins => '90%',
|
31
|
+
:price => 38,
|
32
|
+
:delicious => true
|
33
|
+
}
|
34
|
+
Approvals.verify hash, :namer => namer
|
35
|
+
end
|
36
|
+
|
27
37
|
it "verifies a complex object" do
|
28
38
|
hello = Object.new
|
29
39
|
def hello.to_s
|
data/spec/configuration_spec.rb
CHANGED
@@ -2,8 +2,8 @@ require 'approvals/configuration'
|
|
2
2
|
|
3
3
|
describe Approvals::Configuration do
|
4
4
|
|
5
|
-
it "defaults to 'approvals/'" do
|
6
|
-
Approvals.configuration.approvals_path.should eq('approvals/')
|
5
|
+
it "defaults to 'fixtures/approvals/'" do
|
6
|
+
Approvals.configuration.approvals_path.should eq('fixtures/approvals/')
|
7
7
|
end
|
8
8
|
|
9
9
|
describe "when set" do
|
File without changes
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Hello, World!
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
We have, I fear, confused power with greatness.
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Hello, World!
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
We have, I fear, confused power with greatness.
|
@@ -0,0 +1 @@
|
|
1
|
+
one
|
@@ -0,0 +1 @@
|
|
1
|
+
two
|
@@ -2,9 +2,8 @@ require 'approvals/configuration'
|
|
2
2
|
require 'approvals/namers/default_namer'
|
3
3
|
|
4
4
|
describe Approvals::Namers::DefaultNamer do
|
5
|
-
include Approvals::Namers
|
6
5
|
|
7
|
-
subject { DefaultNamer.new("a f!$^%&*(unky name") }
|
6
|
+
subject { Approvals::Namers::DefaultNamer.new("a f!$^%&*(unky name") }
|
8
7
|
|
9
8
|
it "normalizes the name" do
|
10
9
|
subject.name.should eq("a_funky_name")
|
@@ -29,7 +28,7 @@ describe Approvals::Namers::DefaultNamer do
|
|
29
28
|
end
|
30
29
|
|
31
30
|
it "must have a name" do
|
32
|
-
->{ DefaultNamer.new(nil) }.should raise_error(ArgumentError)
|
31
|
+
->{ Approvals::Namers::DefaultNamer.new(nil) }.should raise_error(ArgumentError)
|
33
32
|
end
|
34
33
|
|
35
34
|
end
|
@@ -1,14 +1,13 @@
|
|
1
1
|
require 'approvals'
|
2
2
|
|
3
3
|
describe Approvals::Namers::RSpecNamer do
|
4
|
-
include Approvals::Namers
|
5
4
|
|
6
5
|
it "uses non-$%^&*funky example description" do
|
7
|
-
RSpecNamer.new(self.example).name.should eq("approvals_namers_rspecnamer_uses_non_funky_example_description")
|
6
|
+
Approvals::Namers::RSpecNamer.new(self.example).name.should eq("approvals_namers_rspecnamer_uses_non_funky_example_description")
|
8
7
|
end
|
9
8
|
|
10
9
|
it "has a decent default" do
|
11
|
-
RSpecNamer.new(self.example).output_dir.should eq('spec/fixtures/approvals/')
|
10
|
+
Approvals::Namers::RSpecNamer.new(self.example).output_dir.should eq('spec/fixtures/approvals/')
|
12
11
|
end
|
13
12
|
|
14
13
|
context "when RSpec is configured" do
|
@@ -25,7 +24,7 @@ describe Approvals::Namers::RSpecNamer do
|
|
25
24
|
end
|
26
25
|
|
27
26
|
it "uses the rspec config option" do
|
28
|
-
RSpecNamer.new(self.example).output_dir.should eq('spec/output/dir/')
|
27
|
+
Approvals::Namers::RSpecNamer.new(self.example).output_dir.should eq('spec/output/dir/')
|
29
28
|
end
|
30
29
|
end
|
31
30
|
end
|
data/spec/namers_spec.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
require 'approvals'
|
2
2
|
|
3
3
|
describe Approvals::Namers do
|
4
|
-
include Approvals::Namers
|
5
4
|
|
6
5
|
it "uses the RSpecNamer" do
|
7
|
-
approval = Approvals::Approval.new("naming with rspec namer", :namer => RSpecNamer.new(self.example))
|
6
|
+
approval = Approvals::Approval.new("naming with rspec namer", :namer => Approvals::Namers::RSpecNamer.new(self.example))
|
8
7
|
approval.name.should eq("approvals_namers_uses_the_rspecnamer")
|
9
8
|
end
|
10
9
|
|
@@ -1,24 +1,24 @@
|
|
1
1
|
require 'approvals/reporters/first_working_reporter'
|
2
2
|
|
3
3
|
describe Approvals::Reporters::FirstWorkingReporter do
|
4
|
-
|
4
|
+
|
5
5
|
|
6
6
|
let(:no) { stub(:working_in_this_environment? => false) }
|
7
7
|
let(:yes) { stub(:working_in_this_environment? => true) }
|
8
8
|
let(:yes_too) { stub(:working_in_this_environment? => true) }
|
9
9
|
|
10
10
|
context "when at least one reporter works" do
|
11
|
-
subject { FirstWorkingReporter.new(no, yes) }
|
11
|
+
subject { Approvals::Reporters::FirstWorkingReporter.new(no, yes) }
|
12
12
|
its(:working_in_this_environment?) { should be_true }
|
13
13
|
end
|
14
14
|
|
15
15
|
context "when no reporters work" do
|
16
|
-
subject { FirstWorkingReporter.new(no, no) }
|
16
|
+
subject { Approvals::Reporters::FirstWorkingReporter.new(no, no) }
|
17
17
|
its(:working_in_this_environment?) { should be_false }
|
18
18
|
end
|
19
19
|
|
20
20
|
it "calls the first working reporter" do
|
21
|
-
working = FirstWorkingReporter.new(no, yes, yes_too)
|
21
|
+
working = Approvals::Reporters::FirstWorkingReporter.new(no, yes, yes_too)
|
22
22
|
|
23
23
|
no.should_not_receive(:report)
|
24
24
|
yes.should_receive(:report)
|
@@ -2,12 +2,11 @@ require 'approvals/reporters'
|
|
2
2
|
require 'approvals/utilities/scrubber'
|
3
3
|
|
4
4
|
describe Approvals::Reporters::HtmlImageReporter do
|
5
|
-
include Approvals
|
6
5
|
|
7
|
-
subject { Reporters::HtmlImageReporter.instance }
|
6
|
+
subject { Approvals::Reporters::HtmlImageReporter.instance }
|
8
7
|
|
9
8
|
it "creates the template" do
|
10
|
-
scrubber = Scrubber.new(subject.html("spec/fixtures/one.png", "spec/fixtures/two.png"))
|
9
|
+
scrubber = Approvals::Scrubber.new(subject.html("spec/fixtures/one.png", "spec/fixtures/two.png"))
|
11
10
|
scrubber.to_s.should 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
11
|
end
|
13
12
|
|
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'approvals/reporters'
|
2
2
|
|
3
3
|
describe Approvals::Reporters::ImageMagickReporter do
|
4
|
-
|
5
|
-
subject { ImageMagickReporter.instance }
|
4
|
+
subject { Approvals::Reporters::ImageMagickReporter.instance }
|
6
5
|
|
7
6
|
it "creates the appropriate command" do
|
8
7
|
result = subject.create_command_line("spec/fixtures/one.png", "spec/fixtures/two.png")
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'approvals/reporters/launcher'
|
2
|
+
|
3
|
+
describe Approvals::Reporters::Launcher do
|
4
|
+
|
5
|
+
|
6
|
+
it "has a vimdiff launcher" do
|
7
|
+
Approvals::Reporters::Launcher.vimdiff.call('one', 'two').should eq("vimdiff one two")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "has an opendiff launcher" do
|
11
|
+
Approvals::Reporters::Launcher.opendiff.call('one', 'two').should eq("opendiff one two")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "has a diffmerge launcher" do
|
15
|
+
Approvals::Reporters::Launcher.diffmerge.call('one', 'two').should match(/DiffMerge.*\"one\"\ \"two\"/)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "has a tortoisediff launcher" do
|
19
|
+
Approvals::Reporters::Launcher.tortoisediff.call('one', 'two').should match(/TortoiseMerge.exe.*one.*two/)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "has a filelauncher launcher" do
|
23
|
+
Approvals::Reporters::Launcher.filelauncher.call('one', 'two').should eq("open one")
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'approvals'
|
2
|
+
|
3
|
+
describe Approvals::Reporters::OpendiffReporter do
|
4
|
+
|
5
|
+
it "has a nice launcher" do
|
6
|
+
pending "Breaks off execution of the tests. Horrible."
|
7
|
+
one = 'spec/fixtures/one.txt'
|
8
|
+
two = 'spec/fixtures/two.txt'
|
9
|
+
executable = Approvals::Executable.new(Approvals::Reporters::OpendiffReporter.instance.launcher.call(one, two)) do |command|
|
10
|
+
Approvals::Reporters::OpendiffReporter.report(one, two)
|
11
|
+
end
|
12
|
+
|
13
|
+
Approvals.verify(executable, :name => 'opendiff launcher')
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'approvals/reporters'
|
2
|
+
|
3
|
+
describe Approvals::Reporters::Reporter do
|
4
|
+
|
5
|
+
it "is not approved by default" do
|
6
|
+
Approvals::Reporters::Reporter.new.should_not be_approved_when_reported
|
7
|
+
end
|
8
|
+
|
9
|
+
it "takes a launcher" do
|
10
|
+
move = lambda {|received, approved|
|
11
|
+
"echo \"mv #{received} #{approved}\""
|
12
|
+
}
|
13
|
+
|
14
|
+
Approvals::Reporters::Reporter.new(&move).launcher.call('received.txt', 'approved.txt').should eq("echo \"mv received.txt approved.txt\"")
|
15
|
+
end
|
16
|
+
|
17
|
+
it "defaults to the default OpenDiff launcher" do
|
18
|
+
Approvals::Reporters::Reporter.new.launcher.should eq(Approvals::Reporters::Launcher.opendiff)
|
19
|
+
end
|
20
|
+
end
|
@@ -1,22 +1,21 @@
|
|
1
1
|
require 'approvals/utilities/dotfile'
|
2
2
|
|
3
3
|
describe Approvals::Dotfile do
|
4
|
-
include Approvals
|
5
4
|
let(:dotfile) { '/tmp/.approvals' }
|
6
5
|
|
7
6
|
before(:each) do
|
8
|
-
Dotfile.stub(:path => dotfile)
|
9
|
-
Dotfile.reset
|
7
|
+
Approvals::Dotfile.stub(:path => dotfile)
|
8
|
+
Approvals::Dotfile.reset
|
10
9
|
end
|
11
10
|
|
12
11
|
it "appends the text" do
|
13
|
-
Dotfile.append('text')
|
12
|
+
Approvals::Dotfile.append('text')
|
14
13
|
File.readlines(dotfile).map(&:chomp).should eq(['text'])
|
15
14
|
end
|
16
15
|
|
17
16
|
it "appends the text exactly once" do
|
18
|
-
Dotfile.append('text')
|
19
|
-
Dotfile.append('text')
|
17
|
+
Approvals::Dotfile.append('text')
|
18
|
+
Approvals::Dotfile.append('text')
|
20
19
|
File.readlines(dotfile).map(&:chomp).should eq(['text'])
|
21
20
|
end
|
22
21
|
end
|
@@ -1,13 +1,12 @@
|
|
1
1
|
require 'approvals/utilities/executable'
|
2
2
|
|
3
3
|
describe Approvals::Executable do
|
4
|
-
include Approvals
|
5
4
|
|
6
|
-
subject { Executable.new('SELECT 1') }
|
5
|
+
subject { Approvals::Executable.new('SELECT 1') }
|
7
6
|
its(:inspect) { should eq('SELECT 1') }
|
8
7
|
|
9
8
|
it "takes a block" do
|
10
|
-
executable = Executable.new('SELECT 1') do |command|
|
9
|
+
executable = Approvals::Executable.new('SELECT 1') do |command|
|
11
10
|
"execute query: #{command}"
|
12
11
|
end
|
13
12
|
executable.on_failure.call('SELECT 1').should eq('execute query: SELECT 1')
|
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'approvals/utilities/scrubber'
|
2
2
|
|
3
3
|
describe Approvals::Scrubber do
|
4
|
-
include Approvals
|
5
4
|
|
6
5
|
describe "defaults" do
|
7
6
|
let(:path) { File.expand_path('.') }
|
8
|
-
subject { Scrubber.new("I am currently at #{path}") }
|
7
|
+
subject { Approvals::Scrubber.new("I am currently at #{path}") }
|
9
8
|
|
10
9
|
its(:to_s) { should eq("I am currently at {{current_dir}}") }
|
11
10
|
|
@@ -19,6 +18,6 @@ describe Approvals::Scrubber do
|
|
19
18
|
end
|
20
19
|
|
21
20
|
it "overrides default hash" do
|
22
|
-
Scrubber.new("oh, my GAWD", {"deity" => "GAWD"}).to_s.should eq('oh, my {{deity}}')
|
21
|
+
Approvals::Scrubber.new("oh, my GAWD", {"deity" => "GAWD"}).to_s.should eq('oh, my {{deity}}')
|
23
22
|
end
|
24
23
|
end
|
@@ -1,13 +1,12 @@
|
|
1
1
|
require 'approvals/utilities/system_command'
|
2
2
|
|
3
3
|
describe Approvals::SystemCommand, "#exists?" do
|
4
|
-
include Approvals
|
5
4
|
|
6
5
|
it "does" do
|
7
|
-
SystemCommand.exists?("ls").should be_true
|
6
|
+
Approvals::SystemCommand.exists?("ls").should be_true
|
8
7
|
end
|
9
8
|
|
10
9
|
it "does not" do
|
11
|
-
SystemCommand.exists?("absolutelydoesnotexistonyoursystem").should be_false
|
10
|
+
Approvals::SystemCommand.exists?("absolutelydoesnotexistonyoursystem").should be_false
|
12
11
|
end
|
13
12
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70196756887140 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '2.7'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70196756887140
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: thor
|
27
|
-
requirement: &
|
27
|
+
requirement: &70196756886080 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70196756886080
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: nokogiri
|
38
|
-
requirement: &
|
38
|
+
requirement: &70196756885140 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70196756885140
|
47
47
|
description: Approval Tests for Ruby
|
48
48
|
email:
|
49
49
|
- katrina.owen@gmail.com
|
@@ -73,10 +73,17 @@ files:
|
|
73
73
|
- lib/approvals/namers/default_namer.rb
|
74
74
|
- lib/approvals/namers/rspec_namer.rb
|
75
75
|
- lib/approvals/reporters.rb
|
76
|
+
- lib/approvals/reporters/diff_reporter/diffmerge_reporter.rb
|
77
|
+
- lib/approvals/reporters/diff_reporter/opendiff_reporter.rb
|
78
|
+
- lib/approvals/reporters/diff_reporter/tortoisediff_reporter.rb
|
79
|
+
- lib/approvals/reporters/diff_reporter/vimdiff_reporter.rb
|
80
|
+
- lib/approvals/reporters/filelauncher_reporter.rb
|
76
81
|
- lib/approvals/reporters/first_working_reporter.rb
|
77
82
|
- lib/approvals/reporters/image_reporter.rb
|
78
83
|
- lib/approvals/reporters/image_reporter/html_image_reporter.rb
|
79
84
|
- lib/approvals/reporters/image_reporter/image_magick_reporter.rb
|
85
|
+
- lib/approvals/reporters/launcher.rb
|
86
|
+
- lib/approvals/reporters/reporter.rb
|
80
87
|
- lib/approvals/utilities.rb
|
81
88
|
- lib/approvals/utilities/cli.rb
|
82
89
|
- lib/approvals/utilities/dotfile.rb
|
@@ -84,8 +91,8 @@ files:
|
|
84
91
|
- lib/approvals/utilities/scrubber.rb
|
85
92
|
- lib/approvals/utilities/system_command.rb
|
86
93
|
- lib/approvals/writer.rb
|
87
|
-
- lib/approvals/writers.rb
|
88
94
|
- lib/approvals/writers/array_writer.rb
|
95
|
+
- lib/approvals/writers/hash_writer.rb
|
89
96
|
- lib/approvals/writers/html_writer.rb
|
90
97
|
- lib/approvals/writers/json_writer.rb
|
91
98
|
- lib/approvals/writers/text_writer.rb
|
@@ -93,7 +100,9 @@ files:
|
|
93
100
|
- spec/approvals_spec.rb
|
94
101
|
- spec/configuration_spec.rb
|
95
102
|
- spec/extensions/rspec_approvals_spec.rb
|
103
|
+
- spec/fixtures/approvals/approvals_fails.approved.txt
|
96
104
|
- spec/fixtures/approvals/approvals_verifies_a_complex_object.approved.txt
|
105
|
+
- spec/fixtures/approvals/approvals_verifies_a_hash.approved.txt
|
97
106
|
- spec/fixtures/approvals/approvals_verifies_a_string.approved.txt
|
98
107
|
- spec/fixtures/approvals/approvals_verifies_an_array.approved.txt
|
99
108
|
- spec/fixtures/approvals/approvals_verifies_an_executable.approved.txt
|
@@ -109,13 +118,18 @@ files:
|
|
109
118
|
- spec/fixtures/approvals/verifies_json.approved.json
|
110
119
|
- spec/fixtures/approvals/verifies_xml.approved.xml
|
111
120
|
- spec/fixtures/one.png
|
121
|
+
- spec/fixtures/one.txt
|
112
122
|
- spec/fixtures/two.png
|
123
|
+
- spec/fixtures/two.txt
|
113
124
|
- spec/namers/default_namer_spec.rb
|
114
125
|
- spec/namers/rspec_namer_spec.rb
|
115
126
|
- spec/namers_spec.rb
|
116
127
|
- spec/reporters/first_working_reporter_spec.rb
|
117
128
|
- spec/reporters/html_image_reporter_spec.rb
|
118
129
|
- spec/reporters/image_magick_reporter_spec.rb
|
130
|
+
- spec/reporters/launcher_spec.rb
|
131
|
+
- spec/reporters/opendiff_reporter_spec.rb
|
132
|
+
- spec/reporters/reporter_spec.rb
|
119
133
|
- spec/utilities/dotfile_spec.rb
|
120
134
|
- spec/utilities/executable_spec.rb
|
121
135
|
- spec/utilities/scrubber_spec.rb
|
@@ -140,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
154
|
version: '0'
|
141
155
|
requirements: []
|
142
156
|
rubyforge_project: approvals
|
143
|
-
rubygems_version: 1.8.
|
157
|
+
rubygems_version: 1.8.15
|
144
158
|
signing_key:
|
145
159
|
specification_version: 3
|
146
160
|
summary: Approval Tests for Ruby
|