picture_tag 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a522369e8c238d79c3f8c1c28f57552bb74e04b
4
- data.tar.gz: 518c916b7b43430a9c8bf01b4ca5fa231962b41f
3
+ metadata.gz: 07303344956dfbc17835db1ed6b262af3f3f8c85
4
+ data.tar.gz: 928988902d49cd4e034f2c9085111396cdbc6741
5
5
  SHA512:
6
- metadata.gz: f14b02492f53b234d0ec0ad812095784a6667270ae815d8267b197035125e8ecf859ee7a90b1b670250e1c54d6213a20d00c4dafb9a32867ebadbd1adf9f76bb
7
- data.tar.gz: b0368f9d0f5768b68caa1d3e85219062e546640f9d4fe8026545c4acd308155b0559d229184c9ae036b1b8590abfa05a8dcadc3f4c387db75fa6ecebb8b98f2e
6
+ metadata.gz: 6c2421d15f25135c59dcfa2a89c6403aef6f7248529acbb0a0c824e5e5923550df89fc48fb04d8096a4c5d3da7f3bf7f5b25a9fe6d25041983decbee44b1c44d
7
+ data.tar.gz: 855abf42b82ce6d8584ec41a8bb97661402d3d4406563f3c9a4fcab641fe33cd480e31ff39a3862f97303402426ff600e279e2b5bf747b1ed351881f731f0de0
data/.gitignore CHANGED
@@ -20,3 +20,4 @@ tmp
20
20
  *.o
21
21
  *.a
22
22
  mkmf.log
23
+ .DS_Store
@@ -1,3 +1,3 @@
1
1
  module PictureTag
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -9,10 +9,10 @@ module PictureTag
9
9
  end
10
10
  end
11
11
 
12
- def picture_tag src, options={}, &block
12
+ def picture_tag srcset, options={}, &block
13
13
  picture_options = options.except(:image)
14
14
  image_options = options.fetch(:image, {})
15
- image_options[:srcset] = src
15
+ image_options[:srcset] = srcset
16
16
 
17
17
  content_tag :picture, picture_options do
18
18
  "<!--[if IE 9]><video style='display: none;'><![endif]-->".html_safe +
@@ -18,36 +18,41 @@ module PictureTag
18
18
  # ---------------------------------------------------------------------
19
19
 
20
20
  describe '#picture_tag' do
21
- let(:src) { 'src' }
21
+ let(:srcset) { 'srcset' }
22
22
  let(:alt) { 'alt text' }
23
- let(:image_options) { { alt: alt } }
23
+ let(:src) { 'foo bar src' }
24
+ let(:image_options) { { alt: alt, src: src } }
24
25
  let(:content) { 'content' }
25
26
  let(:ie9_start) { "<!--[if IE 9]><video style='display: none;'><![endif]-->" }
26
27
  let(:ie9_end) { "<!--[if IE 9]></video><![endif]-->" }
27
28
 
28
29
  it 'returns picture tag' do
29
- picture_tag(src, image: image_options) { content }.must_match Regexp.new("\\A<picture>.*?</picture>\\z")
30
+ picture_tag(srcset, image: image_options) { content }.must_match Regexp.new("\\A<picture>.*?</picture>\\z")
30
31
  end
31
32
 
32
33
  it 'wraps content in the picture tag' do
33
- picture_tag(src, image: image_options) { content }.must_match Regexp.new("<picture>.*#{content}.*</picture>")
34
+ picture_tag(srcset, image: image_options) { content }.must_match Regexp.new("<picture>.*#{content}.*</picture>")
34
35
  end
35
36
 
36
37
  it 'adds image tag after the content' do
37
- picture_tag(src, image: image_options) { content }.must_match Regexp.new("#{content}.*<img.*?/></picture>")
38
+ picture_tag(srcset, image: image_options) { content }.must_match Regexp.new("#{content}.*<img.*?/></picture>")
38
39
  end
39
40
 
40
- it 'passes src to the image tag srcset' do
41
- picture_tag(src) { content }.must_match Regexp.new("<img.*?srcset=\".*?#{src}.*?\".*?/>")
41
+ it 'passes srcset to the image tag srcset' do
42
+ picture_tag(srcset) { content }.must_match Regexp.new("<img.*?srcset=\".*?#{srcset}.*?\".*?/>")
42
43
  end
43
44
 
44
- it 'passes image options to the image tag' do
45
- picture_tag(src, image: image_options) { content }.must_match Regexp.new("<img.*?alt=\"#{alt}\".*?/>")
45
+ it 'passes alt to the image tag' do
46
+ picture_tag(srcset, image: image_options) { content }.must_match Regexp.new("<img.*?alt=\"#{alt}\".*?/>")
47
+ end
48
+
49
+ it 'passes src to the image tag' do
50
+ picture_tag(srcset, image: image_options) { content }.must_match Regexp.new("<img.*?src=\"#{src}\".*?/>")
46
51
  end
47
52
 
48
53
  it 'wraps content with the IE9 fix' do
49
- index_of_content = picture_tag(src) { content }.index(content)
50
- index_of_ie9_start_tag = picture_tag(src) { content }.index(ie9_start)
54
+ index_of_content = picture_tag(srcset) { content }.index(content)
55
+ index_of_ie9_start_tag = picture_tag(srcset) { content }.index(ie9_start)
51
56
  index_of_ie9_end_tag = picture_tag(src) { content }.index(ie9_end)
52
57
  (index_of_ie9_start_tag < index_of_content).must_equal true
53
58
  (index_of_ie9_end_tag > index_of_content).must_equal true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: picture_tag
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Celizna
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-03 00:00:00.000000000 Z
11
+ date: 2015-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails