middleman-automatic-clowncar 0.0.1 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +2 -0
- data/README.md +61 -1
- data/Rakefile +13 -0
- data/features/clowncar_tag_build.feature +136 -30
- data/features/clowncar_tag_preview.feature +31 -16
- data/features/support/env.rb +12 -0
- data/features/support/step_definitions.rb +14 -0
- data/features/thumbnail_generation.feature +41 -7
- data/fixtures/automatic-clowncar-app/profile/build.html +23779 -0
- data/fixtures/automatic-clowncar-app/source/{images/photos → photos}/test-image.jpg +0 -0
- data/fixtures/automatic-clowncar-app/source/tag.html.erb +1 -1
- data/fixtures/automatic-clowncar-app/source/thumbnail.html.erb +1 -0
- data/lib/middleman-automatic-clowncar/extension.rb +59 -131
- data/lib/middleman-automatic-clowncar/sitemap-extension.rb +45 -0
- data/lib/middleman-automatic-clowncar/thumbnail-generator.rb +9 -26
- data/lib/middleman-automatic-clowncar/thumbnail-resource.rb +54 -0
- data/lib/middleman-automatic-clowncar/timestamp-resource.rb +42 -0
- data/lib/middleman-automatic-clowncar/utils.rb +38 -0
- data/lib/middleman-automatic-clowncar/version.rb +1 -1
- data/middleman-automatic-clowncar.gemspec +14 -5
- metadata +84 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7d1c5387f4d2ee33f8a4795a178278d3c64f7ba3db81fbb061a468a6b7fc264d
|
4
|
+
data.tar.gz: 4e767881922623cadde291bd6118a09a9f8d1de486721a8e286734601470febe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb9c10cc06567764fe4dbf77640d24467bb05fec9e7c5040bffbeb6582ef65ea56c4dafb90ea065a469f88a1b9ee9faabcb7607a32e3f1ba01692792a26be469
|
7
|
+
data.tar.gz: 10434cb75830dae162ce46a178aba5c9ee9781cf59545f3ba645142ee82339c1a65f4f79ab9a7e091ee100b45da051564bde5684307a1b8459fc8f2eb6cd814c
|
data/.gitignore
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.6.1
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
Automatically generated responsive images for Middleman.
|
4
4
|
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/middleman-automatic-clowncar.png)](http://badge.fury.io/rb/middleman-automatic-clowncar)
|
6
|
+
[![Build Status](https://travis-ci.org/Octo-Labs/middleman-automatic-clowncar.png?branch=master)](https://travis-ci.org/Octo-Labs/middleman-automatic-clowncar)
|
7
|
+
[![Code Climate](https://codeclimate.com/github/Octo-Labs/middleman-automatic-clowncar.png)](https://codeclimate.com/github/Octo-Labs/middleman-automatic-clowncar)
|
8
|
+
[![Coverage Status](https://coveralls.io/repos/Octo-Labs/middleman-automatic-clowncar/badge.png?branch=master)](https://coveralls.io/r/Octo-Labs/middleman-automatic-clowncar?branch=master)
|
9
|
+
[![Dependency Status](https://gemnasium.com/Octo-Labs/middleman-automatic-clowncar.png)](https://gemnasium.com/Octo-Labs/middleman-automatic-clowncar)
|
10
|
+
|
11
|
+
|
12
|
+
|
5
13
|
## Installation
|
6
14
|
|
7
15
|
Add this line to your application's Gemfile:
|
@@ -27,9 +35,28 @@ activate :automatic_clowncar,
|
|
27
35
|
:medium => 400,
|
28
36
|
:large => 600
|
29
37
|
},
|
30
|
-
:namespace_directory => %w(photos)
|
38
|
+
:namespace_directory => %w(photos),
|
39
|
+
:filetypes => [:jpg, :jpeg, :png]
|
40
|
+
```
|
41
|
+
|
42
|
+
At build time the extension will look in `source/photos` and will create
|
43
|
+
thumbnails for each image it finds there.
|
44
|
+
|
45
|
+
For example, let's say you have an image at
|
46
|
+
`source/photos/my-photo.jpg`. With the configuration above the extension
|
47
|
+
will generate the following files:
|
48
|
+
|
49
|
+
```
|
50
|
+
build/photos/my-photos.svg
|
51
|
+
build/photos/my-photo/my-photo-small.jpg
|
52
|
+
build/photos/my-photo/my-photo-medium.jpg
|
53
|
+
build/photos/my-photo/my-photo-large.jpg
|
54
|
+
build/photos/my-photo/timestamp.txt
|
31
55
|
```
|
32
56
|
|
57
|
+
The timestamp file is used to allow the extension to skip regenerating
|
58
|
+
the thumbnails if the modified timestamp of the source image has not changed.
|
59
|
+
|
33
60
|
Then in a template you can use the `automatic_clowncar_tag` to display a
|
34
61
|
responsive image.
|
35
62
|
|
@@ -37,6 +64,39 @@ responsive image.
|
|
37
64
|
<%= automatic_clowncar_tag 'photos/my-photo.jpg' %>
|
38
65
|
```
|
39
66
|
|
67
|
+
**Please note :** The directory for the images to be clowncar-ed
|
68
|
+
**must** be outside of (and different than) the `source/images`
|
69
|
+
directory. Middleman automatically does some things with `images`
|
70
|
+
that interfere with the operation of `middleman-automatic-clowncar`.
|
71
|
+
|
72
|
+
### Setting the host
|
73
|
+
|
74
|
+
Background images in SVG require a full absolute path with host. You
|
75
|
+
have two options for setting this.
|
76
|
+
|
77
|
+
1. You can set the `:host` option in the call to `automatic_clowncar_tag`.
|
78
|
+
|
79
|
+
```
|
80
|
+
<%= automatic_clowncar_tag 'photos/my-photo.jpg', :host => 'http://localhost:4567' %>
|
81
|
+
```
|
82
|
+
|
83
|
+
2. You can set the `:asset_host` configuration variable in `config.rb`.
|
84
|
+
|
85
|
+
```
|
86
|
+
activate :asset_host
|
87
|
+
set :asset_host, 'http://localhost:4567'
|
88
|
+
```
|
89
|
+
|
90
|
+
Then you'll probably need a different host for your deployed site, so
|
91
|
+
you can change the `:asset_host` variable for your build.
|
92
|
+
|
93
|
+
```
|
94
|
+
configure :build do
|
95
|
+
set :asset_host, 'http://www.octolabs.com'
|
96
|
+
end
|
97
|
+
```
|
98
|
+
|
99
|
+
|
40
100
|
|
41
101
|
## Contributing
|
42
102
|
|
data/Rakefile
CHANGED
@@ -1 +1,14 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
desc "Run tests for travis"
|
4
|
+
task :travis do
|
5
|
+
["cucumber"].each do |cmd|
|
6
|
+
puts "Starting to run #{cmd}..."
|
7
|
+
system("export DISPLAY=:99.0 && bundle exec #{cmd}")
|
8
|
+
raise "#{cmd} failed!" unless $?.exitstatus == 0
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
desc 'Default: run tests.'
|
13
|
+
task :default => ['travis']
|
14
|
+
|
@@ -2,22 +2,24 @@ Feature: Generating SVG clowncars during preview mode
|
|
2
2
|
|
3
3
|
Scenario: Basic command
|
4
4
|
Given a fixture app "automatic-clowncar-app"
|
5
|
-
And a file named "source/
|
5
|
+
And a file named "source/testfile.html.erb" with:
|
6
6
|
"""
|
7
7
|
<%= automatic_clowncar_tag "photos/test-image.jpg", :host => "http://localhost:4567/" %>
|
8
8
|
"""
|
9
9
|
Given a successfully built app at "automatic-clowncar-app" with flags "--verbose"
|
10
10
|
When I cd to "build"
|
11
11
|
#Then the following files should not exist:
|
12
|
-
# |
|
12
|
+
# | photos/test-image.jpg |
|
13
13
|
Then the following files should exist:
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
And the file "
|
14
|
+
| testfile.html |
|
15
|
+
| photos/test-image.jpg |
|
16
|
+
| photos/test-image/test-image-small.jpg |
|
17
|
+
| photos/test-image/test-image-medium.jpg |
|
18
|
+
| photos/test-image/test-image-large.jpg |
|
19
|
+
Then the file "testfile.html" should contain "<object"
|
20
|
+
And the file "testfile.html" should contain "@media%20screen%20and%20(max-width:200px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-small.jpg);%7D%7D"
|
21
|
+
And the file "testfile.html" should contain "@media%20screen%20and%20(min-width:201px)%20and%20(max-width:400px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-medium.jpg);%7D%7D"
|
22
|
+
And the file "testfile.html" should contain "@media%20screen%20and%20(min-width:401px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-large.jpg);%7D%7D"
|
21
23
|
|
22
24
|
Scenario: Basic command with asset_host
|
23
25
|
Given a fixture app "automatic-clowncar-app"
|
@@ -32,43 +34,147 @@ Feature: Generating SVG clowncars during preview mode
|
|
32
34
|
:namespace_directory => %w(photos)
|
33
35
|
activate :asset_host, :host => "http://localhost:4567/"
|
34
36
|
"""
|
35
|
-
And a file named "source/
|
37
|
+
And a file named "source/testfile.html.erb" with:
|
36
38
|
"""
|
37
39
|
<%= automatic_clowncar_tag "photos/test-image.jpg" %>
|
38
40
|
"""
|
39
41
|
Given a successfully built app at "automatic-clowncar-app" with flags "--verbose"
|
40
42
|
When I cd to "build"
|
41
43
|
#Then the following files should not exist:
|
42
|
-
# |
|
44
|
+
# | photos/test-image.jpg
|
43
45
|
Then the following files should exist:
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
Then the file "
|
48
|
-
And the file "
|
49
|
-
And the file "
|
50
|
-
And the file "
|
46
|
+
| photos/test-image/test-image-small.jpg |
|
47
|
+
| photos/test-image/test-image-medium.jpg |
|
48
|
+
| photos/test-image/test-image-large.jpg |
|
49
|
+
Then the file "testfile.html" should contain "<object"
|
50
|
+
And the file "testfile.html" should contain "@media%20screen%20and%20(max-width:200px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-small.jpg);%7D%7D"
|
51
|
+
And the file "testfile.html" should contain "@media%20screen%20and%20(min-width:201px)%20and%20(max-width:400px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-medium.jpg);%7D%7D"
|
52
|
+
And the file "testfile.html" should contain "@media%20screen%20and%20(min-width:401px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-large.jpg);%7D%7D"
|
51
53
|
|
52
54
|
Scenario: With OldIE Fallback
|
53
55
|
Given a fixture app "automatic-clowncar-app"
|
54
|
-
And a file named "source/
|
56
|
+
And a file named "source/testfile.html.erb" with:
|
55
57
|
"""
|
56
58
|
<%= automatic_clowncar_tag "photos/test-image.jpg", :host => "http://localhost:4567/", :fallback => true %>
|
57
59
|
"""
|
58
60
|
Given a successfully built app at "automatic-clowncar-app" with flags "--verbose"
|
59
61
|
When I cd to "build"
|
60
62
|
#Then the following files should not exist:
|
61
|
-
# |
|
63
|
+
# | photos/test-image.jpg
|
62
64
|
Then the following files should exist:
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
Then the file "
|
67
|
-
And the file "
|
68
|
-
And the file "
|
69
|
-
And the file "
|
70
|
-
And the file "
|
71
|
-
And the file "
|
72
|
-
And the file "
|
65
|
+
| photos/test-image/test-image-small.jpg |
|
66
|
+
| photos/test-image/test-image-medium.jpg |
|
67
|
+
| photos/test-image/test-image-large.jpg |
|
68
|
+
Then the file "testfile.html" should contain "<object"
|
69
|
+
And the file "testfile.html" should contain "@media%20screen%20and%20(max-width:200px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-small.jpg);%7D%7D"
|
70
|
+
And the file "testfile.html" should contain "@media%20screen%20and%20(min-width:201px)%20and%20(max-width:400px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-medium.jpg);%7D%7D"
|
71
|
+
And the file "testfile.html" should contain "@media%20screen%20and%20(min-width:401px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-large.jpg);%7D%7D"
|
72
|
+
And the file "testfile.html" should contain "<!--[if lte IE 8]>"
|
73
|
+
And the file "testfile.html" should contain '<img src="/photos/test-image/test-image-small.jpg">'
|
74
|
+
And the file "testfile.html" should contain "<![endif]-->"
|
75
|
+
|
76
|
+
|
77
|
+
Scenario: With prevent_upscaling
|
78
|
+
Given a fixture app "automatic-clowncar-app"
|
79
|
+
And a file named "source/testfile.html.erb" with:
|
80
|
+
"""
|
81
|
+
<%= automatic_clowncar_tag "photos/test-image.jpg", :host => "http://localhost:4567/", :prevent_upscaling => true %>
|
82
|
+
"""
|
83
|
+
Given a successfully built app at "automatic-clowncar-app" with flags "--verbose"
|
84
|
+
When I cd to "build"
|
85
|
+
#Then the following files should not exist:
|
86
|
+
# | photos/test-image.jpg
|
87
|
+
Then the following files should exist:
|
88
|
+
| photos/test-image/test-image-small.jpg |
|
89
|
+
| photos/test-image/test-image-medium.jpg |
|
90
|
+
| photos/test-image/test-image-large.jpg |
|
91
|
+
Then the file "testfile.html" should contain "<object"
|
92
|
+
And the file "testfile.html" should contain "@media%20screen%20and%20(max-width:200px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-small.jpg);%7D%7D"
|
93
|
+
And the file "testfile.html" should contain "@media%20screen%20and%20(min-width:201px)%20and%20(max-width:400px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-medium.jpg);%7D%7D"
|
94
|
+
And the file "testfile.html" should contain "@media%20screen%20and%20(min-width:401px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-large.jpg);%7D%7D"
|
95
|
+
And the file "testfile.html" should contain "max-width:1576px"
|
96
|
+
|
97
|
+
Scenario: Including originals
|
98
|
+
Given a fixture app "automatic-clowncar-app"
|
99
|
+
And a file named "source/testfile.html.erb" with:
|
100
|
+
"""
|
101
|
+
<%= automatic_clowncar_tag "photos/test-image.jpg", :host => "http://localhost:4567/", :include_original => true %>
|
102
|
+
"""
|
103
|
+
Given a successfully built app at "automatic-clowncar-app" with flags "--verbose"
|
104
|
+
When I cd to "build"
|
105
|
+
#Then the following files should not exist:
|
106
|
+
# | photos/test-image.jpg |
|
107
|
+
Then the following files should exist:
|
108
|
+
| photos/test-image.jpg |
|
109
|
+
| photos/test-image/test-image-small.jpg |
|
110
|
+
| photos/test-image/test-image-medium.jpg |
|
111
|
+
| photos/test-image/test-image-large.jpg |
|
112
|
+
Then the file "testfile.html" should contain "<object"
|
113
|
+
And the file "testfile.html" should contain "@media%20screen%20and%20(max-width:200px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-small.jpg);%7D%7D"
|
114
|
+
And the file "testfile.html" should contain "@media%20screen%20and%20(min-width:201px)%20and%20(max-width:400px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-medium.jpg);%7D%7D"
|
115
|
+
And the file "testfile.html" should contain "@media%20screen%20and%20(min-width:401px)%20and%20(max-width:600px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-large.jpg);%7D%7D"
|
116
|
+
And the file "testfile.html" should contain "@media%20screen%20and%20(min-width:601px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/../test-image.jpg);%7D%7D"
|
117
|
+
|
118
|
+
Scenario: Don't generate upscaled images
|
119
|
+
Given a fixture app "automatic-clowncar-app"
|
120
|
+
And a file named "config.rb" with:
|
121
|
+
"""
|
122
|
+
activate :automatic_clowncar,
|
123
|
+
:sizes => {
|
124
|
+
:small => 200,
|
125
|
+
:medium => 400,
|
126
|
+
:huge => 3000
|
127
|
+
},
|
128
|
+
:namespace_directory => %w(photos)
|
129
|
+
activate :asset_host, :host => "http://localhost:4567/"
|
130
|
+
"""
|
131
|
+
And a file named "source/testfile.html.erb" with:
|
132
|
+
"""
|
133
|
+
<%= automatic_clowncar_tag "photos/test-image.jpg" %>
|
134
|
+
"""
|
135
|
+
Given a successfully built app at "automatic-clowncar-app" with flags "--verbose"
|
136
|
+
When I cd to "build"
|
137
|
+
Then the following files should not exist:
|
138
|
+
| photos/test-image/test-image-huge.jpg |
|
139
|
+
Then the following files should exist:
|
140
|
+
| photos/test-image/test-image-small.jpg |
|
141
|
+
| photos/test-image/test-image-medium.jpg |
|
142
|
+
Then the file "testfile.html" should contain "<object"
|
143
|
+
And the file "testfile.html" should contain "@media%20screen%20and%20(max-width:200px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-small.jpg);%7D%7D"
|
144
|
+
And the file "testfile.html" should contain "@media%20screen%20and%20(min-width:201px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-medium.jpg);%7D%7D"
|
145
|
+
And the file "testfile.html" should not contain "test-image-huge.jpg"
|
146
|
+
|
147
|
+
Scenario: Including originals at the top level
|
148
|
+
Given a fixture app "automatic-clowncar-app"
|
149
|
+
And a file named "config.rb" with:
|
150
|
+
"""
|
151
|
+
activate :automatic_clowncar,
|
152
|
+
:sizes => {
|
153
|
+
:small => 200,
|
154
|
+
:medium => 400,
|
155
|
+
:large => 600
|
156
|
+
},
|
157
|
+
:namespace_directory => %w(photos),
|
158
|
+
:include_originals => true
|
159
|
+
activate :asset_host, :host => "http://localhost:4567/"
|
160
|
+
"""
|
161
|
+
And a file named "source/testfile.html.erb" with:
|
162
|
+
"""
|
163
|
+
<%= automatic_clowncar_tag "photos/test-image.jpg" %>
|
164
|
+
"""
|
165
|
+
Given a successfully built app at "automatic-clowncar-app" with flags "--verbose"
|
166
|
+
When I cd to "build"
|
167
|
+
#Then the following files should not exist:
|
168
|
+
# | photos/test-image.jpg |
|
169
|
+
Then the following files should exist:
|
170
|
+
| photos/test-image.jpg |
|
171
|
+
| photos/test-image/test-image-small.jpg |
|
172
|
+
| photos/test-image/test-image-medium.jpg |
|
173
|
+
| photos/test-image/test-image-large.jpg |
|
174
|
+
Then the file "testfile.html" should contain "<object"
|
175
|
+
And the file "testfile.html" should contain "@media%20screen%20and%20(max-width:200px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-small.jpg);%7D%7D"
|
176
|
+
And the file "testfile.html" should contain "@media%20screen%20and%20(min-width:201px)%20and%20(max-width:400px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-medium.jpg);%7D%7D"
|
177
|
+
And the file "testfile.html" should contain "@media%20screen%20and%20(min-width:401px)%20and%20(max-width:600px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-large.jpg);%7D%7D"
|
178
|
+
And the file "testfile.html" should contain "@media%20screen%20and%20(min-width:601px)%7Bsvg%7Bbackground-image:url(/photos/test-image/../test-image.jpg);%7D%7D"
|
73
179
|
|
74
180
|
|
@@ -2,16 +2,16 @@ Feature: Generating SVG clowncars during preview mode
|
|
2
2
|
|
3
3
|
Scenario: Basic command
|
4
4
|
Given a fixture app "automatic-clowncar-app"
|
5
|
-
And a file named "source/index.html.erb" with:
|
5
|
+
And a file named "source/not-index.html.erb" with:
|
6
6
|
"""
|
7
7
|
<%= automatic_clowncar_tag "photos/test-image.jpg", :host => "http://localhost:4567/" %>
|
8
8
|
"""
|
9
9
|
And the Server is running at "automatic-clowncar-app"
|
10
|
-
When I go to "/index.html"
|
10
|
+
When I go to "/not-index.html"
|
11
11
|
Then I should see "<object"
|
12
|
-
And I should see "@media%20screen%20and%20(max-width:200px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/
|
13
|
-
And I should see "@media%20screen%20and%20(min-width:201px)%20and%20(max-width:400px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/
|
14
|
-
And I should see "@media%20screen%20and%20(min-width:401px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/
|
12
|
+
And I should see "@media%20screen%20and%20(max-width:200px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-small.jpg);%7D%7D"
|
13
|
+
And I should see "@media%20screen%20and%20(min-width:201px)%20and%20(max-width:400px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-medium.jpg);%7D%7D"
|
14
|
+
And I should see "@media%20screen%20and%20(min-width:401px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-large.jpg);%7D%7D"
|
15
15
|
|
16
16
|
Scenario: Basic command with asset_host
|
17
17
|
Given a fixture app "automatic-clowncar-app"
|
@@ -26,30 +26,45 @@ Feature: Generating SVG clowncars during preview mode
|
|
26
26
|
:namespace_directory => %w(photos)
|
27
27
|
activate :asset_host, :host => "http://localhost:4567/"
|
28
28
|
"""
|
29
|
-
And a file named "source/index.html.erb" with:
|
29
|
+
And a file named "source/not-index.html.erb" with:
|
30
30
|
"""
|
31
31
|
<%= automatic_clowncar_tag "photos/test-image.jpg" %>
|
32
32
|
"""
|
33
33
|
And the Server is running at "automatic-clowncar-app"
|
34
|
-
When I go to "/index.html"
|
34
|
+
When I go to "/not-index.html"
|
35
35
|
Then I should see "<object"
|
36
|
-
And I should see "@media%20screen%20and%20(max-width:200px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/
|
37
|
-
And I should see "@media%20screen%20and%20(min-width:201px)%20and%20(max-width:400px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/
|
38
|
-
And I should see "@media%20screen%20and%20(min-width:401px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/
|
36
|
+
And I should see "@media%20screen%20and%20(max-width:200px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-small.jpg);%7D%7D"
|
37
|
+
And I should see "@media%20screen%20and%20(min-width:201px)%20and%20(max-width:400px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-medium.jpg);%7D%7D"
|
38
|
+
And I should see "@media%20screen%20and%20(min-width:401px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-large.jpg);%7D%7D"
|
39
39
|
|
40
40
|
Scenario: With OldIE Fallback
|
41
41
|
Given a fixture app "automatic-clowncar-app"
|
42
|
-
And a file named "source/index.html.erb" with:
|
42
|
+
And a file named "source/not-index.html.erb" with:
|
43
43
|
"""
|
44
44
|
<%= automatic_clowncar_tag "photos/test-image.jpg", :host => "http://localhost:4567/", :fallback => true %>
|
45
45
|
"""
|
46
46
|
And the Server is running at "automatic-clowncar-app"
|
47
|
-
When I go to "/index.html"
|
47
|
+
When I go to "/not-index.html"
|
48
48
|
Then I should see "<object"
|
49
|
-
And I should see "@media%20screen%20and%20(max-width:200px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/
|
50
|
-
And I should see "@media%20screen%20and%20(min-width:201px)%20and%20(max-width:400px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/
|
51
|
-
And I should see "@media%20screen%20and%20(min-width:401px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/
|
49
|
+
And I should see "@media%20screen%20and%20(max-width:200px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-small.jpg);%7D%7D"
|
50
|
+
And I should see "@media%20screen%20and%20(min-width:201px)%20and%20(max-width:400px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-medium.jpg);%7D%7D"
|
51
|
+
And I should see "@media%20screen%20and%20(min-width:401px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-large.jpg);%7D%7D"
|
52
52
|
And I should see "<!--[if lte IE 8]>"
|
53
|
-
And I should see '<img src="/
|
53
|
+
And I should see '<img src="/photos/test-image/test-image-small.jpg">'
|
54
54
|
And I should see "<![endif]-->"
|
55
55
|
|
56
|
+
Scenario: With prevent_upscaling
|
57
|
+
Given a fixture app "automatic-clowncar-app"
|
58
|
+
And a file named "source/not-index.html.erb" with:
|
59
|
+
"""
|
60
|
+
<%= automatic_clowncar_tag "photos/test-image.jpg", :host => "http://localhost:4567/", :prevent_upscaling => true %>
|
61
|
+
"""
|
62
|
+
And the Server is running at "automatic-clowncar-app"
|
63
|
+
When I go to "/not-index.html"
|
64
|
+
Then I should see "<object"
|
65
|
+
And I should see "@media%20screen%20and%20(max-width:200px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-small.jpg);%7D%7D"
|
66
|
+
And I should see "@media%20screen%20and%20(min-width:201px)%20and%20(max-width:400px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-medium.jpg);%7D%7D"
|
67
|
+
And I should see "@media%20screen%20and%20(min-width:401px)%7Bsvg%7Bbackground-image:url(http://localhost:4567/photos/test-image/test-image-large.jpg);%7D%7D"
|
68
|
+
And I should see "max-width:1576px"
|
69
|
+
|
70
|
+
|
data/features/support/env.rb
CHANGED
@@ -1,7 +1,19 @@
|
|
1
1
|
ENV["TEST"] = "true"
|
2
2
|
ENV["AUTOLOAD_SPROCKETS"] = "false"
|
3
3
|
|
4
|
+
#require 'coveralls'
|
5
|
+
#Coveralls.wear!
|
6
|
+
|
7
|
+
#require 'simplecov'
|
8
|
+
#SimpleCov.start
|
9
|
+
|
10
|
+
|
4
11
|
PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
|
5
12
|
require "middleman-core"
|
6
13
|
require "middleman-core/step_definitions"
|
14
|
+
require "middleman-sprockets"
|
7
15
|
require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-automatic-clowncar')
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Given(/^the file "(.*?)" has been overwritten with "(.*?)"$/) do |file1,file2|
|
2
|
+
FileUtils.cp File.join(expand_path('.'),file2), File.join(expand_path('.'),file1)
|
3
|
+
end
|
4
|
+
|
5
|
+
Given(/^some time has passed$/) do
|
6
|
+
sleep 30
|
7
|
+
end
|
8
|
+
|
9
|
+
Then(/^we should write some stuff to the console$/) do
|
10
|
+
puts "here's testfile.html"
|
11
|
+
puts File.open(File.join(expand_path('.'),"testfile.html")).read
|
12
|
+
#puts "------"
|
13
|
+
#puts File.open(File.join(expand_path('.'),"photos/test-image/test-image-small.jpg"),'rb').read
|
14
|
+
end
|