Merge pull request #1021 from ZogStriP/less-brittle-specs
less brittle specs to os-specific line endings
This commit is contained in:
commit
80f1e9a0d9
|
@ -15,7 +15,7 @@ describe Oneboxer::AmazonOnebox do
|
|||
end
|
||||
|
||||
it "generates the expected onebox for Amazon" do
|
||||
@o.onebox.should == expected_amazon_result
|
||||
@o.onebox.should match_html expected_amazon_result
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -11,7 +11,7 @@ describe Oneboxer::AndroidAppStoreOnebox do
|
|||
end
|
||||
|
||||
it "generates the expected onebox for Android App Store" do
|
||||
@o.onebox.should == expected_android_app_store_result
|
||||
@o.onebox.should match_html expected_android_app_store_result
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -11,7 +11,7 @@ describe Oneboxer::AppleAppOnebox do
|
|||
end
|
||||
|
||||
it "generates the expected onebox for Apple app" do
|
||||
@o.onebox.should == expected_apple_app_result
|
||||
@o.onebox.should match_html expected_apple_app_result
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -11,7 +11,7 @@ describe Oneboxer::FlickrOnebox do
|
|||
end
|
||||
|
||||
it "generates the expected onebox for Flickr" do
|
||||
@o.onebox.should == expected_flickr_result
|
||||
@o.onebox.should match_html expected_flickr_result
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -13,19 +13,19 @@ describe Oneboxer::RottentomatoesOnebox do
|
|||
it 'generates the expected onebox for a fresh movie' do
|
||||
o = Oneboxer::RottentomatoesOnebox.new('http://www.rottentomatoes.com/m/mud_2012/')
|
||||
FakeWeb.register_uri(:get, o.translate_url, response: fixture_file('oneboxer/rottentomatoes_fresh.response'))
|
||||
expect(o.onebox).to eq(expected_fresh_result)
|
||||
o.onebox.should match_html expected_fresh_result
|
||||
end
|
||||
|
||||
it 'generates the expected onebox for a rotten movie' do
|
||||
o = Oneboxer::RottentomatoesOnebox.new('http://www.rottentomatoes.com/m/the_big_wedding_2013/')
|
||||
FakeWeb.register_uri(:get, o.translate_url, response: fixture_file('oneboxer/rottentomatoes_rotten.response'))
|
||||
expect(o.onebox).to eq(expected_rotten_result)
|
||||
o.onebox.should match_html expected_rotten_result
|
||||
end
|
||||
|
||||
it 'generates the expected onebox for a movie with an incomplete description' do
|
||||
o = Oneboxer::RottentomatoesOnebox.new('http://www.rottentomatoes.com/m/gunde_jaari_gallanthayyinde/')
|
||||
FakeWeb.register_uri(:get, o.translate_url, response: fixture_file('oneboxer/rottentomatoes_incomplete.response'))
|
||||
expect(o.onebox).to eq(expected_incomplete_result)
|
||||
o.onebox.should match_html expected_incomplete_result
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -10,7 +10,7 @@ describe Oneboxer::WikipediaOnebox do
|
|||
o = Oneboxer::WikipediaOnebox.new('http://en.wikipedia.org/wiki/Ruby')
|
||||
FakeWeb.register_uri(:get, o.translate_url, response: fixture_file('oneboxer/wikipedia.response'))
|
||||
FakeWeb.register_uri(:get, 'http://en.m.wikipedia.org/wiki/Ruby', response: fixture_file('oneboxer/wikipedia_redirected.response'))
|
||||
o.onebox.should == expected_wikipedia_result
|
||||
o.onebox.should match_html expected_wikipedia_result
|
||||
end
|
||||
|
||||
it "accepts .com extention" do
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
require 'nokogiri/xml/parse_options'
|
||||
RSpec::Matchers.define :match_html do |expected|
|
||||
match do |actual|
|
||||
a = make_canonical_html expected
|
||||
b = make_canonical_html actual
|
||||
a.to_html == b.to_html
|
||||
a = make_canonical_html(expected).to_html.gsub("\r\n", "\n")
|
||||
b = make_canonical_html(actual).to_html.gsub("\r\n", "\n")
|
||||
a == b
|
||||
end
|
||||
|
||||
failure_message_for_should do |actual|
|
||||
"after sanitizing for extra white space and compactness, expected #{actual} to match #{expected}"
|
||||
"after sanitizing for extra white space and compactness, expected:\n#{actual}\n to match:\n#{expected}"
|
||||
end
|
||||
|
||||
failure_message_for_should_not do |actual|
|
||||
"after sanitizing for extra white space and compactness, expected #{actual} not to match #{expected}"
|
||||
"after sanitizing for extra white space and compactness, expected:\n#{actual}\n not to match:\n#{expected}"
|
||||
end
|
||||
|
||||
def make_canonical_html(html)
|
||||
|
|
Loading…
Reference in New Issue