From fd06f9390333db9533c929fcd7c6c88b5d1ecc96 Mon Sep 17 00:00:00 2001 From: Leandro Nunes dos Santos Date: Thu, 12 Nov 2015 17:38:03 -0300 Subject: [PATCH] adapting tests to use nokogiri correctly --- test/unit/box_organizer_helper_test.rb | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/test/unit/box_organizer_helper_test.rb b/test/unit/box_organizer_helper_test.rb index d8dc65d..3469569 100644 --- a/test/unit/box_organizer_helper_test.rb +++ b/test/unit/box_organizer_helper_test.rb @@ -133,8 +133,8 @@ class BoxOrganizerHelperTest < ActionView::TestCase @plugins = mock @plugins.stubs(:fetch_first_plugin).with(:has_block?, block).returns(nil) - doc = HTML::Document.new display_previews(block) - assert_select doc.root, 'li' do |elements| + doc = Nokogiri::HTML display_previews(block) + assert_select doc, 'li' do |elements| assert_match /img.* src="\/images\/block_preview.png.*"/, elements[0].to_s assert_match /img.* src="\/images\/block_preview.png.*"/, elements[1].to_s assert_match /img.* src="\/images\/block_preview.png.*"/, elements[2].to_s @@ -150,8 +150,8 @@ class BoxOrganizerHelperTest < ActionView::TestCase Dir.stubs(:glob).returns([]) base_path = File.join(Rails.root, 'public', 'images', '/blocks/some_block/previews/') Dir.stubs(:glob).with(File.join(base_path, '*')).returns([File.join(base_path, 'p1.png'), File.join(base_path, 'p2.png')]) - doc = HTML::Document.new display_previews(block) - assert_select doc.root, 'li' do |elements| + doc = Nokogiri::HTML display_previews(block) + assert_select doc, 'li' do |elements| assert_match /img.* src="\/images\/blocks\/some_block\/previews\/p1.png"/, elements[0].to_s assert_match /img.* src="\/images\/blocks\/some_block\/previews\/p2.png"/, elements[1].to_s end @@ -169,8 +169,8 @@ class BoxOrganizerHelperTest < ActionView::TestCase Dir.stubs(:glob).returns([]) base_path = File.join(Rails.root, 'public', 'plugins/some/', 'images', '/blocks/some_block/previews/') Dir.stubs(:glob).with(File.join(base_path, '*')).returns([File.join(base_path, 'p1.png'), File.join(base_path, 'p2.png')]) - doc = HTML::Document.new display_previews(block) - assert_select doc.root, 'li' do |elements| + doc = Nokogiri::HTML display_previews(block) + assert_select doc, 'li' do |elements| assert_match /img.* src="\/plugins\/some\/images\/blocks\/some_block\/previews\/p1.png"/, elements[0].to_s assert_match /img.* src="\/plugins\/some\/images\/blocks\/some_block\/previews\/p2.png"/, elements[1].to_s end @@ -191,8 +191,8 @@ class BoxOrganizerHelperTest < ActionView::TestCase Dir.stubs(:glob).returns([]) base_path = File.join(Rails.root, 'public', 'designs/themes/some_theme/', 'images', '/blocks/some_block/previews/') Dir.stubs(:glob).with(File.join(base_path, '*')).returns([File.join(base_path, 'p1.png'), File.join(base_path, 'p2.png')]) - doc = HTML::Document.new display_previews(block) - assert_select doc.root, 'li' do |elements| + doc = Nokogiri::HTML display_previews(block) + assert_select doc, 'li' do |elements| assert_match /img.* src="\/designs\/themes\/some_theme\/images\/blocks\/some_block\/previews\/p1.png"/, elements[0].to_s assert_match /img.* src="\/designs\/themes\/some_theme\/images\/blocks\/some_block\/previews\/p2.png"/, elements[1].to_s end @@ -216,8 +216,8 @@ class BoxOrganizerHelperTest < ActionView::TestCase base_path = File.join(Rails.root, 'public', 'images', '/blocks/some_block/previews/') Dir.stubs(:glob).with(File.join(base_path, '*')).returns([File.join(base_path, 'p1.png'), File.join(base_path, 'p2.png')]) - doc = HTML::Document.new display_previews(block) - assert_select doc.root, 'li' do |elements| + doc = Nokogiri::HTML display_previews(block) + assert_select doc, 'li' do |elements| assert_match /img.* src="\/designs\/themes\/some_theme\/images\/blocks\/some_block\/previews\/p1.png"/, elements[0].to_s assert_match /img.* src="\/designs\/themes\/some_theme\/images\/blocks\/some_block\/previews\/p2.png"/, elements[1].to_s end @@ -242,8 +242,8 @@ class BoxOrganizerHelperTest < ActionView::TestCase base_path = File.join(Rails.root, 'public', 'plugins/some/', 'images', '/blocks/some_block/previews/') Dir.stubs(:glob).with(File.join(base_path, '*')).returns([File.join(base_path, 'p1.png'), File.join(base_path, 'p2.png')]) - doc = HTML::Document.new display_previews(block) - assert_select doc.root, 'li' do |elements| + doc = Nokogiri::HTML display_previews(block) + assert_select doc, 'li' do |elements| assert_match /img.* src="\/designs\/themes\/some_theme\/images\/blocks\/some_block\/previews\/p1.png"/, elements[0].to_s assert_match /img.* src="\/designs\/themes\/some_theme\/images\/blocks\/some_block\/previews\/p2.png"/, elements[1].to_s end @@ -273,8 +273,8 @@ class BoxOrganizerHelperTest < ActionView::TestCase base_path = File.join(Rails.root, 'public', 'images', '/blocks/some_block/previews/') Dir.stubs(:glob).with(File.join(base_path, '*')).returns([File.join(base_path, 'p1.png'), File.join(base_path, 'p2.png')]) - doc = HTML::Document.new display_previews(block) - assert_select doc.root, 'li' do |elements| + doc = Nokogiri::HTML display_previews(block) + assert_select doc, 'li' do |elements| assert_match /img.* src="\/designs\/themes\/some_theme\/images\/blocks\/some_block\/previews\/p1.png"/, elements[0].to_s assert_match /img.* src="\/designs\/themes\/some_theme\/images\/blocks\/some_block\/previews\/p2.png"/, elements[1].to_s end @@ -300,8 +300,8 @@ class BoxOrganizerHelperTest < ActionView::TestCase base_path = File.join(Rails.root, 'public', 'images', '/blocks/some_block/previews/') Dir.stubs(:glob).with(File.join(base_path, '*')).returns([File.join(base_path, 'p1.png'), File.join(base_path, 'p2.png')]) - doc = HTML::Document.new display_previews(block) - assert_select doc.root, 'li' do |elements| + doc = Nokogiri::HTML display_previews(block) + assert_select doc, 'li' do |elements| assert_match /img.* src="\/plugins\/some\/images\/blocks\/some_block\/previews\/p1.png"/, elements[0].to_s assert_match /img.* src="\/plugins\/some\/images\/blocks\/some_block\/previews\/p2.png"/, elements[1].to_s end -- libgit2 0.21.2