middleman-inline-style 0.5.1 → 0.6.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.
@@ -1,3 +0,0 @@
1
- #izq {
2
- margin: 30px;
3
- }
@@ -1,64 +0,0 @@
1
- require "#{ File.dirname __FILE__ }/spec_helper"
2
-
3
- require 'mail'
4
- Mail.defaults do
5
- delivery_method :test
6
- end
7
- Mail.register_interceptor \
8
- InlineStyle::Mail::Interceptor.new(:stylesheets_path => FIXTURES)
9
-
10
- describe InlineStyle::Mail::Interceptor do
11
-
12
- before do
13
- Mail::TestMailer.deliveries.clear
14
- end
15
-
16
- it 'should inline html e-mail' do
17
- Mail.deliver do
18
- to 'joe@example.com'
19
- from 'joe@example.com'
20
- subject 'HTML e-mail'
21
- content_type 'text/html'
22
- body File.read("#{ FIXTURES }/boletin.html")
23
- end
24
-
25
- Mail::TestMailer.deliveries.first.body.to_s.
26
- should == File.read("#{ FIXTURES }/inline.html")
27
- end
28
-
29
- it 'should not inline non-html' do
30
- Mail.deliver do
31
- to 'joe@example.com'
32
- from 'joe@example.com'
33
- subject 'Plain text e-mail (with HTML looking content)'
34
- content_type 'text/plain'
35
- body File.read("#{ FIXTURES }/boletin.html")
36
- end
37
-
38
- Mail::TestMailer.deliveries.first.body.to_s.
39
- should == File.read("#{ FIXTURES }/boletin.html")
40
- end
41
-
42
- it 'should inline html part of multipart/alternative' do
43
- Mail.deliver do
44
- to 'joe@example.com'
45
- from 'joe@example.com'
46
- subject 'Multipart/alternative e-mail'
47
- text_part do
48
- body File.read("#{ FIXTURES }/boletin.html")
49
- end
50
- html_part do
51
- content_type 'text/html; charset=UTF-8'
52
- body File.read("#{ FIXTURES }/boletin.html")
53
- end
54
- end
55
-
56
- Mail::TestMailer.deliveries.first.parts[0].body.to_s.
57
- should == File.read("#{ FIXTURES }/boletin.html")
58
-
59
- Mail::TestMailer.deliveries.first.parts[1].body.to_s.
60
- should == File.read("#{ FIXTURES }/inline.html")
61
- end
62
-
63
- end
64
-
@@ -1,60 +0,0 @@
1
- require "spec_helper"
2
- require "middleman-inline-style/rack-middleware"
3
-
4
- describe InlineStyle::Rack::Middleware do
5
- def get_response path, body, opts = {}
6
- content_type = opts.delete(:content_type) || 'text/html'
7
- app = Rack::Builder.new do
8
- use InlineStyle::Rack::Middleware, opts
9
- run lambda { |env| env['DOCUMENT_ROOT'] = FIXTURES; [200, {'Content-Type' => content_type}, [body]] }
10
- end
11
- Nokogiri.HTML Rack::MockRequest.new(app).get(path).body
12
- end
13
-
14
- before do
15
- @html = File.read("#{ FIXTURES }/boletin.html")
16
- end
17
-
18
- it "should inline css" do
19
- get_response('/', @html, :stylesheets_path => FIXTURES).should have_inline_style_for('#A')
20
- end
21
-
22
- it "should use external css" do
23
- get_response('/', @html, :stylesheets_path => FIXTURES).css('#izq').first['style'].should match_style /margin: 30.0px/
24
- end
25
-
26
- describe 'Path inclusion' do
27
- it "should inline style for string path" do
28
- paths = "/some/path"
29
- get_response('/some/path', @html, :stylesheets_path => FIXTURES, :paths => paths).should have_inline_style_for('#A')
30
- end
31
-
32
- it "should not inline style for string path" do
33
- paths = "/some/path"
34
- get_response('/some/other/path', @html, :stylesheets_path => FIXTURES, :paths => paths).should_not have_inline_style_for('#A')
35
- end
36
-
37
- it "should inline style for regexp path" do
38
- paths = %r{/some/.*}
39
- get_response('/some/path', @html, :stylesheets_path => FIXTURES, :paths => paths).should have_inline_style_for('#A')
40
- get_response('/some/other/path', @html, :stylesheets_path => FIXTURES, :paths => paths).should have_inline_style_for('#A')
41
- end
42
-
43
- it "should not inline style for regexp path" do
44
- paths = %r{/some/.*}
45
- get_response('/other/path', @html, :stylesheets_path => FIXTURES, :paths => paths).should_not have_inline_style_for('#A')
46
- end
47
-
48
- it "should inline style for array regexp path" do
49
- paths = [%r{/some/path}, %r{/some/other/path}]
50
- get_response('/some/path', @html, :stylesheets_path => FIXTURES, :paths => paths).should have_inline_style_for('#A')
51
- get_response('/some/other/path', @html, :stylesheets_path => FIXTURES, :paths => paths).should have_inline_style_for('#A')
52
- end
53
-
54
- it "should not inline style for array regexp path" do
55
- paths = [%r{/some/path}, %r{/some/other/path}]
56
- get_response('/path', @html, :stylesheets_path => FIXTURES, :paths => paths).should_not have_inline_style_for('#A')
57
- get_response('/other/path', @html, :stylesheets_path => FIXTURES, :paths => paths).should_not have_inline_style_for('#A')
58
- end
59
- end
60
- end
data/spec/spec_helper.rb DELETED
@@ -1,62 +0,0 @@
1
- require 'rubygems'
2
- require 'rspec'
3
- require 'rack'
4
- require 'rack/mock'
5
-
6
- require "middleman-inline-style"
7
- require "middleman-inline-style/csspool_wrapper"
8
-
9
- gem 'maca-fork-csspool'
10
- require "csspool"
11
-
12
- FIXTURES = "#{File.dirname __FILE__}/fixtures"
13
-
14
- module InlineStyleMatchers
15
- class HaveInlineStyle
16
- def initialize selector
17
- @selector = selector
18
- end
19
-
20
- def matches? html
21
- @html = html
22
- !@html.css(@selector).empty? and @html.css(@selector).inject(true){ |bool, e| bool and !e['style'].nil? }
23
- end
24
-
25
- def failure_message
26
- "expected elements with selector #{@selector} style attribute not to be nil"
27
- end
28
-
29
- def negative_failure_message
30
- "expected elements with selector #{@selector} style attribute to be nil"
31
- end
32
- end
33
-
34
- class MatchStyle
35
- def initialize style
36
- @style = style
37
- end
38
-
39
- def matches? actual
40
- @actual = actual.gsub(/([^\.0-9]\d+)(px|;|%|\s)/, '\1.0\2')
41
- @actual =~ @style
42
- end
43
-
44
- def failure_message
45
- "expected #{@actual} to match #{@style}"
46
- end
47
-
48
- def negative_failure_message
49
- "expected #{@actual} not to match #{@style}"
50
- end
51
- end
52
-
53
- def have_inline_style_for selector
54
- HaveInlineStyle.new selector
55
- end
56
-
57
- def match_style style
58
- MatchStyle.new style
59
- end
60
- end
61
-
62
- RSpec.configure { |config| config.include InlineStyleMatchers }