This repository was archived by the owner on Dec 16, 2021. It is now read-only.
forked from premailer/premailer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelper.rb
58 lines (48 loc) · 1.56 KB
/
helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# encoding: utf-8
$:.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
$:.unshift(File.expand_path(File.dirname(__FILE__) + '/../'))
require 'rubygems'
require 'test/unit'
require 'webmock/test_unit'
require 'premailer'
class Premailer::TestCase < Test::Unit::TestCase
BASE_URI = 'http://premailer.dev/'
BASE_PATH = File.expand_path(File.dirname(__FILE__)) + '/files'
def setup
stub_request(:any, /premailer\.dev\/*/).to_return do |request|
file_path = BASE_PATH + URI.parse(request.uri).path
if File.exists?(file_path)
{ :status => 200, :body => File.open(file_path) }
else
{ :status => 404, :body => "#{file_path} not found" }
end
end
stub_request(:get, /my\.example\.com\:8080\/*/).to_return(:status => 200, :body => "", :headers => {})
end
def default_test; end
protected
def local_setup(f = 'base.html', opts = {})
base_file = BASE_PATH + '/' + f
premailer = Premailer.new(base_file, opts)
premailer.to_inline_css
@doc = premailer.processed_doc
end
def remote_setup(f = 'base.html', opts = {})
@premailer = Premailer.new(BASE_URI + "#{f}", opts)
@premailer.to_inline_css
@doc = @premailer.processed_doc
end
def adapters
jruby? ? [:nokogiri] : [:nokogiri, :hpricot]
end
def jruby?
RUBY_PLATFORM == 'java'
end
def special_chars_nokogiri
if jruby?
'cédille cé & garçon garçon à à & ©'
else
'cédille cé & garçon garçon à à & ©'
end
end
end