rspec-html-matchers 0.9.2 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RSpecHtmlMatchers
2
- VERSION = '0.9.2'
4
+ VERSION = '0.9.4'
3
5
  end
@@ -1,53 +1,55 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
- describe "have_form" do
5
+ describe 'have_form' do
4
6
  asset 'form'
5
7
 
6
- context "without &block" do
7
- it "should find form" do
8
+ context '[without &block]' do
9
+ it 'should find form' do
8
10
  # sanity check
9
- expect(rendered).to have_form("/books", :post)
10
- expect(rendered).to have_form("/books", "post", :with => { :id => "new_book", :class => %w(book formtastic) })
11
+ expect(rendered).to have_form('/books', :post)
12
+ expect(rendered).to have_form('/books', 'post', :with => { :id => 'new_book', :class => %w[book formtastic] })
11
13
  end
12
14
 
13
- it "should not find form" do
14
- expect(rendered).to_not have_form("/some_url", :post)
15
- expect(rendered).to_not have_form("/books", :get)
15
+ it 'should not find form' do
16
+ expect(rendered).to_not have_form('/some_url', :post)
17
+ expect(rendered).to_not have_form('/books', :get)
16
18
  end
17
19
  end
18
20
 
19
- context "with &block" do
20
- context "with_select" do
21
- it "should find select" do
22
- expect(rendered).to have_form("/books", :post) do
23
- with_select("book[publisher_id]", :with => { :id => "book_publisher_id" })
24
- with_select("book[publisher_id]", :with => { :id => "book_publisher_id" })
21
+ context '[with &block]' do
22
+ context '[with_select]' do
23
+ it 'should find select' do
24
+ expect(rendered).to have_form('/books', :post) do
25
+ with_select('book[publisher_id]', :with => { :id => 'book_publisher_id' })
26
+ with_select('book[publisher_id]', :with => { :id => 'book_publisher_id' })
25
27
  end
26
28
  end
27
29
 
28
- it "should not find select" do
29
- expect(rendered).to have_form("/books", :post) do
30
- without_select("book[publisher_id]", :with => { :id => "other_id" })
31
- without_select("koob[publisher_id]", :with => { :id => "book_publisher_id" })
30
+ it 'should not find select' do
31
+ expect(rendered).to have_form('/books', :post) do
32
+ without_select('book[publisher_id]', :with => { :id => 'other_id' })
33
+ without_select('koob[publisher_id]', :with => { :id => 'book_publisher_id' })
32
34
  end
33
35
  end
34
36
 
35
- context "with_option" do
36
- it "should find options" do
37
- expect(rendered).to have_form("/books", :post) do
38
- with_select("book[publisher_id]") do
37
+ context '[with_option]' do
38
+ it 'should find options' do
39
+ expect(rendered).to have_form('/books', :post) do
40
+ with_select('book[publisher_id]') do
39
41
  with_option(nil)
40
- with_option("The Pragmatic Bookshelf", :selected => true)
41
- with_option(/sitepoint/,2)
42
+ with_option('The Pragmatic Bookshelf', :selected => true)
43
+ with_option(/sitepoint/, 2)
42
44
  with_option("O'Reilly", 3, :selected => false)
43
45
  end
44
46
  end
45
47
  end
46
48
 
47
- it "should not find options" do
48
- expect(rendered).to have_form("/books", :post) do
49
- with_select("book[publisher_id]") do
50
- without_option("blah blah")
49
+ it 'should not find options' do
50
+ expect(rendered).to have_form('/books', :post) do
51
+ with_select('book[publisher_id]') do
52
+ without_option('blah blah')
51
53
  without_option("O'Reilly", 3, :selected => true)
52
54
  without_option("O'Reilly", 100500)
53
55
  end
@@ -55,245 +57,245 @@ describe "have_form" do
55
57
  end
56
58
  end
57
59
 
58
- context "with_button" do
59
- it "should find button" do
60
- expect(rendered).to have_form("/books", :post) do
61
- with_button("Cancel Book")
60
+ context '[with_button]' do
61
+ it 'should find button' do
62
+ expect(rendered).to have_form('/books', :post) do
63
+ with_button('Cancel Book')
62
64
  end
63
65
  end
64
66
 
65
- it "should not find button" do
66
- expect(rendered).to have_form("/books", :post) do
67
- without_button("Create Book")
67
+ it 'should not find button' do
68
+ expect(rendered).to have_form('/books', :post) do
69
+ without_button('Create Book')
68
70
  end
69
71
  end
70
72
  end
71
73
  end
72
74
 
73
- context "with_hidden_field" do
74
- it "should find hidden field" do
75
- expect(rendered).to have_form("/books", :post) do
76
- with_hidden_field("authenticity_token")
77
- with_hidden_field("authenticity_token", '718WaH76RAbIVhDlnOidgew62ikn8IUCOyWLEqjw1GE=')
75
+ context '[with_hidden_field]' do
76
+ it 'should find hidden field' do
77
+ expect(rendered).to have_form('/books', :post) do
78
+ with_hidden_field('authenticity_token')
79
+ with_hidden_field('authenticity_token', '718WaH76RAbIVhDlnOidgew62ikn8IUCOyWLEqjw1GE=')
78
80
  end
79
81
  end
80
82
 
81
- it "should not find hidden field" do
82
- expect(rendered).to have_form("/books", :post) do
83
+ it 'should not find hidden field' do
84
+ expect(rendered).to have_form('/books', :post) do
83
85
  without_hidden_field('user_id')
84
86
  without_hidden_field('authenticity_token', 'blabla')
85
87
  end
86
88
  end
87
89
  end
88
90
 
89
- context "with_text_field" do
90
- it "should find text field" do
91
- expect(rendered).to have_form("/books", :post) do
91
+ context '[with_text_field]' do
92
+ it 'should find text field' do
93
+ expect(rendered).to have_form('/books', :post) do
92
94
  with_text_field('book[title]')
93
- with_text_field('book[title]',nil)
94
- with_text_field('book[author]','Authorname')
95
+ with_text_field('book[title]', nil)
96
+ with_text_field('book[author]', 'Authorname')
95
97
  end
96
98
  end
97
99
 
98
- it "should not find text field" do
99
- expect(rendered).to have_form("/books", :post) do
100
- without_text_field('book[title]','title does not exist')
100
+ it 'should not find text field' do
101
+ expect(rendered).to have_form('/books', :post) do
102
+ without_text_field('book[title]', 'title does not exist')
101
103
  without_text_field('book[authoRR]')
102
104
  without_text_field('book[blabla]')
103
105
  end
104
106
  end
105
107
  end
106
108
 
107
- context "with_email_field" do
108
- it "should find email field" do
109
- expect(rendered).to have_form("/books", :post) do
109
+ context '[with_email_field]' do
110
+ it 'should find email field' do
111
+ expect(rendered).to have_form('/books', :post) do
110
112
  with_email_field('user[email]')
111
113
  with_email_field('user[email]', 'email@example.com')
112
114
  with_email_field('user[email_confirmation]', nil)
113
115
  end
114
116
  end
115
117
 
116
- it "should not find email field" do
117
- expect(rendered).to have_form("/books", :post) do
118
- without_email_field('book[author]','Authorname')
118
+ it 'should not find email field' do
119
+ expect(rendered).to have_form('/books', :post) do
120
+ without_email_field('book[author]', 'Authorname')
119
121
  without_email_field('user[emaiL]')
120
122
  without_email_field('user[apocalyptiq]')
121
123
  end
122
124
  end
123
125
  end
124
126
 
125
- context "with_url_field" do
126
- it "should find url field" do
127
- expect(rendered).to have_form("/books", :post) do
127
+ context '[with_url_field]' do
128
+ it 'should find url field' do
129
+ expect(rendered).to have_form('/books', :post) do
128
130
  with_url_field('user[url]')
129
131
  with_url_field('user[url]', 'http://user.com')
130
132
  end
131
133
  end
132
134
 
133
- it "should not find url field" do
134
- expect(rendered).to have_form("/books", :post) do
135
- without_url_field('user[url]','Authorname')
135
+ it 'should not find url field' do
136
+ expect(rendered).to have_form('/books', :post) do
137
+ without_url_field('user[url]', 'Authorname')
136
138
  without_url_field('user[emaiL]')
137
139
  without_url_field('user[apocalyptiq]')
138
140
  end
139
141
  end
140
142
  end
141
143
 
142
- context "with_number_field" do
143
- it "should find number field" do
144
- expect(rendered).to have_form("/books", :post) do
144
+ context '[with_number_field]' do
145
+ it 'should find number field' do
146
+ expect(rendered).to have_form('/books', :post) do
145
147
  with_number_field('number')
146
148
  with_number_field('number_defined', 3)
147
149
  with_number_field('number_defined', '3')
148
150
  end
149
151
  end
150
152
 
151
- it "should not find number field" do
152
- expect(rendered).to have_form("/books", :post) do
153
- without_number_field('number',400)
154
- without_number_field('number','400')
153
+ it 'should not find number field' do
154
+ expect(rendered).to have_form('/books', :post) do
155
+ without_number_field('number', 400)
156
+ without_number_field('number', '400')
155
157
  without_number_field('user[emaiL]')
156
158
  without_number_field('user[apocalyptiq]')
157
159
  end
158
160
  end
159
161
  end
160
162
 
161
- context "with_range_field" do
162
- it "should find range field" do
163
- expect(rendered).to have_form("/books", :post) do
163
+ context '[with_range_field]' do
164
+ it 'should find range field' do
165
+ expect(rendered).to have_form('/books', :post) do
164
166
  with_range_field('range1', 1, 3)
165
- with_range_field('range1','1','3')
166
- with_range_field('range2', 1, 3, :with => { :value => 2 } )
167
- with_range_field('range2', 1, 3, :with => { :value => '2' } )
167
+ with_range_field('range1', '1', '3')
168
+ with_range_field('range2', 1, 3, :with => { :value => 2 })
169
+ with_range_field('range2', 1, 3, :with => { :value => '2' })
168
170
  end
169
171
  end
170
172
 
171
- it "should not find range field" do
172
- expect(rendered).to have_form("/books", :post) do
173
+ it 'should not find range field' do
174
+ expect(rendered).to have_form('/books', :post) do
173
175
  without_range_field('number')
174
176
  without_range_field('range1', 1, 5)
175
- without_range_field('range2', 1, 3, :with => { :value => 5 } )
177
+ without_range_field('range2', 1, 3, :with => { :value => 5 })
176
178
  end
177
179
  end
178
180
  end
179
181
 
180
- context "with_date_field" do
181
- it "should find date field" do
182
- expect(rendered).to have_form("/books", :post) do
182
+ context '[with_date_field]' do
183
+ it 'should find date field' do
184
+ expect(rendered).to have_form('/books', :post) do
183
185
  with_date_field(:date)
184
186
  with_date_field(:date, 'book_date')
185
187
  with_date_field(:month, 'book_month', :with => { :value => 5 })
186
- with_date_field(:week,'book_week')
188
+ with_date_field(:week, 'book_week')
187
189
  with_date_field(:time, 'book_time')
188
190
  with_date_field(:datetime, 'book_datetime')
189
191
  with_date_field('datetime-local', 'book_datetime_local')
190
192
  end
191
193
  end
192
194
 
193
- it "should not find date field" do
194
- expect(rendered).to have_form("/books", :post) do
195
+ it 'should not find date field' do
196
+ expect(rendered).to have_form('/books', :post) do
195
197
  without_date_field(:date, 'book_something')
196
198
  without_date_field(:month, 'book_month', :with => { :value => 100500 })
197
199
  end
198
200
  end
199
201
 
200
- it "should raise exception if wrong date field type specified" do
202
+ it 'should raise exception if wrong date field type specified' do
201
203
  expect do
202
- expect(rendered).to have_form("/books", :post) do
204
+ expect(rendered).to have_form('/books', :post) do
203
205
  without_date_field(:unknown, 'book_something')
204
206
  end
205
207
  end.to raise_error('unknown type `unknown` for date picker')
206
208
  expect do
207
- expect(rendered).to have_form("/books", :post) do
209
+ expect(rendered).to have_form('/books', :post) do
208
210
  with_date_field(:unknown, 'book_something')
209
211
  end
210
212
  end.to raise_error('unknown type `unknown` for date picker')
211
213
  end
212
214
  end
213
215
 
214
- context "with_password_field" do
215
- it "should find password field" do
216
- expect(rendered).to have_form("/books", :post) do
216
+ context '[with_password_field]' do
217
+ it 'should find password field' do
218
+ expect(rendered).to have_form('/books', :post) do
217
219
  with_password_field('user[password]')
218
220
  end
219
221
  end
220
222
 
221
- it "should not find password field" do
222
- expect(rendered).to have_form("/books", :post) do
223
+ it 'should not find password field' do
224
+ expect(rendered).to have_form('/books', :post) do
223
225
  without_password_field('account[password]')
224
226
  end
225
227
  end
226
228
  end
227
229
 
228
- context "with_file_field" do
229
- it "should find file field" do
230
- expect(rendered).to have_form("/books", :post) do
230
+ context '[with_file_field]' do
231
+ it 'should find file field' do
232
+ expect(rendered).to have_form('/books', :post) do
231
233
  with_file_field('form[file]')
232
234
  end
233
235
  end
234
236
 
235
- it "should not find file field" do
236
- expect(rendered).to have_form("/books", :post) do
237
+ it 'should not find file field' do
238
+ expect(rendered).to have_form('/books', :post) do
237
239
  without_file_field('user[file]')
238
240
  end
239
241
  end
240
242
  end
241
243
 
242
- context "with_text_area" do
243
- it "should find text area" do
244
- expect(rendered).to have_form("/books", :post) do
244
+ context '[with_text_area]' do
245
+ it 'should find text area' do
246
+ expect(rendered).to have_form('/books', :post) do
245
247
  with_text_area('book[description]')
246
248
  end
247
249
  end
248
250
 
249
- it "should not find text area" do
250
- expect(rendered).to have_form("/books", :post) do
251
+ it 'should not find text area' do
252
+ expect(rendered).to have_form('/books', :post) do
251
253
  without_text_area('user[bio]')
252
254
  end
253
255
  end
254
256
  end
255
257
 
256
- context "with_check_box" do
257
- it "should find check box" do
258
- expect(rendered).to have_form("/books", :post) do
259
- with_checkbox("book[still_in_print]")
260
- with_checkbox("book[still_in_print]","1")
258
+ context '[with_check_box]' do
259
+ it 'should find check box' do
260
+ expect(rendered).to have_form('/books', :post) do
261
+ with_checkbox('book[still_in_print]')
262
+ with_checkbox('book[still_in_print]', '1')
261
263
  end
262
264
  end
263
265
 
264
- it "should not find check box" do
265
- expect(rendered).to have_form("/books", :post) do
266
- without_checkbox("book[book]")
267
- without_checkbox("book[still_in_print]","500")
266
+ it 'should not find check box' do
267
+ expect(rendered).to have_form('/books', :post) do
268
+ without_checkbox('book[book]')
269
+ without_checkbox('book[still_in_print]', '500')
268
270
  end
269
271
  end
270
272
  end
271
273
 
272
- context "with_radio_button" do
273
- it "should find radio button" do
274
- expect(rendered).to have_form("/books", :post) do
275
- with_radio_button("form[name]","true")
274
+ context '[with_radio_button]' do
275
+ it 'should find radio button' do
276
+ expect(rendered).to have_form('/books', :post) do
277
+ with_radio_button('form[name]', 'true')
276
278
  end
277
279
  end
278
280
 
279
- it "should not find radio button" do
280
- expect(rendered).to have_form("/books", :post) do
281
- without_radio_button("form[name]","100500")
282
- without_radio_button("form[item]","false")
281
+ it 'should not find radio button' do
282
+ expect(rendered).to have_form('/books', :post) do
283
+ without_radio_button('form[name]', '100500')
284
+ without_radio_button('form[item]', 'false')
283
285
  end
284
286
  end
285
287
  end
286
288
 
287
- context "with_submit" do
288
- it "should find submit" do
289
- expect(rendered).to have_form("/books", :post) do
290
- with_submit("Create Book")
289
+ context '[with_submit]' do
290
+ it 'should find submit' do
291
+ expect(rendered).to have_form('/books', :post) do
292
+ with_submit('Create Book')
291
293
  end
292
294
  end
293
295
 
294
- it "should not find submit" do
295
- expect(rendered).to have_form("/books", :post) do
296
- without_submit("Destroy Book")
296
+ it 'should not find submit' do
297
+ expect(rendered).to have_form('/books', :post) do
298
+ without_submit('Destroy Book')
297
299
  end
298
300
  end
299
301
  end
@@ -1,23 +1,25 @@
1
1
  # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
2
4
  require 'spec_helper'
3
5
 
4
6
  describe 'have_empty_tag' do
5
- context 'when single element' do
7
+ context '[single element]' do
6
8
  asset 'single_element'
7
9
 
8
10
  it { expect(rendered).to have_empty_tag('div') }
9
- it { expect(rendered).to have_empty_tag('div', :class => "foo") }
10
- it { expect(rendered).to have_empty_tag('div', :class => "bar") }
11
- it { expect(rendered).to have_empty_tag('div', :class => "foo bar") }
11
+ it { expect(rendered).to have_empty_tag('div', :class => 'foo') }
12
+ it { expect(rendered).to have_empty_tag('div', :class => 'bar') }
13
+ it { expect(rendered).to have_empty_tag('div', :class => 'foo bar') }
12
14
  end
13
15
 
14
- context 'when paragraphs' do
16
+ context '[paragraphs]' do
15
17
  asset 'paragraphs'
16
18
 
17
19
  it { expect(rendered).to_not have_empty_tag('p') }
18
20
  end
19
21
 
20
- context 'when ordered list' do
22
+ context '[ordered list]' do
21
23
  asset 'ordered_list'
22
24
 
23
25
  it { expect(rendered).to_not have_empty_tag('html') }