approvals 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. data/Rakefile +3 -0
  2. data/approvals.gemspec +2 -2
  3. data/lib/approvals/extensions/rspec.rb +2 -0
  4. data/lib/approvals/extensions/rspec/dsl.rb +1 -1
  5. data/lib/approvals/namers/directory_namer.rb +23 -0
  6. data/lib/approvals/writers/text_writer.rb +1 -0
  7. data/spec/approvals_spec.rb +1 -1
  8. data/spec/configuration_spec.rb +1 -0
  9. data/spec/extensions/rspec_approvals_spec.rb +28 -2
  10. data/spec/fixtures/approvals/verifies_directory/a_complex_object.approved.txt +1 -0
  11. data/spec/fixtures/approvals/verifies_directory/a_string.approved.txt +1 -0
  12. data/spec/fixtures/approvals/verifies_directory/an_array.approved.txt +4 -0
  13. data/spec/fixtures/approvals/verifies_directory/an_executable.approved.txt +1 -0
  14. data/spec/fixtures/approvals/verifies_directory/html.approved.html +11 -0
  15. data/spec/fixtures/approvals/verifies_directory/json.approved.json +7 -0
  16. data/spec/fixtures/approvals/verifies_directory/xml.approved.xml +9 -0
  17. data/spec/namers/default_namer_spec.rb +1 -0
  18. data/spec/namers/directory_namer_spec.rb +30 -0
  19. data/spec/namers/rspec_namer_spec.rb +1 -1
  20. data/spec/namers_spec.rb +1 -1
  21. data/spec/reporters/first_working_reporter_spec.rb +1 -0
  22. data/spec/reporters/html_image_reporter_spec.rb +1 -0
  23. data/spec/reporters/image_magick_reporter_spec.rb +1 -0
  24. data/spec/reporters/launcher_spec.rb +1 -0
  25. data/spec/reporters/opendiff_reporter_spec.rb +1 -1
  26. data/spec/reporters/reporter_spec.rb +1 -0
  27. data/spec/spec_helper.rb +7 -0
  28. data/spec/utilities/dotfile_spec.rb +1 -0
  29. data/spec/utilities/executable_spec.rb +1 -0
  30. data/spec/utilities/scrubber_spec.rb +1 -0
  31. data/spec/utilities/system_command_spec.rb +1 -0
  32. metadata +19 -9
data/Rakefile CHANGED
@@ -1 +1,4 @@
1
1
  require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new :spec
data/approvals.gemspec CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "approvals"
6
- s.version = "0.0.4"
6
+ s.version = "0.0.5"
7
7
  s.authors = ["Katrina Owen"]
8
8
  s.email = ["katrina.owen@gmail.com"]
9
9
  s.homepage = ""
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
18
  s.require_paths = ["lib"]
19
19
 
20
- s.add_development_dependency 'rspec', '~> 2.7'
20
+ s.add_development_dependency 'rspec', '~> 2.9'
21
21
  s.add_dependency 'thor'
22
22
  s.add_dependency 'nokogiri'
23
23
  end
@@ -1,9 +1,11 @@
1
1
  if defined? RSpec
2
2
  require 'approvals/extensions/rspec/dsl'
3
3
  require 'approvals/namers/rspec_namer'
4
+ require 'approvals/namers/directory_namer'
4
5
 
5
6
  RSpec.configure do |c|
6
7
  c.include Approvals::RSpec::DSL
7
8
  c.add_setting :approvals_path, :default => 'spec/fixtures/approvals/'
9
+ c.add_setting :approvals_namer_class, :default => Approvals::Namers::DirectoryNamer
8
10
  end
9
11
  end
@@ -7,7 +7,7 @@ module Approvals
7
7
 
8
8
  def verify(options = {}, &block)
9
9
  group = eval "self", block.binding
10
- namer = Approvals::Namers::RSpecNamer.new(group.example)
10
+ namer = ::RSpec.configuration.approvals_namer_class.new(group.example)
11
11
  Approvals.verify(block.call, options.merge(:namer => namer))
12
12
  end
13
13
  end
@@ -0,0 +1,23 @@
1
+ module Approvals
2
+ module Namers
3
+ class DirectoryNamer < RSpecNamer
4
+
5
+ def initialize(example)
6
+ @name = directorize example
7
+ end
8
+
9
+ private
10
+
11
+ def directorize(example)
12
+ parts = [ ]
13
+ metadata = example.metadata
14
+
15
+ begin
16
+ parts << metadata[ :description ]
17
+ end while metadata = metadata[ :example_group ]
18
+
19
+ parts.reverse.map { |p| normalize p }.join '/'
20
+ end
21
+ end
22
+ end
23
+ end
@@ -8,6 +8,7 @@ module Approvals
8
8
  end
9
9
 
10
10
  def write(data, path)
11
+ FileUtils.mkdir_p(File.dirname(path))
11
12
  File.open(path, 'w') do |f|
12
13
  f.write format(data)
13
14
  end
@@ -1,4 +1,4 @@
1
- require 'approvals'
1
+ require 'spec_helper'
2
2
  require 'approvals/namers/rspec_namer'
3
3
 
4
4
  describe Approvals do
@@ -1,3 +1,4 @@
1
+ require 'spec_helper'
1
2
  require 'approvals/configuration'
2
3
 
3
4
  describe Approvals::Configuration do
@@ -1,7 +1,7 @@
1
- require 'approvals'
1
+ require 'spec_helper'
2
2
  require 'approvals/rspec'
3
3
 
4
- describe "Verifies" do
4
+ shared_context 'verify examples' do
5
5
  specify "a string" do
6
6
  verify do
7
7
  "We have, I fear, confused power with greatness."
@@ -62,3 +62,29 @@ describe "Verifies" do
62
62
  end
63
63
  end
64
64
  end
65
+
66
+ RSpec.configure do |c|
67
+ c.after :each do
68
+ c.approvals_namer_class = nil
69
+ end
70
+ end
71
+
72
+ describe "Verifies" do
73
+ before :each do
74
+ RSpec.configure do |c|
75
+ c.approvals_namer_class = Approvals::Namers::RSpecNamer
76
+ end
77
+ end
78
+
79
+ include_context 'verify examples'
80
+ end
81
+
82
+ describe "Verifies (directory)" do
83
+ before :each do
84
+ RSpec.configure do |c|
85
+ c.approvals_namer_class = Approvals::Namers::DirectoryNamer
86
+ end
87
+ end
88
+
89
+ include_context 'verify examples'
90
+ end
@@ -0,0 +1 @@
1
+ We have, I fear, confused power with greatness.
@@ -0,0 +1,4 @@
1
+ [0] "abc"
2
+ [1] 123
3
+ [2] :zomg_fooooood
4
+ [3] ["cheese", "burger", "ribs", "steak", "bacon"]
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
5
+ <title>Approval</title>
6
+ </head>
7
+ <body>
8
+ <h1>An Approval</h1>
9
+ <p>It has a paragraph</p>
10
+ </body>
11
+ </html>
@@ -0,0 +1,7 @@
1
+ {
2
+ "pet": {
3
+ "species": "turtle",
4
+ "color": "green",
5
+ "name": "Anthony"
6
+ }
7
+ }
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <xml char="kiddo">
3
+ <node>
4
+ <content name="beatrice"/>
5
+ </node>
6
+ <node aliases="5">
7
+ <content/>
8
+ </node>
9
+ </xml>
@@ -1,3 +1,4 @@
1
+ require 'spec_helper'
1
2
  require 'approvals/configuration'
2
3
  require 'approvals/namers/default_namer'
3
4
 
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe Approvals::Namers::DirectoryNamer do
4
+
5
+ it "uses non-$%^&*funky example description" do
6
+ Approvals::Namers::DirectoryNamer.new(self.example).name.should eq("approvals_namers_directorynamer/uses_non_funky_example_description")
7
+ end
8
+
9
+ it "has a decent default" do
10
+ Approvals::Namers::DirectoryNamer.new(self.example).output_dir.should eq('spec/fixtures/approvals/')
11
+ end
12
+
13
+ context "when RSpec is configured" do
14
+ before :each do
15
+ RSpec.configure do |c|
16
+ c.approvals_path = 'spec/output/dir/'
17
+ end
18
+ end
19
+
20
+ after :each do
21
+ RSpec.configure do |c|
22
+ c.approvals_path = nil
23
+ end
24
+ end
25
+
26
+ it "uses the rspec config option" do
27
+ Approvals::Namers::DirectoryNamer.new(self.example).output_dir.should eq('spec/output/dir/')
28
+ end
29
+ end
30
+ end
@@ -1,4 +1,4 @@
1
- require 'approvals'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Approvals::Namers::RSpecNamer do
4
4
 
data/spec/namers_spec.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'approvals'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Approvals::Namers do
4
4
 
@@ -1,3 +1,4 @@
1
+ require 'spec_helper'
1
2
  require 'approvals/reporters/first_working_reporter'
2
3
 
3
4
  describe Approvals::Reporters::FirstWorkingReporter do
@@ -1,3 +1,4 @@
1
+ require 'spec_helper'
1
2
  require 'approvals/reporters'
2
3
  require 'approvals/utilities/scrubber'
3
4
 
@@ -1,3 +1,4 @@
1
+ require 'spec_helper'
1
2
  require 'approvals/reporters'
2
3
 
3
4
  describe Approvals::Reporters::ImageMagickReporter do
@@ -1,3 +1,4 @@
1
+ require 'spec_helper'
1
2
  require 'approvals/reporters/launcher'
2
3
 
3
4
  describe Approvals::Reporters::Launcher do
@@ -1,4 +1,4 @@
1
- require 'approvals'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Approvals::Reporters::OpendiffReporter do
4
4
 
@@ -1,3 +1,4 @@
1
+ require 'spec_helper'
1
2
  require 'approvals/reporters'
2
3
 
3
4
  describe Approvals::Reporters::Reporter do
@@ -0,0 +1,7 @@
1
+ require 'approvals'
2
+
3
+ # Configure RSpec
4
+ RSpec.configure do |config|
5
+ # Use color
6
+ config.color_enabled = true
7
+ end
@@ -1,3 +1,4 @@
1
+ require 'spec_helper'
1
2
  require 'approvals/utilities/dotfile'
2
3
 
3
4
  describe Approvals::Dotfile do
@@ -1,3 +1,4 @@
1
+ require 'spec_helper'
1
2
  require 'approvals/utilities/executable'
2
3
 
3
4
  describe Approvals::Executable do
@@ -1,3 +1,4 @@
1
+ require 'spec_helper'
1
2
  require 'approvals/utilities/scrubber'
2
3
 
3
4
  describe Approvals::Scrubber do
@@ -1,3 +1,4 @@
1
+ require 'spec_helper'
1
2
  require 'approvals/utilities/system_command'
2
3
 
3
4
  describe Approvals::SystemCommand, "#exists?" do
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
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-29 00:00:00.000000000 Z
12
+ date: 2012-05-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70128394108280 !ruby/object:Gem::Requirement
16
+ requirement: &70114913577820 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '2.7'
21
+ version: '2.9'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70128394108280
24
+ version_requirements: *70114913577820
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: thor
27
- requirement: &70128394107880 !ruby/object:Gem::Requirement
27
+ requirement: &70114913577220 !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: *70128394107880
35
+ version_requirements: *70114913577220
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: nokogiri
38
- requirement: &70128394107400 !ruby/object:Gem::Requirement
38
+ requirement: &70114913576740 !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: *70128394107400
46
+ version_requirements: *70114913576740
47
47
  description: Approval Tests for Ruby
48
48
  email:
49
49
  - katrina.owen@gmail.com
@@ -68,6 +68,7 @@ files:
68
68
  - lib/approvals/extensions/rspec.rb
69
69
  - lib/approvals/extensions/rspec/dsl.rb
70
70
  - lib/approvals/namers/default_namer.rb
71
+ - lib/approvals/namers/directory_namer.rb
71
72
  - lib/approvals/namers/rspec_namer.rb
72
73
  - lib/approvals/reporters.rb
73
74
  - lib/approvals/reporters/diff_reporter/diffmerge_reporter.rb
@@ -112,6 +113,13 @@ files:
112
113
  - spec/fixtures/approvals/verifies_a_string.approved.txt
113
114
  - spec/fixtures/approvals/verifies_an_array.approved.txt
114
115
  - spec/fixtures/approvals/verifies_an_executable.approved.txt
116
+ - spec/fixtures/approvals/verifies_directory/a_complex_object.approved.txt
117
+ - spec/fixtures/approvals/verifies_directory/a_string.approved.txt
118
+ - spec/fixtures/approvals/verifies_directory/an_array.approved.txt
119
+ - spec/fixtures/approvals/verifies_directory/an_executable.approved.txt
120
+ - spec/fixtures/approvals/verifies_directory/html.approved.html
121
+ - spec/fixtures/approvals/verifies_directory/json.approved.json
122
+ - spec/fixtures/approvals/verifies_directory/xml.approved.xml
115
123
  - spec/fixtures/approvals/verifies_html.approved.html
116
124
  - spec/fixtures/approvals/verifies_json.approved.json
117
125
  - spec/fixtures/approvals/verifies_xml.approved.xml
@@ -120,6 +128,7 @@ files:
120
128
  - spec/fixtures/two.png
121
129
  - spec/fixtures/two.txt
122
130
  - spec/namers/default_namer_spec.rb
131
+ - spec/namers/directory_namer_spec.rb
123
132
  - spec/namers/rspec_namer_spec.rb
124
133
  - spec/namers_spec.rb
125
134
  - spec/reporters/first_working_reporter_spec.rb
@@ -128,6 +137,7 @@ files:
128
137
  - spec/reporters/launcher_spec.rb
129
138
  - spec/reporters/opendiff_reporter_spec.rb
130
139
  - spec/reporters/reporter_spec.rb
140
+ - spec/spec_helper.rb
131
141
  - spec/utilities/dotfile_spec.rb
132
142
  - spec/utilities/executable_spec.rb
133
143
  - spec/utilities/scrubber_spec.rb