rspec2-rails-views-matchers 0.0.3 → 0.0.4
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/.gitignore +1 -0
- data/.rspec +0 -1
- data/Gemfile.lock +12 -8
- data/README.md +7 -0
- data/Rakefile +14 -1
- data/docs/CHANGELOG.md +26 -2
- data/lib/rspec/rails/views/matchers/have_tag.rb +108 -5
- data/lib/version.rb +5 -5
- data/rspec2-rails-views-matchers.gemspec +2 -0
- data/spec/matchers/form_matchers_spec.rb +212 -0
- data/spec/matchers/have_tag_spec.rb +68 -0
- data/spec/spec_helper.rb +8 -0
- metadata +15 -24
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rspec2-rails-views-matchers (0.0.
|
4
|
+
rspec2-rails-views-matchers (0.0.4)
|
5
5
|
nokogiri (~> 1.4.4)
|
6
6
|
rspec (>= 2.0.0)
|
7
7
|
|
@@ -10,17 +10,21 @@ GEM
|
|
10
10
|
specs:
|
11
11
|
diff-lcs (1.1.2)
|
12
12
|
nokogiri (1.4.4)
|
13
|
-
rspec (2.
|
14
|
-
rspec-core (~> 2.
|
15
|
-
rspec-expectations (~> 2.
|
16
|
-
rspec-mocks (~> 2.
|
17
|
-
rspec-core (2.
|
18
|
-
rspec-expectations (2.
|
13
|
+
rspec (2.5.0)
|
14
|
+
rspec-core (~> 2.5.0)
|
15
|
+
rspec-expectations (~> 2.5.0)
|
16
|
+
rspec-mocks (~> 2.5.0)
|
17
|
+
rspec-core (2.5.1)
|
18
|
+
rspec-expectations (2.5.0)
|
19
19
|
diff-lcs (~> 1.1.2)
|
20
|
-
rspec-mocks (2.
|
20
|
+
rspec-mocks (2.5.0)
|
21
|
+
simplecov (0.4.1)
|
22
|
+
simplecov-html (~> 0.4.3)
|
23
|
+
simplecov-html (0.4.3)
|
21
24
|
|
22
25
|
PLATFORMS
|
23
26
|
ruby
|
24
27
|
|
25
28
|
DEPENDENCIES
|
26
29
|
rspec2-rails-views-matchers!
|
30
|
+
simplecov
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -4,4 +4,17 @@ Bundler::GemHelper.install_tasks
|
|
4
4
|
|
5
5
|
task :default => :spec
|
6
6
|
|
7
|
-
RSpec::Core::RakeTask.new
|
7
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
8
|
+
t.rspec_opts='--tag ~wip'
|
9
|
+
end
|
10
|
+
|
11
|
+
namespace :spec do
|
12
|
+
RSpec::Core::RakeTask.new(:wip) do |t|
|
13
|
+
t.rspec_opts='--tag wip'
|
14
|
+
t.fail_on_error = false
|
15
|
+
end
|
16
|
+
|
17
|
+
RSpec::Core::RakeTask.new(:rcov) do |t|
|
18
|
+
t.rspec_opts=['-r simplecov']
|
19
|
+
end
|
20
|
+
end
|
data/docs/CHANGELOG.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
Changelog
|
2
2
|
=========
|
3
3
|
|
4
4
|
unreleased(TODO)
|
@@ -8,7 +8,31 @@ unreleased(TODO)
|
|
8
8
|
* add description
|
9
9
|
* raise exception when wrong parametres specified(:count and :minimum simultaneously)
|
10
10
|
* organize code
|
11
|
-
* add
|
11
|
+
* add :without to have\_tag?
|
12
|
+
* !make possible constructions like:
|
13
|
+
|
14
|
+
> rendered.should have(3).tags('div').with(:class => 'some-class').and_content(/some content/)
|
15
|
+
|
16
|
+
0.0.5-dev (trial-trip)
|
17
|
+
----------------------
|
18
|
+
|
19
|
+
* TODO: add more matchers:
|
20
|
+
* have\_form(will be finished when "child" matchers will be done)
|
21
|
+
* with\_hidden\_field
|
22
|
+
* with\_text\_field
|
23
|
+
* with\_password\_field
|
24
|
+
* TODO: with\_file\_field?
|
25
|
+
* TODO: with\_text\_area
|
26
|
+
* TODO: with\_check\_box
|
27
|
+
* TODO: with\_radio\_button
|
28
|
+
* with\_select
|
29
|
+
* with\_option
|
30
|
+
* TODO: with\_submit
|
31
|
+
|
32
|
+
0.0.4 (bugfix)
|
33
|
+
--------------
|
34
|
+
|
35
|
+
* additional parameters(:count,:text,:with) rely on each other to match what exactly tester want to match([link to comment](https://github.com/kucaahbe/rspec2-rails-views-matchers/issues#issue/2/comment/848775))
|
12
36
|
|
13
37
|
0.0.3
|
14
38
|
-----
|
@@ -5,7 +5,7 @@ module RSpec
|
|
5
5
|
|
6
6
|
# @api
|
7
7
|
# @private
|
8
|
-
class NokogiriMatcher
|
8
|
+
class NokogiriMatcher
|
9
9
|
attr_reader :failure_message
|
10
10
|
attr_reader :parent_scope, :current_scope
|
11
11
|
|
@@ -45,7 +45,7 @@ module RSpec
|
|
45
45
|
@document = @parent_scope.to_html
|
46
46
|
end
|
47
47
|
|
48
|
-
if tag_presents? and
|
48
|
+
if tag_presents? and content_right? and count_right?
|
49
49
|
@current_scope = @parent_scope
|
50
50
|
@block.call if @block
|
51
51
|
true
|
@@ -91,14 +91,26 @@ module RSpec
|
|
91
91
|
|
92
92
|
case text=@options[:text]
|
93
93
|
when Regexp
|
94
|
-
|
94
|
+
new_scope = @current_scope.css(":regexp('#{text}')",Class.new {
|
95
|
+
def regexp node_set, text
|
96
|
+
node_set.find_all { |node| node.content =~ Regexp.new(text) }
|
97
|
+
end
|
98
|
+
}.new)
|
99
|
+
unless new_scope.empty?
|
100
|
+
@count = new_scope.count
|
95
101
|
true
|
96
102
|
else
|
97
103
|
@failure_message=%Q{#{text.inspect} regexp expected within "#{@tag}" in following template:\n#{@document}}
|
98
104
|
false
|
99
105
|
end
|
100
106
|
else
|
101
|
-
|
107
|
+
new_scope = @current_scope.css(":content('#{text}')",Class.new {
|
108
|
+
def content node_set, text
|
109
|
+
node_set.find_all { |node| node.content == text }
|
110
|
+
end
|
111
|
+
}.new)
|
112
|
+
unless new_scope.empty?
|
113
|
+
@count = new_scope.count
|
102
114
|
true
|
103
115
|
else
|
104
116
|
@failure_message=%Q{"#{text}" expected within "#{@tag}" in following template:\n#{@document}}
|
@@ -141,7 +153,7 @@ module RSpec
|
|
141
153
|
# </html>".should have_tag('body') { with_tag('h1', :text => 'some html document') }
|
142
154
|
# '<div class="one two">'.should have_tag('div', :with => { :class => ['two', 'one'] })
|
143
155
|
# '<div class="one two">'.should have_tag('div', :with => { :class => 'two one' })
|
144
|
-
def have_tag tag,options={}, &block
|
156
|
+
def have_tag tag, options={}, &block
|
145
157
|
@__current_scope_for_nokogiri_matcher = NokogiriMatcher.new(tag, options, &block)
|
146
158
|
end
|
147
159
|
|
@@ -161,5 +173,96 @@ module RSpec
|
|
161
173
|
@__current_scope_for_nokogiri_matcher.should_not have_tag(tag, options, &block)
|
162
174
|
end
|
163
175
|
|
176
|
+
def have_form action_url, method, options={}, &block
|
177
|
+
options[:with] ||= {}
|
178
|
+
id = options[:with].delete(:id)
|
179
|
+
tag = 'form'; tag += '#'+id if id
|
180
|
+
options[:with].merge!(:action => action_url)
|
181
|
+
options[:with].merge!(:method => method.to_s)
|
182
|
+
have_tag tag, options, &block
|
183
|
+
end
|
184
|
+
|
185
|
+
def with_hidden_field name, value=nil
|
186
|
+
options = { :with => { :name => name, :type => 'hidden' } }
|
187
|
+
options[:with].merge!(:value => value) if value
|
188
|
+
@__current_scope_for_nokogiri_matcher.should have_tag('input', options)
|
189
|
+
end
|
190
|
+
|
191
|
+
def without_hidden_field name, value=nil
|
192
|
+
options = { :with => { :name => name, :type => 'hidden' } }
|
193
|
+
options[:with].merge!(:value => value) if value
|
194
|
+
@__current_scope_for_nokogiri_matcher.should_not have_tag('input', options)
|
195
|
+
end
|
196
|
+
|
197
|
+
def with_text_field name, value=nil
|
198
|
+
options = { :with => { :name => name, :type => 'text' } }
|
199
|
+
options[:with].merge!(:value => value) if value
|
200
|
+
@__current_scope_for_nokogiri_matcher.should have_tag('input', options)
|
201
|
+
end
|
202
|
+
|
203
|
+
def without_text_field name, value=nil
|
204
|
+
options = { :with => { :name => name, :type => 'text' } }
|
205
|
+
options[:with].merge!(:value => value) if value
|
206
|
+
@__current_scope_for_nokogiri_matcher.should_not have_tag('input', options)
|
207
|
+
end
|
208
|
+
|
209
|
+
def with_password_field name
|
210
|
+
options = { :with => { :name => name, :type => 'password' } }
|
211
|
+
@__current_scope_for_nokogiri_matcher.should have_tag('input', options)
|
212
|
+
end
|
213
|
+
|
214
|
+
def without_password_field name
|
215
|
+
options = { :with => { :name => name, :type => 'password' } }
|
216
|
+
@__current_scope_for_nokogiri_matcher.should_not have_tag('input', options)
|
217
|
+
end
|
218
|
+
|
219
|
+
def with_select name, options={}, &block
|
220
|
+
options[:with] ||= {}
|
221
|
+
id = options[:with].delete(:id)
|
222
|
+
tag='select'; tag += '#'+id if id
|
223
|
+
options[:with].merge!(:name => name)
|
224
|
+
@__current_scope_for_nokogiri_matcher.should have_tag(tag, options, &block)
|
225
|
+
end
|
226
|
+
|
227
|
+
def without_select name, options={}, &block
|
228
|
+
options[:with] ||= {}
|
229
|
+
id = options[:with].delete(:id)
|
230
|
+
tag='select'; tag += '#'+id if id
|
231
|
+
options[:with].merge!(:name => name)
|
232
|
+
@__current_scope_for_nokogiri_matcher.should_not have_tag(tag, options, &block)
|
233
|
+
end
|
234
|
+
|
235
|
+
def with_option text, value=nil, options={}
|
236
|
+
options[:with] ||= {}
|
237
|
+
if value.is_a?(Hash)
|
238
|
+
options.merge!(value)
|
239
|
+
value=nil
|
240
|
+
end
|
241
|
+
tag='option'
|
242
|
+
options[:with].merge!(:value => value.to_s) if value
|
243
|
+
if options[:selected]
|
244
|
+
options[:with].merge!(:selected => "selected")
|
245
|
+
end
|
246
|
+
options.delete(:selected)
|
247
|
+
options.merge!(:text => text) if text
|
248
|
+
@__current_scope_for_nokogiri_matcher.should have_tag(tag, options)
|
249
|
+
end
|
250
|
+
|
251
|
+
def without_option text, value=nil, options={}
|
252
|
+
options[:with] ||= {}
|
253
|
+
if value.is_a?(Hash)
|
254
|
+
options.merge!(value)
|
255
|
+
value=nil
|
256
|
+
end
|
257
|
+
tag='option'
|
258
|
+
options[:with].merge!(:value => value.to_s) if value
|
259
|
+
if options[:selected]
|
260
|
+
options[:with].merge!(:selected => "selected")
|
261
|
+
end
|
262
|
+
options.delete(:selected)
|
263
|
+
options.merge!(:text => text) if text
|
264
|
+
@__current_scope_for_nokogiri_matcher.should_not have_tag(tag, options)
|
265
|
+
end
|
266
|
+
|
164
267
|
end
|
165
268
|
end
|
data/lib/version.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
module RSpec
|
1
|
+
module RSpec
|
2
2
|
# @private
|
3
|
-
module Rails
|
3
|
+
module Rails
|
4
4
|
# @private
|
5
|
-
module Views
|
5
|
+
module Views
|
6
6
|
# @private
|
7
|
-
module Matchers
|
7
|
+
module Matchers
|
8
8
|
# @private
|
9
|
-
VERSION = "0.0.
|
9
|
+
VERSION = "0.0.4"
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -0,0 +1,212 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "have_form" do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
render_html <<HTML
|
7
|
+
<form action="/books" class="formtastic book" id="new_book" method="post">
|
8
|
+
|
9
|
+
<div style="margin:0;padding:0;display:inline">
|
10
|
+
<input name="authenticity_token" type="hidden" value="718WaH76RAbIVhDlnOidgew62ikn8IUCOyWLEqjw1GE=" />
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<fieldset class="inputs">
|
14
|
+
<ol>
|
15
|
+
<li class="select required" id="book_publisher_input">
|
16
|
+
<label for="book_publisher_id">
|
17
|
+
Publisher<abbr title="required">*</abbr>
|
18
|
+
</label>
|
19
|
+
<select id="book_publisher_id" name="book[publisher_id]">
|
20
|
+
<option value=""></option>
|
21
|
+
<option value="1" selected="selected">The Pragmatic Bookshelf</option>
|
22
|
+
<option value="2">sitepoint</option>
|
23
|
+
<option value="3">O'Reilly</option>
|
24
|
+
</select>
|
25
|
+
</li>
|
26
|
+
|
27
|
+
<li class="string required" id="book_title_input">
|
28
|
+
<label for="book_title">
|
29
|
+
Title<abbr title="required">*</abbr>
|
30
|
+
</label>
|
31
|
+
<input id="book_title" maxlength="255" name="book[title]" size="50" type="text" />
|
32
|
+
</li>
|
33
|
+
|
34
|
+
<li class="string required" id="book_author_input">
|
35
|
+
<label for="book_author">
|
36
|
+
Author<abbr title="required">*</abbr>
|
37
|
+
</label>
|
38
|
+
<input id="book_author" maxlength="255" name="book[author]" size="50" type="text" value="Authorname" />
|
39
|
+
</li>
|
40
|
+
|
41
|
+
<li class="password optional" id="user_password_input">
|
42
|
+
<label for="user_password">
|
43
|
+
Password:
|
44
|
+
</label>
|
45
|
+
<input id="user_password" name="user[password]" size="30" type="password" />
|
46
|
+
</li>
|
47
|
+
|
48
|
+
</ol>
|
49
|
+
</fieldset>
|
50
|
+
</form>
|
51
|
+
HTML
|
52
|
+
end
|
53
|
+
|
54
|
+
context "without &block" do
|
55
|
+
|
56
|
+
it "should find form" do
|
57
|
+
rendered.should have_form("/books", :post)
|
58
|
+
|
59
|
+
self.should_receive(:have_tag).with("form#new_book", :with => { :method => "post", :action => "/books", :class => %w(book formtastic) })
|
60
|
+
rendered.should have_form("/books", "post", :with => { :id => "new_book", :class => %w(book formtastic) })
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should not find form" do
|
64
|
+
rendered.should_not have_form("/some_url", :post)
|
65
|
+
rendered.should_not have_form("/books", :get)
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
context "with &block" do
|
71
|
+
|
72
|
+
context "with_select" do
|
73
|
+
|
74
|
+
it "should find select" do
|
75
|
+
rendered.should have_form("/books", :post) do
|
76
|
+
with_select("book[publisher_id]", :with => { :id => "book_publisher_id" })
|
77
|
+
|
78
|
+
self.should_receive(:have_tag).with("select#book_publisher_id", :with => { :name => "book[publisher_id]" })
|
79
|
+
with_select("book[publisher_id]", :with => { :id => "book_publisher_id" })
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should not find select" do
|
84
|
+
rendered.should have_form("/books", :post) do
|
85
|
+
without_select("book[publisher_id]", :with => { :id => "other_id" })
|
86
|
+
|
87
|
+
self.should_receive(:have_tag).with("select#book_publisher_id", :with => { :name => "koob[publisher_id]" })
|
88
|
+
without_select("koob[publisher_id]", :with => { :id => "book_publisher_id" })
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context "with_option" do
|
93
|
+
|
94
|
+
it "should find options" do
|
95
|
+
rendered.should have_form("/books", :post) do
|
96
|
+
with_select("book[publisher_id]") do
|
97
|
+
with_option(nil)
|
98
|
+
with_option("The Pragmatic Bookshelf", :selected => true)
|
99
|
+
with_option(/sitepoint/,2)
|
100
|
+
|
101
|
+
self.should_receive(:have_tag).with('option', :with => { :value => '3' }, :text => "O'Reilly")
|
102
|
+
with_option("O'Reilly", 3, :selected => false)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should not find options" do
|
108
|
+
rendered.should have_form("/books", :post) do
|
109
|
+
with_select("book[publisher_id]") do
|
110
|
+
without_option("blah blah")
|
111
|
+
without_option("O'Reilly", 3, :selected => true)
|
112
|
+
without_option("O'Reilly", 100500)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
context "with_hidden_field" do
|
122
|
+
|
123
|
+
it "should find hidden field" do
|
124
|
+
rendered.should have_form("/books", :post) do
|
125
|
+
with_hidden_field("authenticity_token")
|
126
|
+
self.should_receive(:have_tag).with('input', :with => { :name => 'authenticity_token', :type => 'hidden', :value => '718WaH76RAbIVhDlnOidgew62ikn8IUCOyWLEqjw1GE=' })
|
127
|
+
with_hidden_field("authenticity_token", '718WaH76RAbIVhDlnOidgew62ikn8IUCOyWLEqjw1GE=')
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should not find hidden field" do
|
132
|
+
rendered.should have_form("/books", :post) do
|
133
|
+
without_hidden_field('user_id')
|
134
|
+
without_hidden_field('authenticity_token', 'blabla')
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
|
140
|
+
context "with_text_field" do
|
141
|
+
|
142
|
+
it "should find text field" do
|
143
|
+
rendered.should have_form("/books", :post) do
|
144
|
+
with_text_field('book[title]')
|
145
|
+
with_text_field('book[title]',nil)
|
146
|
+
with_text_field('book[author]','Authorname')
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should not find text field" do
|
151
|
+
rendered.should have_form("/books", :post) do
|
152
|
+
without_text_field('book[title]','title does not exist')
|
153
|
+
without_text_field('book[authoRR]')
|
154
|
+
without_text_field('book[blabla]')
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
context "with_password_field" do
|
161
|
+
|
162
|
+
it "should find password field" do
|
163
|
+
rendered.should have_form("/books", :post) do
|
164
|
+
with_password_field('user[password]')
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should not find password field" do
|
169
|
+
rendered.should have_form("/books", :post) do
|
170
|
+
without_password_field('account[password]')
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
end
|
175
|
+
|
176
|
+
context "with_file_field" do
|
177
|
+
|
178
|
+
it "should find file field"
|
179
|
+
it "should not find file field"
|
180
|
+
|
181
|
+
end
|
182
|
+
|
183
|
+
context "with_text_area" do
|
184
|
+
|
185
|
+
it "should find text area"
|
186
|
+
it "should not find text area"
|
187
|
+
|
188
|
+
end
|
189
|
+
|
190
|
+
context "with_check_box" do
|
191
|
+
|
192
|
+
it "should find check box"
|
193
|
+
it "should not find check box"
|
194
|
+
|
195
|
+
end
|
196
|
+
|
197
|
+
context "with_radio_button" do
|
198
|
+
|
199
|
+
it "should find radio button"
|
200
|
+
it "should not find radio button"
|
201
|
+
|
202
|
+
end
|
203
|
+
|
204
|
+
context "with_submit" do
|
205
|
+
|
206
|
+
it "should find submit"
|
207
|
+
it "should not find submit"
|
208
|
+
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
212
|
+
end
|
@@ -209,6 +209,74 @@ HTML
|
|
209
209
|
|
210
210
|
end
|
211
211
|
|
212
|
+
context "mixed matching" do
|
213
|
+
|
214
|
+
before :each do
|
215
|
+
render_html <<HTML
|
216
|
+
<table>
|
217
|
+
<tr>
|
218
|
+
<td>user_1</td>
|
219
|
+
<td id="other-special">user_2</td>
|
220
|
+
<td>user_3</td>
|
221
|
+
</tr>
|
222
|
+
<tr>
|
223
|
+
<td>a</td>
|
224
|
+
<td id="special">a</td>
|
225
|
+
<td>a</td>
|
226
|
+
</tr>
|
227
|
+
</table>
|
228
|
+
|
229
|
+
<div class="one">text</div>
|
230
|
+
<div class="one">text</div>
|
231
|
+
<div class="one">text</div>
|
232
|
+
<div class="one">text bla</div>
|
233
|
+
<div class="one">content bla</div>
|
234
|
+
<div class="one">content</div>
|
235
|
+
<div class="two">content bla</div>
|
236
|
+
<div class="two">content</div>
|
237
|
+
<div class="two">text</div>
|
238
|
+
HTML
|
239
|
+
end
|
240
|
+
|
241
|
+
it "should find tags by count and exact content" do
|
242
|
+
rendered.should have_tag("td", :text => 'a', :count => 3)
|
243
|
+
end
|
244
|
+
|
245
|
+
it "should find tags by count and rough content(regexp)" do
|
246
|
+
rendered.should have_tag("td", :text => /user/, :count => 3)
|
247
|
+
end
|
248
|
+
|
249
|
+
it "should find tags with exact content and additional attributes" do
|
250
|
+
rendered.should have_tag("td", :text => 'a', :with => { :id => "special" })
|
251
|
+
rendered.should_not have_tag("td", :text => 'a', :with => { :id => "other-special" })
|
252
|
+
end
|
253
|
+
|
254
|
+
it "should find tags with rough content and additional attributes" do
|
255
|
+
rendered.should have_tag("td", :text => /user/, :with => { :id => "other-special" })
|
256
|
+
rendered.should_not have_tag("td", :text => /user/, :with => { :id => "special" })
|
257
|
+
end
|
258
|
+
|
259
|
+
it "should find tags with count and additional attributes" do
|
260
|
+
rendered.should have_tag("div", :with => { :class => "one" }, :count => 6)
|
261
|
+
rendered.should have_tag("div", :with => { :class => "two" }, :count => 3)
|
262
|
+
end
|
263
|
+
|
264
|
+
it "should find tags with count, exact text and additional attributes" do
|
265
|
+
rendered.should have_tag("div", :with => { :class => "one" }, :count => 3, :text => 'text')
|
266
|
+
rendered.should_not have_tag("div", :with => { :class => "one" }, :count => 5, :text => 'text')
|
267
|
+
rendered.should_not have_tag("div", :with => { :class => "one" }, :count => 3, :text => 'other text')
|
268
|
+
rendered.should_not have_tag("div", :with => { :class => "two" }, :count => 3, :text => 'text')
|
269
|
+
end
|
270
|
+
|
271
|
+
it "should find tags with count, regexp text and additional attributes" do
|
272
|
+
rendered.should have_tag("div", :with => { :class => "one" }, :count => 2, :text => /bla/)
|
273
|
+
rendered.should have_tag("div", :with => { :class => "two" }, :count => 1, :text => /bla/)
|
274
|
+
rendered.should_not have_tag("div", :with => { :class => "one" }, :count => 5, :text => /bla/)
|
275
|
+
rendered.should_not have_tag("div", :with => { :class => "one" }, :count => 6, :text => /other bla/)
|
276
|
+
end
|
277
|
+
|
278
|
+
end
|
279
|
+
|
212
280
|
context "nested matching:" do
|
213
281
|
before :each do
|
214
282
|
@ordered_list =<<OL
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec2-rails-views-matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 25
|
5
4
|
prerelease:
|
6
|
-
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 3
|
10
|
-
version: 0.0.3
|
5
|
+
version: 0.0.4
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- kucaahbe
|
@@ -15,7 +10,7 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date: 2011-03-
|
13
|
+
date: 2011-03-09 00:00:00 +02:00
|
19
14
|
default_executable:
|
20
15
|
dependencies:
|
21
16
|
- !ruby/object:Gem::Dependency
|
@@ -26,11 +21,6 @@ dependencies:
|
|
26
21
|
requirements:
|
27
22
|
- - ">="
|
28
23
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 15
|
30
|
-
segments:
|
31
|
-
- 2
|
32
|
-
- 0
|
33
|
-
- 0
|
34
24
|
version: 2.0.0
|
35
25
|
type: :runtime
|
36
26
|
version_requirements: *id001
|
@@ -42,14 +32,20 @@ dependencies:
|
|
42
32
|
requirements:
|
43
33
|
- - ~>
|
44
34
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 15
|
46
|
-
segments:
|
47
|
-
- 1
|
48
|
-
- 4
|
49
|
-
- 4
|
50
35
|
version: 1.4.4
|
51
36
|
type: :runtime
|
52
37
|
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: simplecov
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id003
|
53
49
|
description: Nokogiri based 'have_tag' and 'with_tag' for rspec-2 without assert_select dependencies and useful error messages
|
54
50
|
email:
|
55
51
|
- kucaahbe@ukr.net
|
@@ -73,6 +69,7 @@ files:
|
|
73
69
|
- lib/rspec2-rails-views-matchers.rb
|
74
70
|
- lib/version.rb
|
75
71
|
- rspec2-rails-views-matchers.gemspec
|
72
|
+
- spec/matchers/form_matchers_spec.rb
|
76
73
|
- spec/matchers/have_tag_spec.rb
|
77
74
|
- spec/spec_helper.rb
|
78
75
|
- spec/support/spec_error.rb
|
@@ -90,23 +87,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
87
|
requirements:
|
91
88
|
- - ">="
|
92
89
|
- !ruby/object:Gem::Version
|
93
|
-
hash: 3
|
94
|
-
segments:
|
95
|
-
- 0
|
96
90
|
version: "0"
|
97
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
92
|
none: false
|
99
93
|
requirements:
|
100
94
|
- - ">="
|
101
95
|
- !ruby/object:Gem::Version
|
102
|
-
hash: 3
|
103
|
-
segments:
|
104
|
-
- 0
|
105
96
|
version: "0"
|
106
97
|
requirements: []
|
107
98
|
|
108
99
|
rubyforge_project: rspec2-rails-views-matchers
|
109
|
-
rubygems_version: 1.5.
|
100
|
+
rubygems_version: 1.5.2
|
110
101
|
signing_key:
|
111
102
|
specification_version: 3
|
112
103
|
summary: Nokogiri based 'have_tag' and 'with_tag' for rspec-2 without assert_select dependencies and useful error messages
|