From eca90894e0bb6bb9cadc92f39fe1ed07d324747a Mon Sep 17 00:00:00 2001 From: erwanlr Date: Tue, 16 Apr 2013 17:33:40 +0200 Subject: [PATCH] Additional specs for #169 --- .../wp_item/existable/cache_generation.html | 21 +++++++++++++++++++ spec/shared_examples/wp_item_existable.rb | 14 +++++++++++++ spec/shared_examples/wp_item_infos.rb | 2 +- spec/shared_examples/wp_items_detectable.rb | 1 - 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 spec/samples/common/models/wp_item/existable/cache_generation.html diff --git a/spec/samples/common/models/wp_item/existable/cache_generation.html b/spec/samples/common/models/wp_item/existable/cache_generation.html new file mode 100644 index 00000000..b02ff386 --- /dev/null +++ b/spec/samples/common/models/wp_item/existable/cache_generation.html @@ -0,0 +1,21 @@ + + + + + + + + +Lamp Testing + + + + + +
+
+ + + diff --git a/spec/shared_examples/wp_item_existable.rb b/spec/shared_examples/wp_item_existable.rb index dd3c1517..3e0d2d8f 100644 --- a/spec/shared_examples/wp_item_existable.rb +++ b/spec/shared_examples/wp_item_existable.rb @@ -1,6 +1,7 @@ # encoding: UTF-8 shared_examples 'WpItem::Existable' do + let(:fixtures_dir) { MODELS_FIXTURES + '/wp_item/existable' } describe '#exists?' do context 'when the response is supplied' do @@ -75,6 +76,19 @@ shared_examples 'WpItem::Existable' do end end end + + context 'when it\'s a redirect to the homepage' do + context 'and the cache generation time is in comment tag' do + let(:body) { File.new(fixtures_dir + '/cache_generation.html').read } + let(:uncommented_body) { body.gsub(//m, '') } + let(:exists_options) { { homepage_hash: Digest::MD5.hexdigest(uncommented_body) } } + + it 'returns false' do + @resp_opt = { code: 200, body: body } + @expected = false + end + end + end end end diff --git a/spec/shared_examples/wp_item_infos.rb b/spec/shared_examples/wp_item_infos.rb index eabfdb6a..575add79 100644 --- a/spec/shared_examples/wp_item_infos.rb +++ b/spec/shared_examples/wp_item_infos.rb @@ -2,7 +2,7 @@ shared_examples 'WpItem::Infos' do - # 3 expected urls have to be set in the described class (or subject) + # 2 expected urls have to be set in the described class (or subject) # e.g : # let(:changelog_url) { } # let(:error_log_url) { } diff --git a/spec/shared_examples/wp_items_detectable.rb b/spec/shared_examples/wp_items_detectable.rb index 0b4f54a4..66473ce2 100644 --- a/spec/shared_examples/wp_items_detectable.rb +++ b/spec/shared_examples/wp_items_detectable.rb @@ -195,7 +195,6 @@ shared_examples 'WpItems::Detectable' do @expected = subject.new end end - end context 'when no :only_vulnerable' do