suhyo 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/suhyo/view_matchers.rb +6 -6
- data/lib/suhyo/webrat_steps.rb +1 -0
- data/spec/view_matchers_spec.rb +18 -4
- data/spec/webrat_steps_spec.rb +1 -1
- data/suhyo.gemspec +2 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/lib/suhyo/view_matchers.rb
CHANGED
@@ -21,20 +21,20 @@ module Suhyo
|
|
21
21
|
@document = Webrat::XML.document(stringlike)
|
22
22
|
@element = @document.inner_text
|
23
23
|
compacted = @element.gsub(/\s+/, ' ')
|
24
|
-
if
|
24
|
+
if @main_content_index = compacted.index(@content)
|
25
25
|
if @options.has_key?(:before)
|
26
26
|
@other_content_index = compacted.index(@options[:before])
|
27
27
|
if @other_content_index.nil?
|
28
28
|
return false
|
29
29
|
else
|
30
|
-
return
|
30
|
+
return @main_content_index < @other_content_index
|
31
31
|
end
|
32
32
|
elsif @options.has_key?(:after)
|
33
33
|
@other_content_index = compacted.index(@options[:after])
|
34
34
|
if @other_content_index.nil?
|
35
35
|
return false
|
36
36
|
else
|
37
|
-
return
|
37
|
+
return @main_content_index > @other_content_index
|
38
38
|
end
|
39
39
|
else
|
40
40
|
return true
|
@@ -55,13 +55,13 @@ module Suhyo
|
|
55
55
|
def order_message
|
56
56
|
if @options.has_key?(:before)
|
57
57
|
str = %Q{ before "#{@options[:before]}"}
|
58
|
-
if @other_content_index.nil?
|
58
|
+
if !@main_content_index.nil? and @other_content_index.nil?
|
59
59
|
str << %Q{ but "#{@options[:before]}" was not found}
|
60
60
|
end
|
61
61
|
return str
|
62
62
|
elsif @options.has_key?(:after)
|
63
63
|
str = %Q{ after "#{@options[:after]}"}
|
64
|
-
if @other_content_index.nil?
|
64
|
+
if !@main_content_index.nil? and @other_content_index.nil?
|
65
65
|
str << %Q{ but "#{@options[:after]}" was not found}
|
66
66
|
end
|
67
67
|
return str
|
@@ -178,4 +178,4 @@ module Suhyo
|
|
178
178
|
HaveRestfulForm.new(method, options)
|
179
179
|
end
|
180
180
|
end
|
181
|
-
end
|
181
|
+
end
|
data/lib/suhyo/webrat_steps.rb
CHANGED
data/spec/view_matchers_spec.rb
CHANGED
@@ -76,13 +76,20 @@ describe Suhyo::ViewMatchers do
|
|
76
76
|
it 'tells the expected order in the error message' do
|
77
77
|
lambda do
|
78
78
|
'<p>Bar</p><p>Foo</p>'.should contain_in_order('Foo', :before => 'Bar')
|
79
|
-
end.should raise_error(Spec::Expectations::ExpectationNotMetError,
|
79
|
+
end.should raise_error(Spec::Expectations::ExpectationNotMetError, /^expected the following element's content to include "Foo" before "Bar":/)
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'tells you if the reference content is missing' do
|
83
83
|
lambda do
|
84
84
|
'<p>Foo</p><p>...</p>'.should contain_in_order('Foo', :before => 'Bar')
|
85
|
-
end.should raise_error(Spec::Expectations::ExpectationNotMetError,
|
85
|
+
end.should raise_error(Spec::Expectations::ExpectationNotMetError, /^expected the following element's content to include "Foo" before "Bar" but "Bar" was not found:/)
|
86
|
+
end
|
87
|
+
|
88
|
+
# Bug fix
|
89
|
+
it 'does not falsely tell you the reference content is missing when the main content is missing' do
|
90
|
+
lambda do
|
91
|
+
'<p>...</p><p>Bar</p>'.should contain_in_order('Foo', :before => 'Bar')
|
92
|
+
end.should raise_error(Spec::Expectations::ExpectationNotMetError, /^expected the following element\'s content to include "Foo" before "Bar":/)
|
86
93
|
end
|
87
94
|
end
|
88
95
|
|
@@ -106,13 +113,20 @@ describe Suhyo::ViewMatchers do
|
|
106
113
|
it 'tells the expected order in the error message' do
|
107
114
|
lambda do
|
108
115
|
'<p>Foo</p><p>Bar</p>'.should contain_in_order('Foo', :after => 'Bar')
|
109
|
-
end.should raise_error(Spec::Expectations::ExpectationNotMetError,
|
116
|
+
end.should raise_error(Spec::Expectations::ExpectationNotMetError, /^expected the following element's content to include "Foo" after "Bar":/)
|
110
117
|
end
|
111
118
|
|
112
119
|
it 'tells you if the reference content is missing' do
|
113
120
|
lambda do
|
114
121
|
'<p>...</p><p>Foo</p>'.should contain_in_order('Foo', :after => 'Bar')
|
115
|
-
end.should raise_error(Spec::Expectations::ExpectationNotMetError,
|
122
|
+
end.should raise_error(Spec::Expectations::ExpectationNotMetError, /^expected the following element's content to include "Foo" after "Bar" but "Bar" was not found:/)
|
123
|
+
end
|
124
|
+
|
125
|
+
# Bug fix
|
126
|
+
it 'does not falsely tell you the reference content is missing when the main content is missing' do
|
127
|
+
lambda do
|
128
|
+
'<p>Bar</p><p>...</p>'.should contain_in_order('Foo', :after => 'Bar')
|
129
|
+
end.should raise_error(Spec::Expectations::ExpectationNotMetError, /^expected the following element's content to include "Foo" after "Bar":/)
|
116
130
|
end
|
117
131
|
end
|
118
132
|
end
|
data/spec/webrat_steps_spec.rb
CHANGED
data/suhyo.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{suhyo}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["jarrett"]
|
12
|
-
s.date = %q{2010-03-
|
12
|
+
s.date = %q{2010-03-17}
|
13
13
|
s.description = %q{Matchers built on Webrat to address some common needs in web app testing}
|
14
14
|
s.email = %q{jarrett@uchicago.edu}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 6
|
9
|
+
version: 0.0.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- jarrett
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-17 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|