suhyo 0.0.5 → 0.0.6

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.0.5
1
+ 0.0.6
@@ -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 index = compacted.index(@content)
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 index < @other_content_index
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 index > @other_content_index
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
@@ -1,3 +1,4 @@
1
+ require 'uri'
1
2
  require 'webrat'
2
3
  require 'suhyo'
3
4
 
@@ -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, /expected the following element's content to include "Foo" before "Bar":/)
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, /expected the following element's content to include "Foo" before "Bar" but "Bar" was not found:/)
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, /expected the following element's content to include "Foo" after "Bar":/)
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, /expected the following element's content to include "Foo" after "Bar" but "Bar" was not found:/)
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
@@ -124,4 +124,4 @@ describe 'Suhyo Webrat Steps' do
124
124
  scenario('webrat.feature', 'partial query string expected, path wrong').should fail_cuke
125
125
  end
126
126
  end
127
- end
127
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{suhyo}
8
- s.version = "0.0.5"
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-14}
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
- - 5
9
- version: 0.0.5
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-14 00:00:00 -06:00
17
+ date: 2010-03-17 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency