approvals 0.0.12 → 0.0.13

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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +20 -3
  3. data/README.md +47 -3
  4. data/approvals.gemspec +1 -1
  5. data/bin/approvals +1 -1
  6. data/lib/approvals.rb +5 -1
  7. data/lib/approvals/{utilities/dotfile.rb → dotfile.rb} +0 -0
  8. data/lib/approvals/{utilities/executable.rb → executable.rb} +0 -0
  9. data/lib/approvals/extensions/rspec/dsl.rb +11 -2
  10. data/lib/approvals/filter.rb +45 -0
  11. data/lib/approvals/{utilities/scrubber.rb → scrubber.rb} +0 -0
  12. data/lib/approvals/{utilities/system_command.rb → system_command.rb} +0 -0
  13. data/lib/approvals/version.rb +1 -1
  14. data/lib/approvals/writer.rb +8 -8
  15. data/lib/approvals/writers/array_writer.rb +5 -1
  16. data/lib/approvals/writers/binary_writer.rb +11 -15
  17. data/lib/approvals/writers/hash_writer.rb +6 -1
  18. data/lib/approvals/writers/json_writer.rb +10 -30
  19. data/lib/approvals/writers/text_writer.rb +0 -2
  20. data/lib/{approvals/utilities/cli.rb → cli.rb} +0 -0
  21. data/spec/approvals_spec.rb +19 -2
  22. data/spec/{utilities/dotfile_spec.rb → dotfile_spec.rb} +1 -1
  23. data/spec/{utilities/executable_spec.rb → executable_spec.rb} +5 -3
  24. data/spec/filter_spec.rb +89 -0
  25. data/spec/fixtures/approvals/{approvals_supports_excluded_keys_option_for_json_also_supports_an_array_of_hashes.approved.json → approvals_supports_excluded_keys_option_also_supports_an_array_of_hashes.approved.json} +0 -0
  26. data/spec/fixtures/approvals/approvals_supports_excluded_keys_option_supports_the_array_writer.approved.txt +1 -0
  27. data/spec/fixtures/approvals/approvals_supports_excluded_keys_option_supports_the_hash_writer.approved.txt +1 -0
  28. data/spec/fixtures/approvals/{approvals_supports_excluded_keys_option_for_json_verifies_json_with_excluded_keys.approved.json → approvals_supports_excluded_keys_option_verifies_json_with_excluded_keys.approved.json} +0 -0
  29. data/spec/fixtures/approvals/approvals_verifies_an_array_as_json_when_format_is_set_to_json.approved.json +10 -0
  30. data/spec/namers/directory_namer_spec.rb +6 -6
  31. data/spec/namers/rspec_namer_spec.rb +6 -6
  32. data/spec/namers_spec.rb +2 -2
  33. data/spec/reporters/first_working_reporter_spec.rb +6 -6
  34. data/spec/reporters/html_image_reporter_spec.rb +1 -1
  35. data/spec/reporters/opendiff_reporter_spec.rb +1 -1
  36. data/spec/{utilities/scrubber_spec.rb → scrubber_spec.rb} +4 -2
  37. data/spec/{utilities/system_command_spec.rb → system_command_spec.rb} +3 -3
  38. metadata +20 -16
  39. data/lib/approvals/utilities.rb +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5a754f80fcf4b9d5684a6ad266014cbe4f088d97
4
- data.tar.gz: 9f9f31c64420640ae34acfab35f44a4b6bd42fd5
3
+ metadata.gz: a0a50b2c67393dc926d52f49df60c453975df001
4
+ data.tar.gz: 4ff2a58aedde600c73a24578d3e6e2a7cdda6c0d
5
5
  SHA512:
6
- metadata.gz: 83e90620776b4f6cdfa6d280512c78979acde2d7b4478cdc5796bf8ecb8b13d67afea05534bd0312c8af34dbc8d6cbedc290f1100f9eb7ca79a88bc14bbfb433
7
- data.tar.gz: 28376171ae47ec54b63f74ba094a0b9327d3248545fc4b80da1b3d6ec44bbd9827e11c1e631faed607cde89c1a1c9133ea3ce82fb5da443e59a261462f32bee7
6
+ metadata.gz: b9b8bd1f543244f6ff2427b41ca2658f5087f1173024e69990ef7f6b60bbc47d07c15554e4903640198de3438eb579561f6c593b0c967f8ab32ab36d9e5f5f6d
7
+ data.tar.gz: d43cb171f0f9ea3d377d01798d2df4eca92b2b093693eb7760facb2684b6667c84896196f3e0fcf445676ad23cc94e956b4c515aeb6cccd01073da80c0032da6
data/Changelog.md CHANGED
@@ -1,10 +1,27 @@
1
1
  # Changelog
2
2
 
3
- ## HEAD
3
+ ### HEAD
4
4
 
5
- * Added configuration option `diff_on_approval_failure`, and functionality to let rspec diff on an approval failure.
5
+ - Allow to verify hashes and arrays as json
6
6
 
7
+ - Added support for RSpec 3.0
7
8
 
8
- ## Version 0.0.9
9
+ ### v0.0.12 (2014/02/16 16:43 +00:00)
10
+
11
+ - Allow to configure a default format in RSpec
12
+
13
+ ### v0.0.11 (2014/02/16 16:33 +00:00)
14
+
15
+ - Append a trailing newline to all approval files
16
+
17
+
18
+ ### v0.0.10 (2014/01/30 14:41 +00:00)
19
+ - [#9](https://github.com/kytrinyx/approvals/pull/9) Send rspec approval failures to rspec for diffing (@jeremyruppel)
20
+
21
+ - [#19](https://github.com/kytrinyx/approvals/pull/19) Switch rspec fail_with args so diff is correct (@bmarini)
22
+
23
+ - Added configuration option `diff_on_approval_failure`, and functionality to let rspec diff on an approval failure.
24
+
25
+ ### v0.0.9
9
26
 
10
27
  Before this version, no changelog was maintained
data/README.md CHANGED
@@ -20,8 +20,6 @@ See [ApprovalTests](http://www.approvaltests.com) for videos and additional docu
20
20
  Also, check out Herding Code's [podcast #117](http://t.co/GLn88R5) in
21
21
  which Llewellyn Falco is interviewed about approvals.
22
22
 
23
-
24
-
25
23
  ## Configuration
26
24
 
27
25
  ```ruby
@@ -32,7 +30,9 @@ end
32
30
 
33
31
  The default location for the output files is
34
32
 
35
- approvals/
33
+ ```plain
34
+ approvals/
35
+ ```
36
36
 
37
37
  ## Usage
38
38
 
@@ -54,6 +54,50 @@ The first time the approval is run, a file will be created with the contents of
54
54
 
55
55
  Since you have not yet approved anything, the `*.approved` file does not exist, and the comparison will fail.
56
56
 
57
+ ## CLI
58
+
59
+ The gem comes with a command-line tool that makes it easier to manage the
60
+ `*.received.*` and `*.approved.*` files.
61
+
62
+ The basic usage is:
63
+
64
+ ```bash
65
+ approvals verify
66
+ ```
67
+
68
+ This goes through each approval failure in turn showing you the diff.
69
+
70
+ The option `--diff` or `-d` configures which difftool to use (for example
71
+ `opendiff`, `vimdiff`, etc). The default value is `diff`.
72
+
73
+ The option `--ask` or `-a`, which after showing you a diff will offer to
74
+ approve the received file (move it from `*.received.*` to `*.approved.*`.).
75
+ The default is `true`. If you set this to `false`, then nothing happens beyond
76
+ showing you the diff, and you will need to rename files manually.
77
+
78
+ ### Workflow Using VimDiff
79
+
80
+ I have the following mapped to `<leader>v` in my .vimrc file:
81
+
82
+ ```viml
83
+ map <leader>v :!approvals verify -d vimdiff -a<cr>
84
+ ```
85
+
86
+ I tend to run my tests from within vim with an on-the-fly mapping:
87
+
88
+ ```viml
89
+ :map Q :wa <Bar> :!ruby path/to/test_file.rb<cr>
90
+ ```
91
+
92
+ When I get one or more approval failures, I hit `<leader>v`. This gives me the
93
+ vimdiff.
94
+
95
+ When I've inspected the result, I hit `:qa` which closes both sides of the
96
+ diff.
97
+
98
+ Then I'm asked if I want to approve the received file `[yN]`. If there are
99
+ multiple diffs, this handles each failure in turn.
100
+
57
101
  ### RSpec
58
102
 
59
103
  For the moment the only direct integration is with RSpec.
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', '~> 2.9'
23
+ s.add_development_dependency 'rspec', '~> 2.99.0.beta2'
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'
data/bin/approvals CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'rubygems'
4
4
  require 'thor'
5
- require 'approvals/utilities/cli'
5
+ require 'cli'
6
6
 
7
7
  Approvals::CLI.start
8
8
 
data/lib/approvals.rb CHANGED
@@ -6,8 +6,12 @@ require 'approvals/configuration'
6
6
  require 'approvals/approval'
7
7
  require 'approvals/dsl'
8
8
  require 'approvals/error'
9
- require 'approvals/utilities'
9
+ require 'approvals/system_command'
10
+ require 'approvals/scrubber'
11
+ require 'approvals/dotfile'
12
+ require 'approvals/executable'
10
13
  require 'approvals/reporters'
14
+ require 'approvals/filter'
11
15
  require 'approvals/writer'
12
16
  require 'approvals/namers/default_namer'
13
17
 
File without changes
@@ -8,8 +8,13 @@ module Approvals
8
8
  end
9
9
 
10
10
  def verify(options = {}, &block)
11
+ # Workaround to support both Rspec 2 and 3
12
+ # RSpec.current_example is the Rspec 3 way
13
+ fetch_current_example = ::RSpec.respond_to?(:current_example) ? proc { ::RSpec.current_example } : proc { |context| context.example }
14
+ # /Workaround
15
+
11
16
  group = eval "self", block.binding
12
- namer = ::RSpec.configuration.approvals_namer_class.new(group.example)
17
+ namer = ::RSpec.configuration.approvals_namer_class.new(fetch_current_example.call(group))
13
18
  defaults = {
14
19
  :namer => namer
15
20
  }
@@ -27,8 +32,12 @@ module Approvals
27
32
  private
28
33
 
29
34
  def diff_on_approval_failure?
35
+ # Workaround to support both RSpec 2 and 3
36
+ fetch_current_example = ::RSpec.respond_to?(:current_example) ? proc { ::RSpec.current_example } : proc { |context| context.example }
37
+ # /Workaround
38
+
30
39
  ::RSpec.configuration.diff_on_approval_failure? ||
31
- example.metadata[:diff_on_approval_failure]
40
+ fetch_current_example.call(self).metadata[:diff_on_approval_failure]
32
41
  end
33
42
  end
34
43
  end
@@ -0,0 +1,45 @@
1
+ module Approvals
2
+ class Filter
3
+ attr_reader :filters
4
+
5
+ def initialize(filters)
6
+ @filters = filters
7
+ @placeholder = {}
8
+ end
9
+
10
+ def apply hash_or_array
11
+ if @filters.any?
12
+ censored(hash_or_array)
13
+ else
14
+ hash_or_array
15
+ end
16
+ end
17
+
18
+ def censored value, key=nil
19
+ case value
20
+ when Array
21
+ value.map { |item| censored(item) }
22
+ when Hash
23
+ Hash[value.map { |key, value| [key, censored(value, key)] }]
24
+ else
25
+ if value.nil?
26
+ nil
27
+ elsif key && placeholder_for(key)
28
+ "<#{placeholder_for(key)}>"
29
+ else
30
+ value
31
+ end
32
+ end
33
+ end
34
+
35
+ def placeholder_for key
36
+ return @placeholder[key] if @placeholder.key? key
37
+
38
+ applicable_filters = filters.select do |placeholder, pattern|
39
+ pattern && key.match(pattern)
40
+ end
41
+
42
+ @placeholder[key] = applicable_filters.keys.last
43
+ end
44
+ end
45
+ end
@@ -1,3 +1,3 @@
1
1
  module Approvals
2
- VERSION = '0.0.12'
2
+ VERSION = '0.0.13'
3
3
  end
@@ -9,22 +9,22 @@ require 'approvals/writers/binary_writer'
9
9
  module Approvals
10
10
  module Writer
11
11
  extend Writers
12
-
12
+
13
13
  REGISTRY = {
14
- json: Writers::JsonWriter.instance,
15
- xml: Writers::XmlWriter.instance,
16
- html: Writers::HtmlWriter.instance,
17
- hash: Writers::HashWriter.instance,
18
- array: Writers::ArrayWriter.instance,
14
+ json: Writers::JsonWriter.new,
15
+ xml: Writers::XmlWriter.new,
16
+ html: Writers::HtmlWriter.new,
17
+ hash: Writers::HashWriter.new,
18
+ array: Writers::ArrayWriter.new,
19
19
  }
20
-
20
+
21
21
 
22
22
  class << self
23
23
  def for(format)
24
24
  if REGISTRY.include?(format)
25
25
  REGISTRY[format]
26
26
  else
27
- TextWriter.instance
27
+ TextWriter.new
28
28
  end
29
29
  end
30
30
  end
@@ -3,11 +3,15 @@ module Approvals
3
3
  class ArrayWriter < TextWriter
4
4
 
5
5
  def format(data)
6
- data.map.with_index do |value, i|
6
+ filter(data).map.with_index do |value, i|
7
7
  "[#{i.inspect}] #{value.inspect}\n"
8
8
  end.join
9
9
  end
10
10
 
11
+ def filter data
12
+ filter = ::Approvals::Filter.new(Approvals.configuration.excluded_json_keys)
13
+ filter.apply(data)
14
+ end
11
15
  end
12
16
  end
13
17
  end
@@ -1,10 +1,6 @@
1
1
  module Approvals
2
-
3
2
  module Writers
4
-
5
3
  class BinaryWriter
6
- include Singleton
7
-
8
4
  EXCEPTION_WRITER = Proc.new do |data, file|
9
5
  raise "BinaryWriter#callback missing"
10
6
  end
@@ -16,32 +12,32 @@ module Approvals
16
12
  self.write = opts[:write] || EXCEPTION_WRITER
17
13
  self.format = opts[:format] || :binary
18
14
  end
19
-
15
+
20
16
  attr_accessor :autoregister
21
17
  attr_accessor :extension
22
18
  attr_accessor :write
23
19
  attr_accessor :detect
24
-
25
-
20
+
21
+
26
22
  attr_reader :format
27
23
 
28
24
  def format=(sym)
29
25
  unregister if autoregister
30
-
31
- @format = sym
32
-
26
+
27
+ @format = sym
28
+
33
29
  register if autoregister
34
-
30
+
35
31
  end
36
-
32
+
37
33
  def register
38
34
  if @format
39
- Writer::REGISTRY[@format] = self
35
+ Writer::REGISTRY[@format] = self
40
36
  Approval::BINARY_FORMATS << @format
41
37
  Approval::IDENTITIES[@format] = @detect if @detect
42
38
  end
43
39
  end
44
-
40
+
45
41
  def unregister
46
42
  if @format
47
43
  Writer::REGISTRY.delete!(@format)
@@ -56,4 +52,4 @@ module Approvals
56
52
 
57
53
  end
58
54
  end
59
- end
55
+ end
@@ -3,13 +3,18 @@ module Approvals
3
3
  class HashWriter < TextWriter
4
4
 
5
5
  def format(data)
6
- lines = data.map do |key, value|
6
+ lines = filter(data).map do |key, value|
7
7
  "\t#{key.inspect} => #{value.inspect}"
8
8
  end.join("\n")
9
9
 
10
10
  "{\n#{lines}\n}\n"
11
11
  end
12
12
 
13
+ def filter data
14
+ filter = ::Approvals::Filter.new(Approvals.configuration.excluded_json_keys)
15
+ filter.apply(data)
16
+ end
17
+
13
18
  end
14
19
  end
15
20
  end
@@ -1,50 +1,30 @@
1
1
  module Approvals
2
2
  module Writers
3
3
  class JsonWriter < TextWriter
4
-
5
4
  def extension
6
5
  'json'
7
6
  end
8
7
 
9
8
  def format(data)
10
- hash_or_array = parse_data(data)
11
-
12
- apply_filters!(hash_or_array) if filters.any?
9
+ hash_or_array = filter(parse_data(data))
13
10
 
14
11
  JSON.pretty_generate(hash_or_array) + "\n"
15
12
  end
16
13
 
17
14
  private
18
15
 
19
- def filters
20
- Approvals.configuration.excluded_json_keys
21
- end
22
-
23
16
  def parse_data(data)
24
- JSON.parse(data)
17
+ if data.respond_to?(:to_str)
18
+ # if the data is a string, assume it has been already json-ified
19
+ JSON.parse(data)
20
+ else
21
+ JSON.parse(data.to_json)
22
+ end
25
23
  end
26
24
 
27
- def apply_filters!(hash_or_array)
28
- case hash_or_array
29
- when Array
30
- for i in (0 ... hash_or_array.size) do
31
- apply_filters!(hash_or_array[i])
32
- end
33
- when Hash
34
- hash_or_array.each do |key, value|
35
- next if value.nil?
36
-
37
- if value.is_a?(Hash) || value.is_a?(Array)
38
- apply_filters!(value)
39
- else
40
- filters.each do |placeholder, pattern|
41
- if pattern && key.match(pattern)
42
- hash_or_array[key] = "<#{placeholder}>"
43
- end
44
- end
45
- end
46
- end
47
- end
25
+ def filter data
26
+ filter = ::Approvals::Filter.new(Approvals.configuration.excluded_json_keys)
27
+ filter.apply(data)
48
28
  end
49
29
  end
50
30
  end
@@ -1,8 +1,6 @@
1
1
  module Approvals
2
2
  module Writers
3
3
  class TextWriter
4
- include Singleton
5
-
6
4
  def extension
7
5
  'txt'
8
6
  end
File without changes
@@ -3,7 +3,7 @@ require 'approvals/namers/rspec_namer'
3
3
 
4
4
  describe Approvals do
5
5
 
6
- let(:namer) { Approvals::Namers::RSpecNamer.new(self.example) }
6
+ let(:namer) { |example| Approvals::Namers::RSpecNamer.new(example) }
7
7
 
8
8
  it "fails" do
9
9
  Approvals::Dotfile.stub(:path => '/dev/null')
@@ -73,6 +73,15 @@ describe Approvals do
73
73
  Approvals.verify json, :format => :json, :namer => namer
74
74
  end
75
75
 
76
+ it "verifies an array as json when format is set to json" do
77
+ people = [
78
+ {"name" => "Alice", "age" => 28},
79
+ {"name" => "Bob", "age" => 22}
80
+ ]
81
+
82
+ Approvals.verify(people, format: :json, namer: namer)
83
+ end
84
+
76
85
  it "verifies an executable" do
77
86
  executable = Approvals::Executable.new('SELECT 1') do |command|
78
87
  puts "your slip is showing (#{command})"
@@ -87,7 +96,7 @@ describe Approvals do
87
96
  Approvals.verify string, :namer => namer
88
97
  end
89
98
 
90
- describe "supports excluded keys option for json" do
99
+ describe "supports excluded keys option" do
91
100
  let(:hash) { {:object => {:id => rand(100), :created_at => Time.now, :name => 'test', deleted_at: nil}} }
92
101
 
93
102
  before do
@@ -106,5 +115,13 @@ describe Approvals do
106
115
  it "also supports an array of hashes" do
107
116
  Approvals.verify JSON.dump([hash]), :format => :json, :namer => namer
108
117
  end
118
+
119
+ it "supports the array writer" do
120
+ Approvals.verify [hash], :format => :array, :namer => namer
121
+ end
122
+
123
+ it "supports the hash writer" do
124
+ Approvals.verify hash, :format => :array, :namer => namer
125
+ end
109
126
  end
110
127
  end
@@ -1,5 +1,5 @@
1
1
  require 'spec_helper'
2
- require 'approvals/utilities/dotfile'
2
+ require 'approvals/dotfile'
3
3
 
4
4
  describe Approvals::Dotfile do
5
5
  let(:dotfile) { '/tmp/.approvals' }
@@ -1,10 +1,12 @@
1
1
  require 'spec_helper'
2
- require 'approvals/utilities/executable'
2
+ require 'approvals/executable'
3
3
 
4
4
  describe Approvals::Executable do
5
5
 
6
- subject { Approvals::Executable.new('SELECT 1') }
7
- its(:inspect) { should eq('SELECT 1') }
6
+ it "reflects the its value in inspect" do
7
+ executable = Approvals::Executable.new('SELECT 1')
8
+ executable.inspect.should eq 'SELECT 1'
9
+ end
8
10
 
9
11
  it "takes a block" do
10
12
  executable = Approvals::Executable.new('SELECT 1') do |command|
@@ -0,0 +1,89 @@
1
+ require 'spec_helper'
2
+
3
+
4
+ describe Approvals::Filter do
5
+ it "When no filters were supplied, it leaves the h_or_a alone" do
6
+ filter = Approvals::Filter.new({})
7
+
8
+ input = {some: 'hash'}
9
+ output = filter.apply(input)
10
+
11
+ expect(input).to equal output
12
+ end
13
+
14
+ it "replaces fields which match a filter" do
15
+ filter = Approvals::Filter.new({foo: /^_?foo$/})
16
+ input = {
17
+ foo: 'bar13',
18
+ _foo: 'bar27',
19
+ nonfoo: 'bar',
20
+ }
21
+
22
+ output = filter.apply(input)
23
+
24
+ expect(output).to eq({
25
+ foo: '<foo>',
26
+ _foo: '<foo>',
27
+ nonfoo: 'bar',
28
+ })
29
+ end
30
+
31
+ it "a filter matches, but the value is nil, it does not get replaced" do
32
+ filter = Approvals::Filter.new({foo: /^foo$/})
33
+ input = {
34
+ foo: nil,
35
+ nonfoo: 'bar',
36
+ }
37
+
38
+ output = filter.apply(input)
39
+
40
+ expect(output).to eq({
41
+ foo: nil,
42
+ nonfoo: 'bar',
43
+ })
44
+ end
45
+ it "a filter matches, and the value is falsey, but not nil, it gets replaced" do
46
+ filter = Approvals::Filter.new({foo: /^foo$/})
47
+ input = {
48
+ foo: false,
49
+ nonfoo: 'bar',
50
+ }
51
+
52
+ output = filter.apply(input)
53
+
54
+ expect(output).to eq({
55
+ foo: "<foo>",
56
+ nonfoo: 'bar',
57
+ })
58
+ end
59
+
60
+ it "filters recursively in hashes and array" do
61
+ filter = Approvals::Filter.new({foo: /^foo$/})
62
+ input = {
63
+ foo: 'bar124',
64
+ foolist: [{foo: 'bar 145', bar: 'foo'}, 'foobar'],
65
+ nonfoo: 'bar',
66
+ }
67
+
68
+ output = filter.apply(input)
69
+
70
+ expect(output).to eq({
71
+ foo: '<foo>',
72
+ foolist: [{foo: '<foo>', bar: 'foo'}, 'foobar'],
73
+ nonfoo: 'bar',
74
+ })
75
+ end
76
+
77
+ it "takes the last applicable filter" do
78
+ filter = Approvals::Filter.new({foo: /^foo/, bar: /bar$/})
79
+ input = {
80
+ foobar: 'baz',
81
+ }
82
+
83
+ output = filter.apply(input)
84
+
85
+ expect(output).to eq({
86
+ foobar: '<bar>',
87
+ })
88
+ end
89
+ end
@@ -0,0 +1 @@
1
+ [0] {:object=>{:id=>"<id>", :created_at=>"<date>", :name=>"test", :deleted_at=>nil}}
@@ -0,0 +1 @@
1
+ [0] [:object, {:id=>"<id>", :created_at=>"<date>", :name=>"test", :deleted_at=>nil}]
@@ -0,0 +1,10 @@
1
+ [
2
+ {
3
+ "name": "Alice",
4
+ "age": 28
5
+ },
6
+ {
7
+ "name": "Bob",
8
+ "age": 22
9
+ }
10
+ ]
@@ -3,12 +3,12 @@ require 'approvals/rspec'
3
3
 
4
4
  describe Approvals::Namers::DirectoryNamer do
5
5
 
6
- it "uses non-$%^&*funky example description" do
7
- Approvals::Namers::DirectoryNamer.new(self.example).name.should eq("approvals_namers_directorynamer/uses_non_funky_example_description")
6
+ it "uses non-$%^&*funky example description" do |example|
7
+ Approvals::Namers::DirectoryNamer.new(example).name.should eq("approvals_namers_directorynamer/uses_non_funky_example_description")
8
8
  end
9
9
 
10
- it "has a decent default" do
11
- Approvals::Namers::DirectoryNamer.new(self.example).output_dir.should eq('spec/fixtures/approvals/')
10
+ it "has a decent default" do |example|
11
+ Approvals::Namers::DirectoryNamer.new(example).output_dir.should eq('spec/fixtures/approvals/')
12
12
  end
13
13
 
14
14
  context "when RSpec is configured" do
@@ -24,8 +24,8 @@ describe Approvals::Namers::DirectoryNamer do
24
24
  end
25
25
  end
26
26
 
27
- it "uses the rspec config option" do
28
- Approvals::Namers::DirectoryNamer.new(self.example).output_dir.should eq('spec/output/dir/')
27
+ it "uses the rspec config option" do |example|
28
+ Approvals::Namers::DirectoryNamer.new(example).output_dir.should eq('spec/output/dir/')
29
29
  end
30
30
  end
31
31
  end
@@ -2,12 +2,12 @@ require 'spec_helper'
2
2
 
3
3
  describe Approvals::Namers::RSpecNamer do
4
4
 
5
- it "uses non-$%^&*funky example description" do
6
- Approvals::Namers::RSpecNamer.new(self.example).name.should eq("approvals_namers_rspecnamer_uses_non_funky_example_description")
5
+ it "uses non-$%^&*funky example description" do |example|
6
+ Approvals::Namers::RSpecNamer.new(example).name.should eq("approvals_namers_rspecnamer_uses_non_funky_example_description")
7
7
  end
8
8
 
9
- it "has a decent default" do
10
- Approvals::Namers::RSpecNamer.new(self.example).output_dir.should eq('spec/fixtures/approvals/')
9
+ it "has a decent default" do |example|
10
+ Approvals::Namers::RSpecNamer.new(example).output_dir.should eq('spec/fixtures/approvals/')
11
11
  end
12
12
 
13
13
  context "when RSpec is configured" do
@@ -23,8 +23,8 @@ describe Approvals::Namers::RSpecNamer do
23
23
  end
24
24
  end
25
25
 
26
- it "uses the rspec config option" do
27
- Approvals::Namers::RSpecNamer.new(self.example).output_dir.should eq('spec/output/dir/')
26
+ it "uses the rspec config option" do |example|
27
+ Approvals::Namers::RSpecNamer.new(example).output_dir.should eq('spec/output/dir/')
28
28
  end
29
29
  end
30
30
  end
data/spec/namers_spec.rb CHANGED
@@ -3,8 +3,8 @@ require 'approvals/rspec'
3
3
 
4
4
  describe Approvals::Namers do
5
5
 
6
- it "uses the RSpecNamer" do
7
- approval = Approvals::Approval.new("naming with rspec namer", :namer => Approvals::Namers::RSpecNamer.new(self.example))
6
+ it "uses the RSpecNamer" do |example|
7
+ approval = Approvals::Approval.new("naming with rspec namer", :namer => Approvals::Namers::RSpecNamer.new(example))
8
8
  approval.name.should eq("approvals_namers_uses_the_rspecnamer")
9
9
  end
10
10
 
@@ -8,14 +8,14 @@ describe Approvals::Reporters::FirstWorkingReporter do
8
8
  let(:yes) { double(:working_in_this_environment? => true) }
9
9
  let(:yes_too) { double(:working_in_this_environment? => true) }
10
10
 
11
- context "when at least one reporter works" do
12
- subject { Approvals::Reporters::FirstWorkingReporter.new(no, yes) }
13
- its(:working_in_this_environment?) { should be_true }
11
+ it "when at least one reporter works it is working" do
12
+ reporter = Approvals::Reporters::FirstWorkingReporter.new(no, yes)
13
+ reporter.should be_working_in_this_environment
14
14
  end
15
15
 
16
- context "when no reporters work" do
17
- subject { Approvals::Reporters::FirstWorkingReporter.new(no, no) }
18
- its(:working_in_this_environment?) { should be_false }
16
+ it "when no reporters work it's not working" do
17
+ reporter = Approvals::Reporters::FirstWorkingReporter.new(no, no)
18
+ reporter.should_not be_working_in_this_environment
19
19
  end
20
20
 
21
21
  it "calls the first working reporter" do
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
  require 'approvals/reporters'
3
- require 'approvals/utilities/scrubber'
3
+ require 'approvals/scrubber'
4
4
 
5
5
  describe Approvals::Reporters::HtmlImageReporter do
6
6
 
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Approvals::Reporters::OpendiffReporter do
4
4
 
5
5
  it "has a nice launcher" do
6
- pending "Breaks off execution of the tests. Horrible."
6
+ skip "Breaks off execution of the tests. Horrible."
7
7
  one = 'spec/fixtures/one.txt'
8
8
  two = 'spec/fixtures/two.txt'
9
9
  executable = Approvals::Executable.new(Approvals::Reporters::OpendiffReporter.instance.launcher.call(one, two)) do |command|
@@ -1,5 +1,5 @@
1
1
  require 'spec_helper'
2
- require 'approvals/utilities/scrubber'
2
+ require 'approvals/scrubber'
3
3
 
4
4
  describe Approvals::Scrubber do
5
5
 
@@ -7,7 +7,9 @@ describe Approvals::Scrubber do
7
7
  let(:path) { File.expand_path('.') }
8
8
  subject { Approvals::Scrubber.new("I am currently at #{path}") }
9
9
 
10
- its(:to_s) { should eq("I am currently at {{current_dir}}") }
10
+ it "has a sensible to_s" do
11
+ subject.to_s.should eq("I am currently at {{current_dir}}")
12
+ end
11
13
 
12
14
  it "unscrubs" do
13
15
  subject.unscrub.should eq("I am currently at #{path}")
@@ -1,13 +1,13 @@
1
1
  require 'spec_helper'
2
- require 'approvals/utilities/system_command'
2
+ require 'approvals/system_command'
3
3
 
4
4
  describe Approvals::SystemCommand, "#exists?" do
5
5
 
6
6
  it "does" do
7
- Approvals::SystemCommand.exists?("ls").should be_true
7
+ Approvals::SystemCommand.exists?("ls").should be_truthy
8
8
  end
9
9
 
10
10
  it "does not" do
11
- Approvals::SystemCommand.exists?("absolutelydoesnotexistonyoursystem").should be_false
11
+ Approvals::SystemCommand.exists?("absolutelydoesnotexistonyoursystem").should 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.12
4
+ version: 0.0.13
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-02-16 00:00:00.000000000 Z
11
+ date: 2014-03-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: '2.9'
19
+ version: 2.99.0.beta2
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: '2.9'
26
+ version: 2.99.0.beta2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -87,10 +87,13 @@ files:
87
87
  - lib/approvals.rb
88
88
  - lib/approvals/approval.rb
89
89
  - lib/approvals/configuration.rb
90
+ - lib/approvals/dotfile.rb
90
91
  - lib/approvals/dsl.rb
91
92
  - lib/approvals/error.rb
93
+ - lib/approvals/executable.rb
92
94
  - lib/approvals/extensions/rspec.rb
93
95
  - lib/approvals/extensions/rspec/dsl.rb
96
+ - lib/approvals/filter.rb
94
97
  - lib/approvals/namers/default_namer.rb
95
98
  - lib/approvals/namers/directory_namer.rb
96
99
  - lib/approvals/namers/rspec_namer.rb
@@ -107,12 +110,8 @@ files:
107
110
  - lib/approvals/reporters/launcher.rb
108
111
  - lib/approvals/reporters/reporter.rb
109
112
  - lib/approvals/rspec.rb
110
- - lib/approvals/utilities.rb
111
- - lib/approvals/utilities/cli.rb
112
- - lib/approvals/utilities/dotfile.rb
113
- - lib/approvals/utilities/executable.rb
114
- - lib/approvals/utilities/scrubber.rb
115
- - lib/approvals/utilities/system_command.rb
113
+ - lib/approvals/scrubber.rb
114
+ - lib/approvals/system_command.rb
116
115
  - lib/approvals/version.rb
117
116
  - lib/approvals/writer.rb
118
117
  - lib/approvals/writers/array_writer.rb
@@ -122,16 +121,23 @@ files:
122
121
  - lib/approvals/writers/json_writer.rb
123
122
  - lib/approvals/writers/text_writer.rb
124
123
  - lib/approvals/writers/xml_writer.rb
124
+ - lib/cli.rb
125
125
  - spec/approvals_spec.rb
126
126
  - spec/configuration_spec.rb
127
+ - spec/dotfile_spec.rb
128
+ - spec/executable_spec.rb
127
129
  - spec/extensions/rspec_approvals_spec.rb
130
+ - spec/filter_spec.rb
128
131
  - spec/fixtures/approvals/approvals_passes_approved_files_through_erb.approved.txt
129
- - spec/fixtures/approvals/approvals_supports_excluded_keys_option_for_json_also_supports_an_array_of_hashes.approved.json
130
- - spec/fixtures/approvals/approvals_supports_excluded_keys_option_for_json_verifies_json_with_excluded_keys.approved.json
132
+ - spec/fixtures/approvals/approvals_supports_excluded_keys_option_also_supports_an_array_of_hashes.approved.json
133
+ - spec/fixtures/approvals/approvals_supports_excluded_keys_option_supports_the_array_writer.approved.txt
134
+ - spec/fixtures/approvals/approvals_supports_excluded_keys_option_supports_the_hash_writer.approved.txt
135
+ - spec/fixtures/approvals/approvals_supports_excluded_keys_option_verifies_json_with_excluded_keys.approved.json
131
136
  - spec/fixtures/approvals/approvals_verifies_a_complex_object.approved.txt
132
137
  - spec/fixtures/approvals/approvals_verifies_a_hash.approved.txt
133
138
  - spec/fixtures/approvals/approvals_verifies_a_string.approved.txt
134
139
  - spec/fixtures/approvals/approvals_verifies_an_array.approved.txt
140
+ - spec/fixtures/approvals/approvals_verifies_an_array_as_json_when_format_is_set_to_json.approved.json
135
141
  - spec/fixtures/approvals/approvals_verifies_an_executable.approved.txt
136
142
  - spec/fixtures/approvals/approvals_verifies_html.approved.html
137
143
  - spec/fixtures/approvals/approvals_verifies_json.approved.json
@@ -170,11 +176,9 @@ files:
170
176
  - spec/reporters/launcher_spec.rb
171
177
  - spec/reporters/opendiff_reporter_spec.rb
172
178
  - spec/reporters/reporter_spec.rb
179
+ - spec/scrubber_spec.rb
173
180
  - spec/spec_helper.rb
174
- - spec/utilities/dotfile_spec.rb
175
- - spec/utilities/executable_spec.rb
176
- - spec/utilities/scrubber_spec.rb
177
- - spec/utilities/system_command_spec.rb
181
+ - spec/system_command_spec.rb
178
182
  homepage: ''
179
183
  licenses:
180
184
  - MIT
@@ -1,4 +0,0 @@
1
- require 'approvals/utilities/system_command'
2
- require 'approvals/utilities/scrubber'
3
- require 'approvals/utilities/dotfile'
4
- require 'approvals/utilities/executable'