padrino-assets 0.2.2 → 0.3.0
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/.gitignore +6 -4
- data/.rspec +2 -0
- data/.travis.yml +7 -0
- data/.yardopts +10 -0
- data/CHANGELOG.md +11 -8
- data/Gemfile +1 -1
- data/LICENSE +18 -18
- data/README.md +126 -64
- data/Rakefile +30 -7
- data/lib/padrino-assets.rb +154 -91
- data/lib/padrino-assets/helpers.rb +445 -379
- data/lib/padrino-assets/version.rb +5 -4
- data/lib/tasks/cleanup.rake +8 -7
- data/lib/tasks/clobber.rake +7 -6
- data/lib/tasks/compress.rake +14 -13
- data/lib/tasks/precompile.rake +32 -29
- data/padrino-assets.gemspec +25 -24
- data/spec/assets_spec.rb +61 -0
- data/spec/fixtures/assets/application.css +11 -0
- data/spec/fixtures/assets/application.js +1 -0
- data/spec/fixtures/assets/pony.jpg +0 -0
- data/spec/fixtures/compiled_assets/application-b8588c6975a4539fbf2c11471870bdca.css +11 -0
- data/spec/fixtures/compiled_assets/manifest.json +1 -0
- data/spec/helpers_spec.rb +293 -0
- data/spec/spec.rb +37 -0
- data/spec/tasks_spec.rb +114 -0
- metadata +39 -21
- data/examples/nginx.md +0 -11
- data/test/test.rb +0 -52
- data/test/test_helpers.rb +0 -339
data/spec/spec.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
PADRINO_ENV = 'test'
|
2
|
+
|
3
|
+
require 'rspec'
|
4
|
+
require 'rspec-html-matchers'
|
5
|
+
require 'padrino-assets'
|
6
|
+
|
7
|
+
module TestHelpers
|
8
|
+
def app
|
9
|
+
@app ||= Sinatra.new(Padrino::Application) do
|
10
|
+
register Padrino::Assets
|
11
|
+
set :manifest_file, File.join(settings.root, 'fixtures', 'compiled_assets', 'manifest.json')
|
12
|
+
set :logging, false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def settings
|
17
|
+
app.settings
|
18
|
+
end
|
19
|
+
|
20
|
+
def request
|
21
|
+
@request ||= Sinatra::Request.new(nil.to_s)
|
22
|
+
end
|
23
|
+
|
24
|
+
def environment
|
25
|
+
Padrino::Assets.environment
|
26
|
+
end
|
27
|
+
|
28
|
+
def manifest
|
29
|
+
Padrino::Assets.manifest
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
RSpec.configure do |configuration|
|
34
|
+
configuration.include TestHelpers
|
35
|
+
end
|
36
|
+
|
37
|
+
Padrino::Assets.load_paths << File.dirname(__FILE__) + '/fixtures/assets'
|
data/spec/tasks_spec.rb
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
require_relative 'spec'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'tmpdir'
|
4
|
+
require 'rake'
|
5
|
+
|
6
|
+
describe 'Rake Tasks' do
|
7
|
+
let :temp_directory do
|
8
|
+
File.join(Dir.tmpdir, 'sprockets')
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:image) { File.join(temp_directory, environment['pony.jpg'].digest_path) }
|
12
|
+
let(:stylesheet) { File.join(temp_directory, environment['application.css'].digest_path) }
|
13
|
+
let(:javascript) { File.join(temp_directory, environment['application.js'].digest_path) }
|
14
|
+
|
15
|
+
let :rake do
|
16
|
+
Rake.application
|
17
|
+
end
|
18
|
+
|
19
|
+
before do
|
20
|
+
app.set :manifest_file, File.join(temp_directory, 'manifest.json')
|
21
|
+
app.set :app_obj, app
|
22
|
+
|
23
|
+
Padrino.after_load.each(&:call)
|
24
|
+
Padrino.clear!
|
25
|
+
|
26
|
+
Padrino.insert_mounted_app(app)
|
27
|
+
|
28
|
+
Rake.application = Rake::Application.new
|
29
|
+
Dir.glob(File.expand_path('../../lib/tasks/*.rake', __FILE__)).each do |task|
|
30
|
+
load(task)
|
31
|
+
end
|
32
|
+
rake.load_imports
|
33
|
+
end
|
34
|
+
|
35
|
+
after do
|
36
|
+
FileUtils.rm_rf(temp_directory)
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'assets:precompile' do
|
40
|
+
it 'should allow you to use a regexp to filter assets' do
|
41
|
+
app.set :precompile_assets, [/^application\.(css|js)$/]
|
42
|
+
rake['assets:precompile'].invoke
|
43
|
+
|
44
|
+
File.should exist(stylesheet)
|
45
|
+
File.should exist(javascript)
|
46
|
+
File.should_not exist(image)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should allow you to use a proc to filter assets' do
|
50
|
+
app.set :precompile_assets, [ ->(asset) { !File.extname(asset).in?(['.css', '.js']) } ]
|
51
|
+
rake['assets:precompile'].invoke
|
52
|
+
|
53
|
+
File.should exist(image)
|
54
|
+
File.should_not exist(stylesheet)
|
55
|
+
File.should_not exist(javascript)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should allow you to use a string to filter assets' do
|
59
|
+
app.set :precompile_assets, ['pony.jpg', 'application.css']
|
60
|
+
rake['assets:precompile'].invoke
|
61
|
+
|
62
|
+
File.should exist(stylesheet)
|
63
|
+
File.should exist(image)
|
64
|
+
File.should_not exist(javascript)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should automatically compress assets when enabled' do
|
68
|
+
app.set :precompile_assets, ['application.css']
|
69
|
+
app.set :compress_assets, true
|
70
|
+
|
71
|
+
rake['assets:precompile'].invoke
|
72
|
+
|
73
|
+
File.should exist(stylesheet)
|
74
|
+
File.should exist(stylesheet + '.gz')
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'assets:clobber' do
|
79
|
+
it 'should delete the directory' do
|
80
|
+
rake['assets:precompile'].invoke
|
81
|
+
File.should exist(app.manifest_file)
|
82
|
+
|
83
|
+
rake['assets:clobber'].invoke
|
84
|
+
File.should_not exist(manifest.dir)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'assets:compress' do
|
89
|
+
it 'should compress assets' do
|
90
|
+
app.set :precompile_assets, [/^application\.(css|js)$/]
|
91
|
+
app.set :compress_assets, false
|
92
|
+
|
93
|
+
rake['assets:precompile'].invoke
|
94
|
+
rake['assets:compress'].invoke
|
95
|
+
|
96
|
+
File.should exist(stylesheet)
|
97
|
+
File.should exist(stylesheet + '.gz')
|
98
|
+
File.should exist(javascript)
|
99
|
+
File.should exist(javascript + '.gz')
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should only compress text based assets' do
|
103
|
+
app.set :precompile_assets, [/.+/]
|
104
|
+
app.set :compress_assets, false
|
105
|
+
|
106
|
+
rake['assets:precompile'].invoke
|
107
|
+
rake['assets:compress'].invoke
|
108
|
+
|
109
|
+
File.should exist(stylesheet + '.gz')
|
110
|
+
File.should exist(javascript + '.gz')
|
111
|
+
File.should_not exist(image + '.gz')
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: padrino-assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-03-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sprockets
|
16
|
-
requirement: &
|
16
|
+
requirement: &15358392 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.3.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *15358392
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: padrino-core
|
27
|
-
requirement: &
|
27
|
+
requirement: &15357600 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *15357600
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: padrino-helpers
|
38
|
-
requirement: &
|
38
|
+
requirement: &15356832 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *15356832
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
49
|
-
requirement: &
|
48
|
+
name: rake
|
49
|
+
requirement: &15356448 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,21 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *15356448
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
|
-
name:
|
60
|
-
requirement: &
|
59
|
+
name: rspec
|
60
|
+
requirement: &15356040 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 2.0.0
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *15356040
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec-html-matchers
|
71
|
+
requirement: &15355728 !ruby/object:Gem::Requirement
|
61
72
|
none: false
|
62
73
|
requirements:
|
63
74
|
- - ! '>='
|
@@ -65,7 +76,7 @@ dependencies:
|
|
65
76
|
version: '0'
|
66
77
|
type: :development
|
67
78
|
prerelease: false
|
68
|
-
version_requirements: *
|
79
|
+
version_requirements: *15355728
|
69
80
|
description: A plugin for the Padrino web framework which uses Sprockets to manage
|
70
81
|
and compile assets
|
71
82
|
email:
|
@@ -75,12 +86,14 @@ extensions: []
|
|
75
86
|
extra_rdoc_files: []
|
76
87
|
files:
|
77
88
|
- .gitignore
|
89
|
+
- .rspec
|
90
|
+
- .travis.yml
|
91
|
+
- .yardopts
|
78
92
|
- CHANGELOG.md
|
79
93
|
- Gemfile
|
80
94
|
- LICENSE
|
81
95
|
- README.md
|
82
96
|
- Rakefile
|
83
|
-
- examples/nginx.md
|
84
97
|
- lib/padrino-assets.rb
|
85
98
|
- lib/padrino-assets/helpers.rb
|
86
99
|
- lib/padrino-assets/version.rb
|
@@ -89,8 +102,15 @@ files:
|
|
89
102
|
- lib/tasks/compress.rake
|
90
103
|
- lib/tasks/precompile.rake
|
91
104
|
- padrino-assets.gemspec
|
92
|
-
-
|
93
|
-
-
|
105
|
+
- spec/assets_spec.rb
|
106
|
+
- spec/fixtures/assets/application.css
|
107
|
+
- spec/fixtures/assets/application.js
|
108
|
+
- spec/fixtures/assets/pony.jpg
|
109
|
+
- spec/fixtures/compiled_assets/application-b8588c6975a4539fbf2c11471870bdca.css
|
110
|
+
- spec/fixtures/compiled_assets/manifest.json
|
111
|
+
- spec/helpers_spec.rb
|
112
|
+
- spec/spec.rb
|
113
|
+
- spec/tasks_spec.rb
|
94
114
|
homepage: https://github.com/Cirex/padrino-assets
|
95
115
|
licenses: []
|
96
116
|
post_install_message:
|
@@ -111,12 +131,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
131
|
version: '0'
|
112
132
|
requirements: []
|
113
133
|
rubyforge_project:
|
114
|
-
rubygems_version: 1.8.
|
134
|
+
rubygems_version: 1.8.17
|
115
135
|
signing_key:
|
116
136
|
specification_version: 3
|
117
137
|
summary: A plugin for the Padrino web framework which uses Sprockets to manage and
|
118
138
|
compile assets
|
119
|
-
test_files:
|
120
|
-
- test/test.rb
|
121
|
-
- test/test_helpers.rb
|
139
|
+
test_files: []
|
122
140
|
has_rdoc:
|
data/examples/nginx.md
DELETED
data/test/test.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'webrat'
|
2
|
-
require 'padrino-assets'
|
3
|
-
require 'minitest/pride'
|
4
|
-
require 'minitest/autorun'
|
5
|
-
|
6
|
-
Padrino::Assets.load_paths << File.dirname(__FILE__) + '/fixtures/assets/**'
|
7
|
-
|
8
|
-
module MiniTest
|
9
|
-
class Spec
|
10
|
-
class << self
|
11
|
-
alias_method :context, :describe
|
12
|
-
end
|
13
|
-
|
14
|
-
def app
|
15
|
-
@app ||= Sinatra.new(Padrino::Application) do
|
16
|
-
register Padrino::Assets
|
17
|
-
set :environment, :test
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def settings
|
22
|
-
app.settings
|
23
|
-
end
|
24
|
-
|
25
|
-
def request
|
26
|
-
nil
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
module Assertions
|
31
|
-
include Webrat::Matchers
|
32
|
-
|
33
|
-
def assert_has_tag(tag, html, attributes)
|
34
|
-
selector = HaveSelector.new(tag, attributes)
|
35
|
-
assert selector.matches?(html), selector.failure_message
|
36
|
-
end
|
37
|
-
|
38
|
-
def refute_has_tag(tag, html, attributes)
|
39
|
-
selector = HaveSelector.new(tag, attributes)
|
40
|
-
refute selector.matches?(html), selector.failure_message
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
module Expectations
|
45
|
-
infect_an_assertion :assert_has_tag, :must_have_tag
|
46
|
-
infect_an_assertion :refute_has_tag, :wont_have_tag
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
class Object
|
51
|
-
include MiniTest::Expectations
|
52
|
-
end
|
data/test/test_helpers.rb
DELETED
@@ -1,339 +0,0 @@
|
|
1
|
-
require_relative 'test'
|
2
|
-
|
3
|
-
describe 'Helpers' do
|
4
|
-
include Padrino::Helpers::OutputHelpers
|
5
|
-
include Padrino::Helpers::TagHelpers
|
6
|
-
include Padrino::Assets::Helpers
|
7
|
-
|
8
|
-
describe 'assets_path' do
|
9
|
-
it 'should prepend :assets_host when present' do
|
10
|
-
app.set :assets_host, 'http://www.test.com'
|
11
|
-
asset = asset_path('application.css')
|
12
|
-
asset.must_equal 'http://www.test.com/assets/application.css'
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should allow :assets_host to use a Proc' do
|
16
|
-
app.set :assets_host, ->(asset, request) { 'http://test.com' }
|
17
|
-
asset = asset_path('application.css')
|
18
|
-
asset.must_equal 'http://test.com/assets/application.css'
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should pass the current source to :assets_host when a Proc is used' do
|
22
|
-
app.set :assets_host, ->(source, request) do
|
23
|
-
if source =~ /application.css/
|
24
|
-
'http://true.com'
|
25
|
-
else
|
26
|
-
'http://false.com'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
asset = asset_path('application.css')
|
30
|
-
asset.must_equal 'http://true.com/assets/application.css'
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should append extension when provided' do
|
34
|
-
asset = asset_path(:application, :css)
|
35
|
-
asset.must_equal '/assets/application.css'
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should not append extension when one is present' do
|
39
|
-
asset = asset_path('application.css', :css)
|
40
|
-
asset.wont_equal '/assets/application.css.css'
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'should prepend :assets_prefix when present' do
|
44
|
-
app.set :assets_prefix, '/test'
|
45
|
-
asset = asset_path('application.css')
|
46
|
-
asset.must_equal '/test/application.css'
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'should prepend a forward slash to :assets_prefix when missing' do
|
50
|
-
app.set :assets_prefix, 'test'
|
51
|
-
asset = asset_path('application.css')
|
52
|
-
asset.must_equal '/test/application.css'
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'should not interfere with a reference URI' do
|
56
|
-
asset = asset_path('/application.css')
|
57
|
-
asset.must_equal '/application.css'
|
58
|
-
|
59
|
-
asset = asset_path('//test.com/application.css')
|
60
|
-
asset.must_equal '//test.com/application.css'
|
61
|
-
|
62
|
-
asset = asset_path('http://test.com/application.css')
|
63
|
-
asset.must_equal 'http://test.com/application.css'
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe 'is_uri?' do
|
68
|
-
it 'should return true when given an absolute URI' do
|
69
|
-
is_uri?('https://example.com/application.css').must_equal true
|
70
|
-
is_uri?('http://example.com/application.css').must_equal true
|
71
|
-
is_uri?('ftp://example.com/application.css').must_equal true
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'should return true when given a reference URI' do
|
75
|
-
is_uri?('//example.com/assets/application.css').must_equal true
|
76
|
-
is_uri?('/assets/application.css').must_equal true
|
77
|
-
end
|
78
|
-
|
79
|
-
it 'should return false when given a host without a protocol' do
|
80
|
-
is_uri?('example.com/assets/application.css').must_equal false
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'should return false when given an asset' do
|
84
|
-
is_uri?('application.css').must_equal false
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe 'include_stylesheet' do
|
89
|
-
it 'should accept multiple sources' do
|
90
|
-
stylesheets = include_stylesheets :application, :theme
|
91
|
-
stylesheets.must_have_tag :link, href: '/assets/application.css'
|
92
|
-
stylesheets.must_have_tag :link, href: '/assets/theme.css'
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'should accept multiple sources with attributes' do
|
96
|
-
stylesheets = include_stylesheets :application, :theme, media: 'handheld'
|
97
|
-
stylesheets.must_have_tag :link, href: '/assets/application.css', media: 'handheld'
|
98
|
-
stylesheets.must_have_tag :link, href: '/assets/theme.css', media: 'handheld'
|
99
|
-
end
|
100
|
-
|
101
|
-
it 'should accept a single source' do
|
102
|
-
stylesheet = include_stylesheet :application
|
103
|
-
stylesheet.must_have_tag :link, href: '/assets/application.css'
|
104
|
-
end
|
105
|
-
|
106
|
-
it 'should accept a single source with attributes' do
|
107
|
-
stylesheet = include_stylesheet :application, media: 'handheld'
|
108
|
-
stylesheet.must_have_tag :link, href: '/assets/application.css', media: 'handheld'
|
109
|
-
end
|
110
|
-
|
111
|
-
it 'should allow a source with an extension' do
|
112
|
-
stylesheet = include_stylesheet 'application.css'
|
113
|
-
stylesheet.wont_have_tag :link, hreg: '/assets/application.css.css'
|
114
|
-
end
|
115
|
-
|
116
|
-
it 'should be aliased for compatibility' do
|
117
|
-
respond_to?(:stylesheet_link_tag).must_equal true
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
describe 'include_javascript' do
|
122
|
-
it 'should accept multiple sources' do
|
123
|
-
javascripts = include_javascripts :application, :jquery
|
124
|
-
javascripts.must_have_tag :script, src: '/assets/application.js'
|
125
|
-
javascripts.must_have_tag :script, src: '/assets/jquery.js'
|
126
|
-
end
|
127
|
-
|
128
|
-
it 'should accept a single source' do
|
129
|
-
javascripts = include_javascript :application
|
130
|
-
javascripts.must_have_tag :script, src: '/assets/application.js'
|
131
|
-
end
|
132
|
-
|
133
|
-
it 'should be aliased for compatibility' do
|
134
|
-
respond_to?(:javascript_include_tag).must_equal true
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
describe 'image' do
|
139
|
-
it 'should accept multiple sources' do
|
140
|
-
images = images 'application.jpg', 'application.png'
|
141
|
-
images.must_have_tag :img, src: '/assets/application.jpg'
|
142
|
-
images.must_have_tag :img, src: '/assets/application.png'
|
143
|
-
end
|
144
|
-
|
145
|
-
it 'should accept multiple sources with attributes' do
|
146
|
-
images = images 'application.jpg', 'application.png', width: '40', height: '40'
|
147
|
-
images.must_have_tag :img, src: '/assets/application.jpg', width: '40', height: '40'
|
148
|
-
images.must_have_tag :img, src: '/assets/application.png', width: '40', height: '40'
|
149
|
-
end
|
150
|
-
|
151
|
-
it 'should accept a single source' do
|
152
|
-
image = image 'application.jpg'
|
153
|
-
image.must_have_tag :img, src: '/assets/application.jpg'
|
154
|
-
end
|
155
|
-
|
156
|
-
it 'should accept a single source with attributes' do
|
157
|
-
image = image 'application.jpg', width: '40', height: '40'
|
158
|
-
image.must_have_tag :img, width: '40', height: '40'
|
159
|
-
end
|
160
|
-
|
161
|
-
it 'should allow you to set the :width and :height with size' do
|
162
|
-
image = image 'application.jpg', size: '40x40'
|
163
|
-
image.must_have_tag :img, width: '40', height: '40'
|
164
|
-
end
|
165
|
-
|
166
|
-
it 'should allow you to set the :width' do
|
167
|
-
image = image 'application.jpg', width: '40'
|
168
|
-
image.must_have_tag :img, width: '40'
|
169
|
-
end
|
170
|
-
|
171
|
-
it 'should allow you to set the :height' do
|
172
|
-
image = image 'application.jpg', height: '40'
|
173
|
-
image.must_have_tag :img, height: '40'
|
174
|
-
end
|
175
|
-
|
176
|
-
it 'should allow you to set the alternate text' do
|
177
|
-
image = image 'application.jpg', alt: 'My Little Pony'
|
178
|
-
image.must_have_tag :img, alt: 'My Little Pony'
|
179
|
-
end
|
180
|
-
|
181
|
-
it 'should automatically set an alternate text when none present' do
|
182
|
-
image = image 'application.jpg'
|
183
|
-
image.must_have_tag :img, alt: 'Application'
|
184
|
-
end
|
185
|
-
|
186
|
-
it 'should allow you to set the :class' do
|
187
|
-
image = image 'application.jpg', class: 'image'
|
188
|
-
image.must_have_tag :img, class: 'image'
|
189
|
-
end
|
190
|
-
|
191
|
-
it 'should allow you to set the :id' do
|
192
|
-
image = image 'application.jpg', id: 'logo'
|
193
|
-
image.must_have_tag :img, id: 'logo'
|
194
|
-
end
|
195
|
-
|
196
|
-
it 'should be aliased for compatibility' do
|
197
|
-
respond_to?(:image_tag).must_equal true
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
describe 'video' do
|
202
|
-
it 'should accept multiple sources' do
|
203
|
-
videos = videos 'test.webm', 'test.mov'
|
204
|
-
videos.must_have_tag :source, src: '/assets/test.webm'
|
205
|
-
videos.must_have_tag :source, src: '/assets/test.mov'
|
206
|
-
end
|
207
|
-
|
208
|
-
it 'should accept multiple sources with attributes' do
|
209
|
-
videos = videos 'test.webm', 'test.mov', width: '40', height: '40'
|
210
|
-
videos.must_have_tag :video, width: '40', height: '40'
|
211
|
-
videos.must_have_tag :source, src: '/assets/test.webm'
|
212
|
-
videos.must_have_tag :source, src: '/assets/test.mov'
|
213
|
-
end
|
214
|
-
|
215
|
-
it 'should accept a single source' do
|
216
|
-
video = video 'test.webm'
|
217
|
-
video.must_have_tag :video, src: '/assets/test.webm'
|
218
|
-
end
|
219
|
-
|
220
|
-
it 'should accept a single source with attributes' do
|
221
|
-
video = video 'test.webm', width: '40', height: '40'
|
222
|
-
video.must_have_tag :video, src: '/assets/test.webm', width: '40', height: '40'
|
223
|
-
end
|
224
|
-
|
225
|
-
it 'should allow you to set the :class' do
|
226
|
-
video = video 'test.webm', class: 'video'
|
227
|
-
video.must_have_tag :video, class: 'video'
|
228
|
-
end
|
229
|
-
|
230
|
-
it 'should allow you to set the :id' do
|
231
|
-
video = video 'test.webm', id: 'video'
|
232
|
-
video.must_have_tag :video, id: 'video'
|
233
|
-
end
|
234
|
-
|
235
|
-
it 'should allow you to set the :width and :height with :size' do
|
236
|
-
video = video 'test.webm', size: '40x40'
|
237
|
-
video.must_have_tag :video, width: '40', height: '40'
|
238
|
-
end
|
239
|
-
|
240
|
-
it 'should allow you to set the :width' do
|
241
|
-
video = video 'test.webm', width: '40'
|
242
|
-
video.must_have_tag :video, width: '40'
|
243
|
-
end
|
244
|
-
|
245
|
-
it 'should allow you to set the :height' do
|
246
|
-
video = video 'test.webm', height: '40'
|
247
|
-
video.must_have_tag :video, height: '40'
|
248
|
-
end
|
249
|
-
|
250
|
-
it 'should allow :poster to use an absolute URI' do
|
251
|
-
video = video 'test.webm', poster: 'http://test.com/poster.jpg'
|
252
|
-
video.must_have_tag :video, poster: 'http://test.com/poster.jpg'
|
253
|
-
end
|
254
|
-
|
255
|
-
it 'should use asset_path when :poster is present' do
|
256
|
-
video = video 'test.webm', poster: 'poster.jpg'
|
257
|
-
video.must_have_tag :video, poster: '/assets/poster.jpg'
|
258
|
-
end
|
259
|
-
|
260
|
-
it 'should allow you to set the :preload method' do
|
261
|
-
video = video 'test.webm', preload: 'auto'
|
262
|
-
video.must_have_tag :video, preload: 'auto'
|
263
|
-
end
|
264
|
-
|
265
|
-
it 'should allow you to set :muted to true' do
|
266
|
-
video = video 'test.webm', muted: true
|
267
|
-
video.must_have_tag :video, muted: 'muted'
|
268
|
-
end
|
269
|
-
|
270
|
-
it 'should allow you to set :autoplay to true' do
|
271
|
-
video = video 'test.webm', autoplay: true
|
272
|
-
video.must_have_tag :video, autoplay: 'autoplay'
|
273
|
-
end
|
274
|
-
|
275
|
-
it 'should allow you to set :loop to true' do
|
276
|
-
video = video 'test.webm', loop: true
|
277
|
-
video.must_have_tag :video, loop: 'loop'
|
278
|
-
end
|
279
|
-
|
280
|
-
it 'should allow you to set :controls to true' do
|
281
|
-
video = video 'test.webm', controls: true
|
282
|
-
video.must_have_tag :video, controls: 'controls'
|
283
|
-
end
|
284
|
-
|
285
|
-
it 'should be aliased for compatibility' do
|
286
|
-
respond_to?(:video_tag).must_equal true
|
287
|
-
end
|
288
|
-
end
|
289
|
-
|
290
|
-
describe 'audio' do
|
291
|
-
it 'should accept multiple sources' do
|
292
|
-
audios = audios 'test.ogg', 'test.aac'
|
293
|
-
audios.must_have_tag :source, src: '/assets/test.ogg'
|
294
|
-
audios.must_have_tag :source, src: '/assets/test.aac'
|
295
|
-
end
|
296
|
-
|
297
|
-
it 'should accept multiple sources with attributes' do
|
298
|
-
audios = audios 'test.ogg', 'test.aac', id: 'audio'
|
299
|
-
audios.must_have_tag :audio, id: 'audio'
|
300
|
-
audios.must_have_tag :source, src: '/assets/test.ogg'
|
301
|
-
audios.must_have_tag :source, src: '/assets/test.aac'
|
302
|
-
end
|
303
|
-
|
304
|
-
it 'should accept a single source' do
|
305
|
-
audio = audio 'test.ogg'
|
306
|
-
audio.must_have_tag :audio, src: '/assets/test.ogg'
|
307
|
-
end
|
308
|
-
|
309
|
-
it 'should accept a single source with attributes' do
|
310
|
-
audio = audio 'test.ogg', id: 'audio'
|
311
|
-
audio.must_have_tag :audio, src: '/assets/test.ogg', id: 'audio'
|
312
|
-
end
|
313
|
-
|
314
|
-
it 'should allow you to set the :class' do
|
315
|
-
audio = audio 'test.ogg', class: 'audio'
|
316
|
-
audio.must_have_tag :audio, class: 'audio'
|
317
|
-
end
|
318
|
-
|
319
|
-
it 'should allow you to set the :id' do
|
320
|
-
audio = audio 'test.ogg', id: 'audio'
|
321
|
-
audio.must_have_tag :audio, id: 'audio'
|
322
|
-
end
|
323
|
-
|
324
|
-
it 'should allow you to set :autoplay to true' do
|
325
|
-
audio = audio 'test.ogg', autoplay: true
|
326
|
-
audio.must_have_tag :audio, autoplay: 'autoplay'
|
327
|
-
end
|
328
|
-
|
329
|
-
it 'should allow you to set :loop to true' do
|
330
|
-
audio = audio 'test.ogg', loop: true
|
331
|
-
audio.must_have_tag :audio, loop: 'loop'
|
332
|
-
end
|
333
|
-
|
334
|
-
it 'should allow you to set :controls to true' do
|
335
|
-
audio = audio 'test.ogg', controls: true
|
336
|
-
audio.must_have_tag :audio, controls: 'controls'
|
337
|
-
end
|
338
|
-
end
|
339
|
-
end
|