w3c_rspec_validators 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/w3c_rspec_validators/validator.rb +18 -2
- data/lib/w3c_rspec_validators/version.rb +1 -1
- data/spec/validator_spec.rb +13 -1
- data/w3c_rspec_validators.gemspec +1 -1
- metadata +11 -11
@@ -8,14 +8,30 @@ module W3cRspecValidators
|
|
8
8
|
@css_validator = CSSValidator.new validator_uri: Config.get["w3c_css_service_uri"]
|
9
9
|
end
|
10
10
|
|
11
|
+
def try method, try_count = 1
|
12
|
+
begin
|
13
|
+
method.call
|
14
|
+
rescue Exception => e
|
15
|
+
raise e if try_count >= 3
|
16
|
+
sleep 3
|
17
|
+
try(method, try_count + 1)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
11
21
|
def validate_html text
|
12
|
-
|
22
|
+
validate = Proc.new {
|
23
|
+
@response = @html_validator.validate_text(text)
|
24
|
+
}
|
25
|
+
try validate
|
13
26
|
raise "Error: Invalid validation response! Tip: check if validator.nu engine is configured correctly" if @response.checked_by.blank?
|
14
27
|
@response
|
15
28
|
end
|
16
29
|
|
17
30
|
def validate_css text
|
18
|
-
|
31
|
+
validate = Proc.new {
|
32
|
+
@response = @css_validator.validate_text(text)
|
33
|
+
}
|
34
|
+
try validate
|
19
35
|
raise "Error: Invalid validation response! Tip: check if validator.nu engine is configured correctly" if @response.checked_by.blank?
|
20
36
|
@response
|
21
37
|
end
|
data/spec/validator_spec.rb
CHANGED
@@ -14,7 +14,7 @@ describe W3cRspecValidators::Validator do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
describe "validate_text" do
|
17
|
-
it "should raise an exception if validation fails silently" do
|
17
|
+
it "should raise an exception if validation fails silently (eg. validator.nu engine misconfiguration)" do
|
18
18
|
class Dummy
|
19
19
|
def checked_by
|
20
20
|
""
|
@@ -27,4 +27,16 @@ describe W3cRspecValidators::Validator do
|
|
27
27
|
}.to raise_exception
|
28
28
|
end
|
29
29
|
end
|
30
|
+
|
31
|
+
describe "error handling" do
|
32
|
+
it "should retry 3 times if there is a connection error" do
|
33
|
+
MarkupValidator.any_instance.stub(:validate_text).and_raise "error"
|
34
|
+
validator = W3cRspecValidators::Validator.new
|
35
|
+
validator.should_receive(:sleep).exactly(2).times
|
36
|
+
|
37
|
+
lambda {
|
38
|
+
validator.validate_html("dummy")
|
39
|
+
}.should raise_error()
|
40
|
+
end
|
41
|
+
end
|
30
42
|
end
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.email = ["dominik@goltermann.cc"]
|
10
10
|
s.homepage = ""
|
11
11
|
s.summary = %q{This gem adds w3c validation in form of rspec matchers}
|
12
|
-
s.description = %q{
|
12
|
+
s.description = %q{Allows testing vor valid html (including html5) and css. In addition you can configure the gem to use a locally installed validation service instead of the online w3c servers}
|
13
13
|
|
14
14
|
s.rubyforge_project = "w3c_rspec_validators"
|
15
15
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: w3c_rspec_validators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: w3c_validators
|
16
|
-
requirement: &
|
16
|
+
requirement: &13658840 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *13658840
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &13658240 !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: *
|
35
|
+
version_requirements: *13658240
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rails
|
38
|
-
requirement: &
|
38
|
+
requirement: &13657220 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
47
|
-
description:
|
48
|
-
|
49
|
-
|
46
|
+
version_requirements: *13657220
|
47
|
+
description: Allows testing vor valid html (including html5) and css. In addition
|
48
|
+
you can configure the gem to use a locally installed validation service instead
|
49
|
+
of the online w3c servers
|
50
50
|
email:
|
51
51
|
- dominik@goltermann.cc
|
52
52
|
executables: []
|