approvals-approval_tests 0.0.3 → 0.0.4

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/Rakefile CHANGED
@@ -13,9 +13,8 @@ begin
13
13
  gemspec.summary = "Approval testing library"
14
14
  gemspec.email = "approvaltests@dangilkerson.com"
15
15
  gemspec.homepage = "http://github.com/approvaltests/approval_tests"
16
- gemspec.description = "Approval testing library for ruby"
16
+ gemspec.description = "Approval testing library"
17
17
  gemspec.authors = ["Dan Gilkerson, Llewellyn Falco"]
18
- gemspec.rubyforge_project = 'approvaltests'
19
18
  end
20
19
  rescue LoadError
21
20
  puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
@@ -2,12 +2,12 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{approval_tests}
5
- s.version = "0.0.3"
5
+ s.version = "0.0.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Dan Gilkerson, Llewellyn Falco"]
9
- s.date = %q{2009-07-03}
10
- s.description = %q{Approval testing library for ruby}
9
+ s.date = %q{2009-07-02}
10
+ s.description = %q{Approval testing library}
11
11
  s.email = %q{approvaltests@dangilkerson.com}
12
12
  s.extra_rdoc_files = [
13
13
  "README"
@@ -27,18 +27,13 @@ Gem::Specification.new do |s|
27
27
  "lib/approval_tests/reporters/text_mate_reporter.rb",
28
28
  "lib/approval_tests/writers/html_writer.rb",
29
29
  "lib/approval_tests/writers/text_writer.rb",
30
- "lib/approval_tests/writers/xml_writer.rb",
31
30
  "spec/a.txt",
32
- "spec/approvals_lists_should_show_empty_lists.approved.txt",
33
- "spec/approvals_lists_should_write_arrays.approved.txt",
34
- "spec/approvals_lists_should_write_maps.approved.txt",
35
31
  "spec/approvals_multiple_describes_should_approve_multiple_describes.approved.txt",
36
32
  "spec/approvals_should_approve_shared_behaviors.approved.txt",
37
33
  "spec/approvals_should_successfully_approve_text.approved.txt",
38
34
  "spec/approvals_spec.rb",
39
35
  "spec/approvals_using_approval_blocks.approved.txt",
40
36
  "spec/approvals_using_approval_blocks_the_last_statement.approved.txt",
41
- "spec/approvals_xml_should_be_pretty.approved.txt",
42
37
  "spec/b.txt",
43
38
  "spec/cleanup_reporter.rb",
44
39
  "spec/spec.opts",
@@ -47,7 +42,6 @@ Gem::Specification.new do |s|
47
42
  s.homepage = %q{http://github.com/approvaltests/approval_tests}
48
43
  s.rdoc_options = ["--charset=UTF-8"]
49
44
  s.require_paths = ["lib"]
50
- s.rubyforge_project = %q{approvaltests}
51
45
  s.rubygems_version = %q{1.3.4}
52
46
  s.summary = %q{Approval testing library}
53
47
  s.test_files = [
@@ -4,7 +4,6 @@ require "#{__DIR__}/namers/rspec_namer"
4
4
  require "#{__DIR__}/approvers/file_approver"
5
5
  require "#{__DIR__}/writers/text_writer"
6
6
  require "#{__DIR__}/writers/html_writer"
7
- require "#{__DIR__}/writers/xml_writer"
8
7
  require "#{__DIR__}/reporters/quiet_reporter"
9
8
  require "#{__DIR__}/reporters/text_mate_reporter"
10
9
  require "#{__DIR__}/reporters/diff_reporter"
@@ -38,32 +37,25 @@ module ApprovalTests
38
37
  end
39
38
  approve(out)
40
39
  end
41
- def approve(data)
42
- approve_with_writer(TextWriter.new(data))
43
- end
44
-
45
- def approve_html(data)
46
- approve_with_writer(HtmlWriter.new(data))
47
- end
48
-
49
- def approve_xml(data)
50
- approve_with_writer(TextWriter.new(XmlWriter.pretty_xml(data)))
51
- end
52
-
53
- def approve_with_writer(writer)
54
- approver = FileApprover.new(writer, @namer)
55
- if approver.approve()
56
- approver.clean_up_after_success()
57
- else
58
- @reporter = get_default_reporter()
59
- approver.report_failure(@reporter)
40
+ def approve(data, writer_option = :text)
41
+ case writer_option
42
+ when :html then writer = HtmlWriter.new(data)
43
+ when :text then writer = TextWriter.new(data)
44
+ end
45
+
46
+ approver = FileApprover.new(writer, @namer)
47
+ if approver.approve()
48
+ approver.clean_up_after_success()
49
+ else
50
+ @reporter = get_default_reporter()
51
+ approver.report_failure(@reporter)
60
52
 
61
- if @reporter.approved_when_reported()
62
- approver.clean_up_after_sucess()
63
- else
64
- approver.fail()
65
- end
53
+ if @reporter.approved_when_reported()
54
+ approver.clean_up_after_sucess()
55
+ else
56
+ approver.fail()
66
57
  end
58
+ end
67
59
  end
68
60
 
69
61
  def namer=(namer)
@@ -45,11 +45,6 @@ describe "Approvals" do
45
45
  end
46
46
  end
47
47
 
48
- describe "xml" do
49
- it "should be pretty" do
50
- Approvals.approve_xml('<?xml version="1.0" encoding="ISO-8859-1"?><data><a><b>Bee</b><c>Sea</c></a></data>')
51
- end
52
- end
53
48
 
54
49
  describe "DiffReporter" do
55
50
  it "should launch" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: approvals-approval_tests
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Gilkerson, Llewellyn Falco
@@ -9,11 +9,11 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-03 00:00:00 -07:00
12
+ date: 2009-07-02 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
- description: Approval testing library for ruby
16
+ description: Approval testing library
17
17
  email: approvaltests@dangilkerson.com
18
18
  executables: []
19
19
 
@@ -36,18 +36,13 @@ files:
36
36
  - lib/approval_tests/reporters/text_mate_reporter.rb
37
37
  - lib/approval_tests/writers/html_writer.rb
38
38
  - lib/approval_tests/writers/text_writer.rb
39
- - lib/approval_tests/writers/xml_writer.rb
40
39
  - spec/a.txt
41
- - spec/approvals_lists_should_show_empty_lists.approved.txt
42
- - spec/approvals_lists_should_write_arrays.approved.txt
43
- - spec/approvals_lists_should_write_maps.approved.txt
44
40
  - spec/approvals_multiple_describes_should_approve_multiple_describes.approved.txt
45
41
  - spec/approvals_should_approve_shared_behaviors.approved.txt
46
42
  - spec/approvals_should_successfully_approve_text.approved.txt
47
43
  - spec/approvals_spec.rb
48
44
  - spec/approvals_using_approval_blocks.approved.txt
49
45
  - spec/approvals_using_approval_blocks_the_last_statement.approved.txt
50
- - spec/approvals_xml_should_be_pretty.approved.txt
51
46
  - spec/b.txt
52
47
  - spec/cleanup_reporter.rb
53
48
  - spec/spec.opts
@@ -73,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
68
  version:
74
69
  requirements: []
75
70
 
76
- rubyforge_project: approvaltests
71
+ rubyforge_project:
77
72
  rubygems_version: 1.2.0
78
73
  signing_key:
79
74
  specification_version: 3
@@ -1,81 +0,0 @@
1
- require 'rexml/document'
2
- include REXML
3
-
4
- module ApprovalTests
5
- module Writers
6
- class XmlWriter
7
- def initialize(data)
8
- @data = data
9
- end
10
-
11
- def get_approval_filename(basename)
12
- basename + ".approved.xml"
13
- end
14
-
15
- def get_received_filename(basename)
16
- basename + ".received.xml"
17
- end
18
-
19
- def write_received_file(received)
20
- f = File.new("#{received}", "w+")
21
- f.write(@data)
22
- f.close()
23
- f.path
24
- end
25
- class << self
26
- def pretty_print(parent_node, itab)
27
- buffer = ''
28
-
29
- parent_node.elements.each do |node|
30
-
31
- buffer += ' ' * itab + "<#{node.name}#{get_att_list(node)}"
32
-
33
- if node.to_a.length > 0
34
- buffer += ">"
35
- if node.text.nil?
36
- buffer += "\n"
37
- buffer += pretty_print(node,itab+2)
38
- buffer += ' ' * itab + "</#{node.name}>\n"
39
- else
40
- node_text = node.text.strip
41
- if node_text != ''
42
- buffer += node_text
43
- buffer += "</#{node.name}>\n"
44
- else
45
- buffer += "\n" + pretty_print(node,itab+2)
46
- buffer += ' ' * itab + "</#{node.name}>\n"
47
- end
48
- end
49
- else
50
- buffer += "/>\n"
51
- end
52
-
53
- end
54
- buffer
55
- end
56
-
57
- def get_att_list(node)
58
- att_list = ''
59
- node.attributes.each { |attribute, val| att_list += " #{attribute}='#{val}'" }
60
- att_list
61
- end
62
-
63
- def pretty_xml(xml_string)
64
- doc = Document.new(xml_string)
65
-
66
- buffer = ''
67
- xml_declaration = doc.to_s.match('<\?.*\?>').to_s
68
- buffer += "#{xml_declaration}\n" if not xml_declaration.nil?
69
- xml_doctype = doc.to_s.match('<\!.*\">').to_s
70
- buffer += "#{xml_doctype}\n" if not xml_doctype.nil?
71
- buffer += "<#{doc.root.name}#{get_att_list(doc.root)}"
72
- if doc.root.to_a.length > 0
73
- buffer +=">\n#{pretty_print(doc.root,2)}</#{doc.root.name}>"
74
- else
75
- buffer += "/>\n"
76
- end
77
- end
78
- end
79
- end
80
- end
81
- end
@@ -1 +0,0 @@
1
- tv.count = 0
@@ -1 +0,0 @@
1
- name[0] = tom
@@ -1 +0,0 @@
1
- [name] = harry
@@ -1,8 +0,0 @@
1
- <?xml version='1.0' encoding='ISO-8859-1'?>
2
-
3
- <data>
4
- <a>
5
- <b>Bee</b>
6
- <c>Sea</c>
7
- </a>
8
- </data>