Commit fd06f9390333db9533c929fcd7c6c88b5d1ecc96

Authored by Leandro Santos
1 parent e74f65a7

adapting tests to use nokogiri correctly

Showing 1 changed file with 16 additions and 16 deletions   Show diff stats
test/unit/box_organizer_helper_test.rb
@@ -133,8 +133,8 @@ class BoxOrganizerHelperTest < ActionView::TestCase @@ -133,8 +133,8 @@ class BoxOrganizerHelperTest < ActionView::TestCase
133 @plugins = mock 133 @plugins = mock
134 @plugins.stubs(:fetch_first_plugin).with(:has_block?, block).returns(nil) 134 @plugins.stubs(:fetch_first_plugin).with(:has_block?, block).returns(nil)
135 135
136 - doc = HTML::Document.new display_previews(block)  
137 - assert_select doc.root, 'li' do |elements| 136 + doc = Nokogiri::HTML display_previews(block)
  137 + assert_select doc, 'li' do |elements|
138 assert_match /img.* src="\/images\/block_preview.png.*"/, elements[0].to_s 138 assert_match /img.* src="\/images\/block_preview.png.*"/, elements[0].to_s
139 assert_match /img.* src="\/images\/block_preview.png.*"/, elements[1].to_s 139 assert_match /img.* src="\/images\/block_preview.png.*"/, elements[1].to_s
140 assert_match /img.* src="\/images\/block_preview.png.*"/, elements[2].to_s 140 assert_match /img.* src="\/images\/block_preview.png.*"/, elements[2].to_s
@@ -150,8 +150,8 @@ class BoxOrganizerHelperTest < ActionView::TestCase @@ -150,8 +150,8 @@ class BoxOrganizerHelperTest < ActionView::TestCase
150 Dir.stubs(:glob).returns([]) 150 Dir.stubs(:glob).returns([])
151 base_path = File.join(Rails.root, 'public', 'images', '/blocks/some_block/previews/') 151 base_path = File.join(Rails.root, 'public', 'images', '/blocks/some_block/previews/')
152 Dir.stubs(:glob).with(File.join(base_path, '*')).returns([File.join(base_path, 'p1.png'), File.join(base_path, 'p2.png')]) 152 Dir.stubs(:glob).with(File.join(base_path, '*')).returns([File.join(base_path, 'p1.png'), File.join(base_path, 'p2.png')])
153 - doc = HTML::Document.new display_previews(block)  
154 - assert_select doc.root, 'li' do |elements| 153 + doc = Nokogiri::HTML display_previews(block)
  154 + assert_select doc, 'li' do |elements|
155 assert_match /img.* src="\/images\/blocks\/some_block\/previews\/p1.png"/, elements[0].to_s 155 assert_match /img.* src="\/images\/blocks\/some_block\/previews\/p1.png"/, elements[0].to_s
156 assert_match /img.* src="\/images\/blocks\/some_block\/previews\/p2.png"/, elements[1].to_s 156 assert_match /img.* src="\/images\/blocks\/some_block\/previews\/p2.png"/, elements[1].to_s
157 end 157 end
@@ -169,8 +169,8 @@ class BoxOrganizerHelperTest < ActionView::TestCase @@ -169,8 +169,8 @@ class BoxOrganizerHelperTest < ActionView::TestCase
169 Dir.stubs(:glob).returns([]) 169 Dir.stubs(:glob).returns([])
170 base_path = File.join(Rails.root, 'public', 'plugins/some/', 'images', '/blocks/some_block/previews/') 170 base_path = File.join(Rails.root, 'public', 'plugins/some/', 'images', '/blocks/some_block/previews/')
171 Dir.stubs(:glob).with(File.join(base_path, '*')).returns([File.join(base_path, 'p1.png'), File.join(base_path, 'p2.png')]) 171 Dir.stubs(:glob).with(File.join(base_path, '*')).returns([File.join(base_path, 'p1.png'), File.join(base_path, 'p2.png')])
172 - doc = HTML::Document.new display_previews(block)  
173 - assert_select doc.root, 'li' do |elements| 172 + doc = Nokogiri::HTML display_previews(block)
  173 + assert_select doc, 'li' do |elements|
174 assert_match /img.* src="\/plugins\/some\/images\/blocks\/some_block\/previews\/p1.png"/, elements[0].to_s 174 assert_match /img.* src="\/plugins\/some\/images\/blocks\/some_block\/previews\/p1.png"/, elements[0].to_s
175 assert_match /img.* src="\/plugins\/some\/images\/blocks\/some_block\/previews\/p2.png"/, elements[1].to_s 175 assert_match /img.* src="\/plugins\/some\/images\/blocks\/some_block\/previews\/p2.png"/, elements[1].to_s
176 end 176 end
@@ -191,8 +191,8 @@ class BoxOrganizerHelperTest < ActionView::TestCase @@ -191,8 +191,8 @@ class BoxOrganizerHelperTest < ActionView::TestCase
191 Dir.stubs(:glob).returns([]) 191 Dir.stubs(:glob).returns([])
192 base_path = File.join(Rails.root, 'public', 'designs/themes/some_theme/', 'images', '/blocks/some_block/previews/') 192 base_path = File.join(Rails.root, 'public', 'designs/themes/some_theme/', 'images', '/blocks/some_block/previews/')
193 Dir.stubs(:glob).with(File.join(base_path, '*')).returns([File.join(base_path, 'p1.png'), File.join(base_path, 'p2.png')]) 193 Dir.stubs(:glob).with(File.join(base_path, '*')).returns([File.join(base_path, 'p1.png'), File.join(base_path, 'p2.png')])
194 - doc = HTML::Document.new display_previews(block)  
195 - assert_select doc.root, 'li' do |elements| 194 + doc = Nokogiri::HTML display_previews(block)
  195 + assert_select doc, 'li' do |elements|
196 assert_match /img.* src="\/designs\/themes\/some_theme\/images\/blocks\/some_block\/previews\/p1.png"/, elements[0].to_s 196 assert_match /img.* src="\/designs\/themes\/some_theme\/images\/blocks\/some_block\/previews\/p1.png"/, elements[0].to_s
197 assert_match /img.* src="\/designs\/themes\/some_theme\/images\/blocks\/some_block\/previews\/p2.png"/, elements[1].to_s 197 assert_match /img.* src="\/designs\/themes\/some_theme\/images\/blocks\/some_block\/previews\/p2.png"/, elements[1].to_s
198 end 198 end
@@ -216,8 +216,8 @@ class BoxOrganizerHelperTest < ActionView::TestCase @@ -216,8 +216,8 @@ class BoxOrganizerHelperTest < ActionView::TestCase
216 base_path = File.join(Rails.root, 'public', 'images', '/blocks/some_block/previews/') 216 base_path = File.join(Rails.root, 'public', 'images', '/blocks/some_block/previews/')
217 Dir.stubs(:glob).with(File.join(base_path, '*')).returns([File.join(base_path, 'p1.png'), File.join(base_path, 'p2.png')]) 217 Dir.stubs(:glob).with(File.join(base_path, '*')).returns([File.join(base_path, 'p1.png'), File.join(base_path, 'p2.png')])
218 218
219 - doc = HTML::Document.new display_previews(block)  
220 - assert_select doc.root, 'li' do |elements| 219 + doc = Nokogiri::HTML display_previews(block)
  220 + assert_select doc, 'li' do |elements|
221 assert_match /img.* src="\/designs\/themes\/some_theme\/images\/blocks\/some_block\/previews\/p1.png"/, elements[0].to_s 221 assert_match /img.* src="\/designs\/themes\/some_theme\/images\/blocks\/some_block\/previews\/p1.png"/, elements[0].to_s
222 assert_match /img.* src="\/designs\/themes\/some_theme\/images\/blocks\/some_block\/previews\/p2.png"/, elements[1].to_s 222 assert_match /img.* src="\/designs\/themes\/some_theme\/images\/blocks\/some_block\/previews\/p2.png"/, elements[1].to_s
223 end 223 end
@@ -242,8 +242,8 @@ class BoxOrganizerHelperTest < ActionView::TestCase @@ -242,8 +242,8 @@ class BoxOrganizerHelperTest < ActionView::TestCase
242 base_path = File.join(Rails.root, 'public', 'plugins/some/', 'images', '/blocks/some_block/previews/') 242 base_path = File.join(Rails.root, 'public', 'plugins/some/', 'images', '/blocks/some_block/previews/')
243 Dir.stubs(:glob).with(File.join(base_path, '*')).returns([File.join(base_path, 'p1.png'), File.join(base_path, 'p2.png')]) 243 Dir.stubs(:glob).with(File.join(base_path, '*')).returns([File.join(base_path, 'p1.png'), File.join(base_path, 'p2.png')])
244 244
245 - doc = HTML::Document.new display_previews(block)  
246 - assert_select doc.root, 'li' do |elements| 245 + doc = Nokogiri::HTML display_previews(block)
  246 + assert_select doc, 'li' do |elements|
247 assert_match /img.* src="\/designs\/themes\/some_theme\/images\/blocks\/some_block\/previews\/p1.png"/, elements[0].to_s 247 assert_match /img.* src="\/designs\/themes\/some_theme\/images\/blocks\/some_block\/previews\/p1.png"/, elements[0].to_s
248 assert_match /img.* src="\/designs\/themes\/some_theme\/images\/blocks\/some_block\/previews\/p2.png"/, elements[1].to_s 248 assert_match /img.* src="\/designs\/themes\/some_theme\/images\/blocks\/some_block\/previews\/p2.png"/, elements[1].to_s
249 end 249 end
@@ -273,8 +273,8 @@ class BoxOrganizerHelperTest < ActionView::TestCase @@ -273,8 +273,8 @@ class BoxOrganizerHelperTest < ActionView::TestCase
273 base_path = File.join(Rails.root, 'public', 'images', '/blocks/some_block/previews/') 273 base_path = File.join(Rails.root, 'public', 'images', '/blocks/some_block/previews/')
274 Dir.stubs(:glob).with(File.join(base_path, '*')).returns([File.join(base_path, 'p1.png'), File.join(base_path, 'p2.png')]) 274 Dir.stubs(:glob).with(File.join(base_path, '*')).returns([File.join(base_path, 'p1.png'), File.join(base_path, 'p2.png')])
275 275
276 - doc = HTML::Document.new display_previews(block)  
277 - assert_select doc.root, 'li' do |elements| 276 + doc = Nokogiri::HTML display_previews(block)
  277 + assert_select doc, 'li' do |elements|
278 assert_match /img.* src="\/designs\/themes\/some_theme\/images\/blocks\/some_block\/previews\/p1.png"/, elements[0].to_s 278 assert_match /img.* src="\/designs\/themes\/some_theme\/images\/blocks\/some_block\/previews\/p1.png"/, elements[0].to_s
279 assert_match /img.* src="\/designs\/themes\/some_theme\/images\/blocks\/some_block\/previews\/p2.png"/, elements[1].to_s 279 assert_match /img.* src="\/designs\/themes\/some_theme\/images\/blocks\/some_block\/previews\/p2.png"/, elements[1].to_s
280 end 280 end
@@ -300,8 +300,8 @@ class BoxOrganizerHelperTest < ActionView::TestCase @@ -300,8 +300,8 @@ class BoxOrganizerHelperTest < ActionView::TestCase
300 base_path = File.join(Rails.root, 'public', 'images', '/blocks/some_block/previews/') 300 base_path = File.join(Rails.root, 'public', 'images', '/blocks/some_block/previews/')
301 Dir.stubs(:glob).with(File.join(base_path, '*')).returns([File.join(base_path, 'p1.png'), File.join(base_path, 'p2.png')]) 301 Dir.stubs(:glob).with(File.join(base_path, '*')).returns([File.join(base_path, 'p1.png'), File.join(base_path, 'p2.png')])
302 302
303 - doc = HTML::Document.new display_previews(block)  
304 - assert_select doc.root, 'li' do |elements| 303 + doc = Nokogiri::HTML display_previews(block)
  304 + assert_select doc, 'li' do |elements|
305 assert_match /img.* src="\/plugins\/some\/images\/blocks\/some_block\/previews\/p1.png"/, elements[0].to_s 305 assert_match /img.* src="\/plugins\/some\/images\/blocks\/some_block\/previews\/p1.png"/, elements[0].to_s
306 assert_match /img.* src="\/plugins\/some\/images\/blocks\/some_block\/previews\/p2.png"/, elements[1].to_s 306 assert_match /img.* src="\/plugins\/some\/images\/blocks\/some_block\/previews\/p2.png"/, elements[1].to_s
307 end 307 end