slimmer 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/slimmer/test.rb +2 -21
- data/lib/slimmer/test_template.rb +23 -0
- data/lib/slimmer/version.rb +1 -1
- data/test/test_helper.rb +7 -0
- data/test/test_template_dependency_on_static_test.rb +15 -0
- metadata +7 -4
data/lib/slimmer/test.rb
CHANGED
@@ -1,30 +1,11 @@
|
|
1
1
|
require 'slimmer/skin'
|
2
|
+
require 'slimmer/test_template'
|
2
3
|
|
3
4
|
module Slimmer
|
4
5
|
class Skin
|
5
6
|
def load_template name
|
6
7
|
logger.debug "Slimmer: TEST MODE - Loading fixture template from #{__FILE__}"
|
7
|
-
|
8
|
-
<html>
|
9
|
-
<head>
|
10
|
-
<title>Test Template</title>
|
11
|
-
<script src="http://static.preview.alphagov.co.uk/javascripts/libs/jquery/jquery-1.7.2.min.js"></script><!-- no defer on jquery -->
|
12
|
-
<script src="http://static.preview.alphagov.co.uk/javascripts/libs/jquery/jquery-ui-1.8.16.custom.min.js" defer></script>
|
13
|
-
<script src="http://static.preview.alphagov.co.uk/javascripts/libs/jquery/plugins/jquery.base64.js" defer></script>
|
14
|
-
<script src="http://static.preview.alphagov.co.uk/javascripts/libs/jquery/plugins/jquery.mustache.js" defer></script>
|
15
|
-
<script src="http://static.preview.alphagov.co.uk/javascripts/search.js" defer></script>
|
16
|
-
<script src="http://static.preview.alphagov.co.uk/javascripts/core.js" defer></script>
|
17
|
-
<script src="http://static.preview.alphagov.co.uk/javascripts/devolution.js" defer></script>
|
18
|
-
<script src="http://static.preview.alphagov.co.uk/javascripts/popup.js" defer></script>
|
19
|
-
<script src="http://static.preview.alphagov.co.uk/javascripts/geo-locator.js" defer></script>
|
20
|
-
<script src="http://static.preview.alphagov.co.uk/javascripts/customisation-settings.js" defer></script>
|
21
|
-
</head>
|
22
|
-
<body>
|
23
|
-
<div class="header-context">Header</div>
|
24
|
-
<div id="wrapper"></div>
|
25
|
-
</body>
|
26
|
-
</html>
|
27
|
-
}
|
8
|
+
Slimmer::TestTemplate::TEMPLATE
|
28
9
|
end
|
29
10
|
end
|
30
11
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Slimmer::TestTemplate
|
2
|
+
TEMPLATE = %q{
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title>Test Template</title>
|
6
|
+
<script src="http://static.preview.alphagov.co.uk/static/libs/jquery/jquery-1.7.2.min.js"></script><!-- no defer on jquery -->
|
7
|
+
<script src="http://static.preview.alphagov.co.uk/static/libs/jquery/jquery-ui-1.8.16.custom.min.js" defer></script>
|
8
|
+
<script src="http://static.preview.alphagov.co.uk/static/libs/jquery/plugins/jquery.base64.js" defer></script>
|
9
|
+
<script src="http://static.preview.alphagov.co.uk/static/libs/jquery/plugins/jquery.mustache.js" defer></script>
|
10
|
+
<script src="http://static.preview.alphagov.co.uk/static/search.js" defer></script>
|
11
|
+
<script src="http://static.preview.alphagov.co.uk/static/core.js" defer></script>
|
12
|
+
<script src="http://static.preview.alphagov.co.uk/static/devolution.js" defer></script>
|
13
|
+
<script src="http://static.preview.alphagov.co.uk/static/popup.js" defer></script>
|
14
|
+
<script src="http://static.preview.alphagov.co.uk/static/geo-locator.js" defer></script>
|
15
|
+
<script src="http://static.preview.alphagov.co.uk/static/customisation-settings.js" defer></script>
|
16
|
+
</head>
|
17
|
+
<body>
|
18
|
+
<div class="header-context">Header</div>
|
19
|
+
<div id="wrapper"></div>
|
20
|
+
</body>
|
21
|
+
</html>
|
22
|
+
}
|
23
|
+
end
|
data/lib/slimmer/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -22,6 +22,13 @@ class MiniTest::Unit::TestCase
|
|
22
22
|
def assert_not_in(template, selector, message="didn't exist to find #{selector}")
|
23
23
|
refute template.at_css(selector), message
|
24
24
|
end
|
25
|
+
|
26
|
+
def allowing_real_web_connections(&block)
|
27
|
+
WebMock.allow_net_connect!
|
28
|
+
result = yield
|
29
|
+
WebMock.disable_net_connect!
|
30
|
+
result
|
31
|
+
end
|
25
32
|
end
|
26
33
|
|
27
34
|
class SlimmerIntegrationTest < MiniTest::Unit::TestCase
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "slimmer/test_template"
|
3
|
+
|
4
|
+
class TestTemplateDependencyOnStaticTest < MiniTest::Unit::TestCase
|
5
|
+
def test_test_template_static_asset_urls_should_be_valid
|
6
|
+
doc = Nokogiri::HTML.fragment(Slimmer::TestTemplate::TEMPLATE)
|
7
|
+
scripts = doc.search("script").map { |node| node.attributes["src"].value }
|
8
|
+
failing_scripts = allowing_real_web_connections do
|
9
|
+
scripts.select do |script_src|
|
10
|
+
Net::HTTP.get_response(URI.parse(script_src)).code != "200"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
assert failing_scripts.empty?, "Some scripts could not be loaded: #{failing_scripts.inspect}"
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: slimmer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.2.
|
5
|
+
version: 1.2.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ben Griffiths
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2012-08-
|
14
|
+
date: 2012-08-13 00:00:00 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: nokogiri
|
@@ -182,6 +182,7 @@ files:
|
|
182
182
|
- lib/slimmer/tag_mover.rb
|
183
183
|
- lib/slimmer/title_inserter.rb
|
184
184
|
- lib/slimmer/header_context_inserter.rb
|
185
|
+
- lib/slimmer/test_template.rb
|
185
186
|
- lib/slimmer.rb
|
186
187
|
- Rakefile
|
187
188
|
- test/processors/header_context_inserter_test.rb
|
@@ -189,6 +190,7 @@ files:
|
|
189
190
|
- test/skin_test.rb
|
190
191
|
- test/headers_test.rb
|
191
192
|
- test/google_analytics_test.rb
|
193
|
+
- test/test_template_dependency_on_static_test.rb
|
192
194
|
- test/typical_usage_test.rb
|
193
195
|
- test/fixtures/500.html.erb
|
194
196
|
- test/fixtures/404.html.erb
|
@@ -210,7 +212,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
210
212
|
requirements:
|
211
213
|
- - ">="
|
212
214
|
- !ruby/object:Gem::Version
|
213
|
-
hash: -
|
215
|
+
hash: -2032820947441079493
|
214
216
|
segments:
|
215
217
|
- 0
|
216
218
|
version: "0"
|
@@ -219,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
219
221
|
requirements:
|
220
222
|
- - ">="
|
221
223
|
- !ruby/object:Gem::Version
|
222
|
-
hash: -
|
224
|
+
hash: -2032820947441079493
|
223
225
|
segments:
|
224
226
|
- 0
|
225
227
|
version: "0"
|
@@ -236,6 +238,7 @@ test_files:
|
|
236
238
|
- test/skin_test.rb
|
237
239
|
- test/headers_test.rb
|
238
240
|
- test/google_analytics_test.rb
|
241
|
+
- test/test_template_dependency_on_static_test.rb
|
239
242
|
- test/typical_usage_test.rb
|
240
243
|
- test/fixtures/500.html.erb
|
241
244
|
- test/fixtures/404.html.erb
|