hiroeorz-rspec-w3c-matchers 0.1.0
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/LICENSE +20 -0
- data/README.rdoc +7 -0
- data/Rakefile +48 -0
- data/VERSION.yml +4 -0
- data/lib/rspec_w3c_matchers.rb +87 -0
- data/spec/rspec_w3c_matchers_spec.rb +6 -0
- data/spec/spec_helper.rb +9 -0
- metadata +80 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 hiroeorz
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "rspec-w3c-matchers"
|
8
|
+
gem.summary = %Q{TODO}
|
9
|
+
gem.email = "hiroe.orz@gmail.com"
|
10
|
+
gem.homepage = "http://github.com/hiroeorz/rspec-w3c-matchers"
|
11
|
+
gem.authors = ["hiroeorz"]
|
12
|
+
|
13
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
14
|
+
end
|
15
|
+
rescue LoadError
|
16
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'spec/rake/spectask'
|
20
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
21
|
+
spec.libs << 'lib' << 'spec'
|
22
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
23
|
+
end
|
24
|
+
|
25
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
26
|
+
spec.libs << 'lib' << 'spec'
|
27
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
28
|
+
spec.rcov = true
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
task :default => :spec
|
33
|
+
|
34
|
+
require 'rake/rdoctask'
|
35
|
+
Rake::RDocTask.new do |rdoc|
|
36
|
+
if File.exist?('VERSION.yml')
|
37
|
+
config = YAML.load(File.read('VERSION.yml'))
|
38
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
39
|
+
else
|
40
|
+
version = ""
|
41
|
+
end
|
42
|
+
|
43
|
+
rdoc.rdoc_dir = 'rdoc'
|
44
|
+
rdoc.title = "rspec-w3c-matchers #{version}"
|
45
|
+
rdoc.rdoc_files.include('README*')
|
46
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
47
|
+
end
|
48
|
+
|
data/VERSION.yml
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
begin
|
2
|
+
require "rubygems"
|
3
|
+
rescue
|
4
|
+
end
|
5
|
+
|
6
|
+
require "w3c_validators"
|
7
|
+
|
8
|
+
class BeW3CValidHtml
|
9
|
+
include W3CValidators
|
10
|
+
|
11
|
+
def initialize(format = nil)
|
12
|
+
@html_validator = MarkupValidator.new
|
13
|
+
@html_validator.set_charset!(:utf_8)
|
14
|
+
@html_validator.set_doctype!(format) if format
|
15
|
+
@html_validator.set_debug!(true)
|
16
|
+
end
|
17
|
+
|
18
|
+
def matches?(target)
|
19
|
+
if defined?(target.body)
|
20
|
+
@target = target.body
|
21
|
+
else
|
22
|
+
@target = target.to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
@result = @html_validator.validate_text(@target)
|
26
|
+
|
27
|
+
print_warnings
|
28
|
+
|
29
|
+
@result.is_valid?
|
30
|
+
end
|
31
|
+
|
32
|
+
def print_warnings
|
33
|
+
warn_flg = false
|
34
|
+
msg = "\n"
|
35
|
+
|
36
|
+
@result.warnings.each do |e|
|
37
|
+
next if e.to_s =~ /DOCTYPE Override in effect!/
|
38
|
+
msg << "\n #{e.to_s}\n";
|
39
|
+
warn_flg = true
|
40
|
+
end
|
41
|
+
|
42
|
+
puts msg if warn_flg
|
43
|
+
end
|
44
|
+
|
45
|
+
def failure_message_for_should
|
46
|
+
msg = "expected be xhtml 1.0 strict, but was not validated.\n"
|
47
|
+
msg << "\n"
|
48
|
+
|
49
|
+
@result.errors.each do |e|
|
50
|
+
msg << "\n #{e.to_s}\n"
|
51
|
+
end
|
52
|
+
|
53
|
+
msg
|
54
|
+
end
|
55
|
+
|
56
|
+
def failure_message_for_should_not
|
57
|
+
"expected not be xhtml 1.0 strict, but was validated.\n"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def be_valid_html(format = nil)
|
62
|
+
BeW3CValidHtml.new(format)
|
63
|
+
end
|
64
|
+
|
65
|
+
def be_xhtml_10_strict
|
66
|
+
BeW3CValidHtml.new(:xhtml10_strict)
|
67
|
+
end
|
68
|
+
|
69
|
+
def be_xhtml_10_transitional
|
70
|
+
BeW3CValidHtml.new(:xhtml10_transitional)
|
71
|
+
end
|
72
|
+
|
73
|
+
def be_xhtml_10_frameset
|
74
|
+
BeW3CValidHtml.new(:xhtml10_frameset)
|
75
|
+
end
|
76
|
+
|
77
|
+
def be_xhtml_11
|
78
|
+
BeW3CValidHtml.new(:xhtml11)
|
79
|
+
end
|
80
|
+
|
81
|
+
def be_xhtml_basic_10
|
82
|
+
BeW3CValidHtml.new(:xhtml_basic10)
|
83
|
+
end
|
84
|
+
|
85
|
+
# see http://code.dunae.ca/w3c_validators/doc
|
86
|
+
#
|
87
|
+
# W3CValidators#DOCTYPE
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hiroeorz-rspec-w3c-matchers
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- hiroeorz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-04-18 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.2.4
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: w3c_validators
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.9.3
|
34
|
+
version:
|
35
|
+
description:
|
36
|
+
email: hiroe.orz@gmail.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README.rdoc
|
44
|
+
files:
|
45
|
+
- LICENSE
|
46
|
+
- README.rdoc
|
47
|
+
- Rakefile
|
48
|
+
- VERSION.yml
|
49
|
+
- lib/rspec_w3c_matchers.rb
|
50
|
+
- spec/rspec_w3c_matchers_spec.rb
|
51
|
+
- spec/spec_helper.rb
|
52
|
+
has_rdoc: true
|
53
|
+
homepage: http://github.com/hiroeorz/rspec-w3c-matchers
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options:
|
56
|
+
- --charset=UTF-8
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: "0"
|
70
|
+
version:
|
71
|
+
requirements: []
|
72
|
+
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 1.2.0
|
75
|
+
signing_key:
|
76
|
+
specification_version: 2
|
77
|
+
summary: TODO
|
78
|
+
test_files:
|
79
|
+
- spec/spec_helper.rb
|
80
|
+
- spec/rspec_w3c_matchers_spec.rb
|