html_acceptance 0.1.7 → 0.1.8

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.7
1
+ 0.1.8
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{html_acceptance}
8
- s.version = "0.1.7"
8
+ s.version = "0.1.8"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Eric Beland"]
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
30
30
  "lib/html_acceptance.rb",
31
31
  "lib/html_acceptance/html_acceptance_result.rb",
32
32
  "lib/tasks/html_acceptance.rake",
33
+ "samples/have_valid_html.rb",
33
34
  "spec/html_acceptance_spec.rb",
34
35
  "spec/spec_helper.rb"
35
36
  ]
@@ -0,0 +1,32 @@
1
+ require 'html_acceptance'
2
+
3
+ # This is a sample matcher for use with Rspec and Capybara.
4
+ # https://github.com/jnicklas/capybara
5
+ # keep this in spec/support/matchers
6
+
7
+ class HaveValidHTML
8
+
9
+ # This is the matching method called by RSpec
10
+ # The response is passed in as an argument when you do this:
11
+ # page.should have_valid_html
12
+
13
+ def matches?(page)
14
+ path=File.join(File.dirname(__FILE__), '../validation' )
15
+ h=HTMLAcceptance.new(path)
16
+ @v=h.validator(page.body, page.current_url)
17
+ @v.valid?
18
+ end
19
+
20
+ def description
21
+ "Have valid html"
22
+ end
23
+
24
+ def failure_message
25
+ "#{@v.resource} Invalid html (fix or run rake html_acceptance task to add exceptions)\n#{@v.resource} exceptions:\n #{@v.exceptions}\n\n #{@v.html}"
26
+ end
27
+
28
+ end
29
+
30
+ def have_valid_html
31
+ HaveValidHTML.new
32
+ end
@@ -63,27 +63,35 @@ describe "HtmlAcceptance" do
63
63
  result=@h.validator("<html></body></html>", "http://mycoolsite.com").valid?.should be_false
64
64
  end
65
65
 
66
- it "should let me pass a tidy option" do
67
- @h=HTMLAcceptance.new('/tmp/validation', :tidy_opts=>"-e")
68
- result=@h.validator("<html>foo", 'c:\mycoolapp\somesite.html')
69
- result.exceptions.include?("were found!").should be_true
70
- @h=HTMLAcceptance.new('/tmp/validation')
71
- result=@h.validator("<html>foo", 'c:\mycoolapp\somesite.html')
72
- result.exceptions.include?("were found!").should be_false
73
- end
74
-
75
-
76
- it "should yeild exception results" do
77
- @h=HTMLAcceptance.new('/tmp/validation', :tidy_opts=>"-e")
78
- result=@h.validator("<html>foo", 'c:\evencooler.com\somesite.html')
79
- had_exceptions=false
80
- @h.each_exception do |e|
81
- had_exceptions=true
82
- e.is_a?(HTMLAcceptanceResult).should be_true
83
- (e.resource.length > 0).should be_true
84
- (e.html.length > 0).should be_true
85
- end
86
- had_exceptions.should be_true
66
+
67
+ describe "when launching HTML Tidy" do
68
+
69
+ it "should let me pass different Tidy command line options" do
70
+ @h=HTMLAcceptance.new('/tmp/validation', :tidy_opts=>"-e")
71
+ result=@h.validator("<html>foo", 'c:\mycoolapp\somesite.html')
72
+ result.exceptions.include?("were found!").should be_true
73
+ @h=HTMLAcceptance.new('/tmp/validation')
74
+ result=@h.validator("<html>foo", 'c:\mycoolapp\somesite.html')
75
+ result.exceptions.include?("were found!").should be_false
76
+ end
77
+
78
+ end
79
+
80
+ describe "when walking exception results" do
81
+
82
+ it "should yield loaded exception results" do
83
+ @h=HTMLAcceptance.new('/tmp/validation')
84
+ result=@h.validator("<html>foo", 'c:\evencooler.com\somesite.html')
85
+ had_exceptions=false
86
+ @h.each_exception do |e|
87
+ had_exceptions=true
88
+ e.is_a?(HTMLAcceptanceResult).should be_true
89
+ (e.resource.length > 0).should be_true
90
+ (e.html.length > 0).should be_true
91
+ end
92
+ had_exceptions.should be_true
93
+ end
94
+
87
95
  end
88
96
 
89
97
  private
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html_acceptance
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 7
10
- version: 0.1.7
9
+ - 8
10
+ version: 0.1.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Eric Beland
@@ -103,6 +103,7 @@ files:
103
103
  - lib/html_acceptance.rb
104
104
  - lib/html_acceptance/html_acceptance_result.rb
105
105
  - lib/tasks/html_acceptance.rake
106
+ - samples/have_valid_html.rb
106
107
  - spec/html_acceptance_spec.rb
107
108
  - spec/spec_helper.rb
108
109
  has_rdoc: true