roadie 3.0.0.pre1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -0
  3. data/Changelog.md +22 -1
  4. data/Gemfile +0 -4
  5. data/Guardfile +3 -2
  6. data/README.md +6 -4
  7. data/lib/roadie.rb +3 -1
  8. data/lib/roadie/filesystem_provider.rb +13 -2
  9. data/lib/roadie/inliner.rb +10 -8
  10. data/lib/roadie/markup_improver.rb +1 -1
  11. data/lib/roadie/provider_list.rb +5 -1
  12. data/lib/roadie/rspec/asset_provider.rb +9 -9
  13. data/lib/roadie/selector.rb +1 -0
  14. data/lib/roadie/style_attribute_builder.rb +25 -0
  15. data/lib/roadie/style_block.rb +0 -1
  16. data/lib/roadie/upgrade_guide.rb +36 -0
  17. data/lib/roadie/version.rb +1 -1
  18. data/roadie.gemspec +2 -1
  19. data/spec/integration_spec.rb +15 -15
  20. data/spec/lib/roadie/asset_scanner_spec.rb +27 -27
  21. data/spec/lib/roadie/css_not_found_spec.rb +4 -3
  22. data/spec/lib/roadie/document_spec.rb +19 -19
  23. data/spec/lib/roadie/filesystem_provider_spec.rb +29 -6
  24. data/spec/lib/roadie/inliner_spec.rb +18 -18
  25. data/spec/lib/roadie/markup_improver_spec.rb +17 -17
  26. data/spec/lib/roadie/null_provider_spec.rb +4 -4
  27. data/spec/lib/roadie/provider_list_spec.rb +23 -15
  28. data/spec/lib/roadie/selector_spec.rb +16 -13
  29. data/spec/lib/roadie/style_attribute_builder_spec.rb +29 -0
  30. data/spec/lib/roadie/style_block_spec.rb +6 -6
  31. data/spec/lib/roadie/style_property_spec.rb +22 -22
  32. data/spec/lib/roadie/stylesheet_spec.rb +8 -8
  33. data/spec/lib/roadie/test_provider_spec.rb +5 -5
  34. data/spec/lib/roadie/url_generator_spec.rb +21 -20
  35. data/spec/lib/roadie/url_rewriter_spec.rb +7 -7
  36. data/spec/shared_examples/asset_provider.rb +4 -4
  37. data/spec/shared_examples/url_rewriter.rb +6 -6
  38. data/spec/spec_helper.rb +2 -1
  39. data/spec/support/have_attribute_matcher.rb +2 -2
  40. data/spec/support/have_node_matcher.rb +2 -2
  41. data/spec/support/have_selector_matcher.rb +2 -2
  42. data/spec/support/have_styling_matcher.rb +7 -5
  43. metadata +36 -21
  44. data/lib/roadie/style_properties.rb +0 -29
  45. data/spec/lib/roadie/style_properties_spec.rb +0 -61
@@ -12,7 +12,7 @@ module Roadie
12
12
  def dom_document(html); Nokogiri::HTML.parse html; end
13
13
 
14
14
  it "rewrites all a[href]" do
15
- generator.should_receive(:generate_url).with("some/path").and_return "http://foo.com/"
15
+ expect(generator).to receive(:generate_url).with("some/path").and_return "http://foo.com/"
16
16
  dom = dom_document <<-HTML
17
17
  <body>
18
18
  <a href="some/path">Some path</a>
@@ -25,7 +25,7 @@ module Roadie
25
25
  end
26
26
 
27
27
  it "rewrites relative img[src]" do
28
- generator.should_receive(:generate_url).with("some/path.jpg").and_return "http://foo.com/image.jpg"
28
+ expect(generator).to receive(:generate_url).with("some/path.jpg").and_return "http://foo.com/image.jpg"
29
29
  dom = dom_document <<-HTML
30
30
  <body>
31
31
  <img src="some/path.jpg">
@@ -38,7 +38,7 @@ module Roadie
38
38
  end
39
39
 
40
40
  it "rewrites url() directives inside style attributes" do
41
- generator.should_receive(:generate_url).with("some/path.jpg").and_return "http://foo.com/image.jpg"
41
+ expect(generator).to receive(:generate_url).with("some/path.jpg").and_return "http://foo.com/image.jpg"
42
42
  dom = dom_document <<-HTML
43
43
  <body>
44
44
  <div style="background-image: url(&quot;some/path.jpg&quot;);">
@@ -53,7 +53,7 @@ module Roadie
53
53
 
54
54
  describe "transforming css" do
55
55
  it "rewrites all url() directives" do
56
- generator.should_receive(:generate_url).with("some/path.jpg").and_return "http://foo.com/image.jpg"
56
+ expect(generator).to receive(:generate_url).with("some/path.jpg").and_return "http://foo.com/image.jpg"
57
57
  css = "body { background: top url(some/path.jpg) #eee; }"
58
58
  expect {
59
59
  rewriter.transform_css css
@@ -61,17 +61,17 @@ module Roadie
61
61
  end
62
62
 
63
63
  it "correctly identifies URLs with single quotes" do
64
- generator.should_receive(:generate_url).with("images/foo.png").and_return "x"
64
+ expect(generator).to receive(:generate_url).with("images/foo.png").and_return "x"
65
65
  rewriter.transform_css "url('images/foo.png')"
66
66
  end
67
67
 
68
68
  it "correctly identifies URLs with double quotes" do
69
- generator.should_receive(:generate_url).with("images/foo.png").and_return "x"
69
+ expect(generator).to receive(:generate_url).with("images/foo.png").and_return "x"
70
70
  rewriter.transform_css 'url("images/foo.png")'
71
71
  end
72
72
 
73
73
  it "correctly identifies URLs with parenthesis inside them" do
74
- generator.should_receive(:generate_url).with("images/map_(large_(extra)).png").and_return "x"
74
+ expect(generator).to receive(:generate_url).with("images/map_(large_(extra)).png").and_return "x"
75
75
  rewriter.transform_css 'url(images/map_(large_(extra)).png)'
76
76
  end
77
77
  end
@@ -1,11 +1,11 @@
1
1
  shared_examples_for "asset provider role" do
2
2
  it "responds to #find_stylesheet" do
3
- subject.should respond_to(:find_stylesheet)
4
- subject.method(:find_stylesheet).arity.should == 1
3
+ expect(subject).to respond_to(:find_stylesheet)
4
+ expect(subject.method(:find_stylesheet).arity).to eq(1)
5
5
  end
6
6
 
7
7
  it "responds to #find_stylesheet!" do
8
- subject.should respond_to(:find_stylesheet!)
9
- subject.method(:find_stylesheet!).arity.should == 1
8
+ expect(subject).to respond_to(:find_stylesheet!)
9
+ expect(subject.method(:find_stylesheet!).arity).to eq(1)
10
10
  end
11
11
  end
@@ -7,17 +7,17 @@ shared_examples_for "url rewriter" do
7
7
  end
8
8
 
9
9
  it "has a #transform_dom(dom) method that returns nil" do
10
- subject.should respond_to(:transform_dom)
11
- subject.method(:transform_dom).arity.should == 1
10
+ expect(subject).to respond_to(:transform_dom)
11
+ expect(subject.method(:transform_dom).arity).to eq(1)
12
12
 
13
13
  dom = Nokogiri::HTML.parse "<body></body>"
14
- subject.transform_dom(dom).should be_nil
14
+ expect(subject.transform_dom(dom)).to be_nil
15
15
  end
16
16
 
17
17
  it "has a #transform_css(css) method that returns nil" do
18
- subject.should respond_to(:transform_css)
19
- subject.method(:transform_css).arity.should == 1
18
+ expect(subject).to respond_to(:transform_css)
19
+ expect(subject.method(:transform_css).arity).to eq(1)
20
20
 
21
- subject.transform_css("").should be_nil
21
+ expect(subject.transform_css("")).to be_nil
22
22
  end
23
23
  end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'rspec/collection_matchers'
2
+
1
3
  if ENV['CI']
2
4
  require 'coveralls'
3
5
  Coveralls.wear!
@@ -7,7 +9,6 @@ $: << File.dirname(__FILE__) + '/../lib'
7
9
  require 'roadie'
8
10
 
9
11
  RSpec.configure do |config|
10
- config.treat_symbols_as_metadata_keys_with_true_values = true
11
12
  config.run_all_when_everything_filtered = true
12
13
  end
13
14
 
@@ -11,11 +11,11 @@ RSpec::Matchers.define :have_attribute do |attribute|
11
11
  end
12
12
 
13
13
  description { "have attribute #{attribute.inspect} at selector #{@selector.inspect}" }
14
- failure_message_for_should do |document|
14
+ failure_message do |document|
15
15
  name, expected = attribute.first
16
16
  "expected #{name} attribute at #{@selector.inspect} to be #{expected.inspect} but was #{attribute(document, name).inspect}"
17
17
  end
18
- failure_message_for_should_not do |document|
18
+ failure_message_when_negated do |document|
19
19
  name, expected = attribute.first
20
20
  "expected #{name} attribute at #{@selector.inspect} to not be #{expected.inspect}"
21
21
  end
@@ -9,8 +9,8 @@ RSpec::Matchers.define :have_node do |selector|
9
9
  end
10
10
  end
11
11
 
12
- failure_message_for_should { "expected document to #{name_to_sentence}#{expected_to_sentence}"}
13
- failure_message_for_should_not { "expected document to not #{name_to_sentence}#{expected_to_sentence}"}
12
+ failure_message { "expected document to #{name_to_sentence}#{expected_to_sentence}"}
13
+ failure_message_when_negated { "expected document to not #{name_to_sentence}#{expected_to_sentence}"}
14
14
 
15
15
  def match_attributes(node_attributes)
16
16
  attributes = Hash[node_attributes.map { |name, attribute| [name, attribute.value] }]
@@ -1,6 +1,6 @@
1
1
  RSpec::Matchers.define :have_selector do |selector|
2
2
  match { |document| !document.css(selector).empty? }
3
- failure_message_for_should { "expected document to #{name_to_sentence}#{expected_to_sentence}"}
4
- failure_message_for_should_not { "expected document to not #{name_to_sentence}#{expected_to_sentence}"}
3
+ failure_message { "expected document to #{name_to_sentence}#{to_sentence selector}"}
4
+ failure_message_when_negated { "expected document to not #{name_to_sentence}#{to_sentence selector}"}
5
5
  end
6
6
 
@@ -1,24 +1,26 @@
1
1
  RSpec::Matchers.define :have_styling do |rules|
2
- @selector = 'body > *:first'
3
2
  normalized_rules = StylingExpectation.new(rules)
4
3
 
5
4
  chain(:at_selector) { |selector| @selector = selector }
6
- match { |document| normalized_rules == styles_at_selector(document) }
5
+ match { |document|
6
+ @selector ||= 'body > *:first'
7
+ normalized_rules == styles_at_selector(document)
8
+ }
7
9
 
8
10
  description {
9
11
  "have styles #{normalized_rules.inspect} at selector #{@selector.inspect}"
10
12
  }
11
13
 
12
- failure_message_for_should { |document|
14
+ failure_message { |document|
13
15
  "expected styles at #{@selector.inspect} to be:\n#{normalized_rules}\nbut was:\n#{styles_at_selector(document)}"
14
16
  }
15
17
 
16
- failure_message_for_should_not {
18
+ failure_message_when_negated {
17
19
  "expected styles at #{@selector.inspect} to not be:\n#{normalized_rules}"
18
20
  }
19
21
 
20
22
  def styles_at_selector(document)
21
- document.should have_selector(@selector)
23
+ expect(document).to have_selector(@selector)
22
24
  StylingExpectation.new document.at_css(@selector)['style']
23
25
  end
24
26
  end
metadata CHANGED
@@ -1,57 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roadie
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.pre1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Magnus Bergmark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-04 00:00:00.000000000 Z
11
+ date: 2014-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.6.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.6.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: css_parser
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.3.4
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.3.4
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '3.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-collection_matchers
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
55
69
  description: Roadie tries to make sending HTML emails a little less painful by inlining
56
70
  stylesheets and rewriting relative URLs for you.
57
71
  email:
@@ -62,10 +76,10 @@ extra_rdoc_files:
62
76
  - README.md
63
77
  - Changelog.md
64
78
  files:
65
- - .autotest
66
- - .gitignore
67
- - .travis.yml
68
- - .yardopts
79
+ - ".autotest"
80
+ - ".gitignore"
81
+ - ".travis.yml"
82
+ - ".yardopts"
69
83
  - Changelog.md
70
84
  - Gemfile
71
85
  - Guardfile
@@ -87,10 +101,11 @@ files:
87
101
  - lib/roadie/rspec.rb
88
102
  - lib/roadie/rspec/asset_provider.rb
89
103
  - lib/roadie/selector.rb
104
+ - lib/roadie/style_attribute_builder.rb
90
105
  - lib/roadie/style_block.rb
91
- - lib/roadie/style_properties.rb
92
106
  - lib/roadie/style_property.rb
93
107
  - lib/roadie/stylesheet.rb
108
+ - lib/roadie/upgrade_guide.rb
94
109
  - lib/roadie/url_generator.rb
95
110
  - lib/roadie/url_rewriter.rb
96
111
  - lib/roadie/version.rb
@@ -108,8 +123,8 @@ files:
108
123
  - spec/lib/roadie/null_url_rewriter_spec.rb
109
124
  - spec/lib/roadie/provider_list_spec.rb
110
125
  - spec/lib/roadie/selector_spec.rb
126
+ - spec/lib/roadie/style_attribute_builder_spec.rb
111
127
  - spec/lib/roadie/style_block_spec.rb
112
- - spec/lib/roadie/style_properties_spec.rb
113
128
  - spec/lib/roadie/style_property_spec.rb
114
129
  - spec/lib/roadie/stylesheet_spec.rb
115
130
  - spec/lib/roadie/test_provider_spec.rb
@@ -133,17 +148,17 @@ require_paths:
133
148
  - lib
134
149
  required_ruby_version: !ruby/object:Gem::Requirement
135
150
  requirements:
136
- - - '>='
151
+ - - ">="
137
152
  - !ruby/object:Gem::Version
138
153
  version: '1.9'
139
154
  required_rubygems_version: !ruby/object:Gem::Requirement
140
155
  requirements:
141
- - - '>'
156
+ - - ">="
142
157
  - !ruby/object:Gem::Version
143
- version: 1.3.1
158
+ version: '0'
144
159
  requirements: []
145
160
  rubyforge_project:
146
- rubygems_version: 2.0.6
161
+ rubygems_version: 2.2.2
147
162
  signing_key:
148
163
  specification_version: 4
149
164
  summary: Making HTML emails comfortable for the Ruby rockstars
@@ -161,8 +176,8 @@ test_files:
161
176
  - spec/lib/roadie/null_url_rewriter_spec.rb
162
177
  - spec/lib/roadie/provider_list_spec.rb
163
178
  - spec/lib/roadie/selector_spec.rb
179
+ - spec/lib/roadie/style_attribute_builder_spec.rb
164
180
  - spec/lib/roadie/style_block_spec.rb
165
- - spec/lib/roadie/style_properties_spec.rb
166
181
  - spec/lib/roadie/style_property_spec.rb
167
182
  - spec/lib/roadie/stylesheet_spec.rb
168
183
  - spec/lib/roadie/test_provider_spec.rb
@@ -1,29 +0,0 @@
1
- module Roadie
2
- # @api private
3
- # Stores orphan style properties as they are being merged into specific
4
- # element's "style" attribute.
5
- class StyleProperties
6
- attr_reader :properties
7
-
8
- def initialize(properties)
9
- @properties = properties
10
- end
11
-
12
- def merge(new_properties)
13
- StyleProperties.new(properties + properties_of(new_properties))
14
- end
15
-
16
- def merge!(new_properties)
17
- @properties += properties_of(new_properties)
18
- end
19
-
20
- def to_s
21
- @properties.sort.map(&:to_s).join(";")
22
- end
23
-
24
- private
25
- def properties_of(object)
26
- object.respond_to?(:properties) ? object.properties : object
27
- end
28
- end
29
- end
@@ -1,61 +0,0 @@
1
- # encoding: UTF-8
2
- require 'spec_helper'
3
-
4
- module Roadie
5
- describe StyleProperties do
6
- it "has a list of properties" do
7
- property = StyleProperty.new("color", "green", false, 1)
8
- StyleProperties.new([property]).properties.should == [property]
9
- end
10
-
11
- it "can be merged with other properties" do
12
- old = StyleProperty.new("color", "red", false, 1)
13
- new = StyleProperty.new("color", "green", false, 5)
14
- instance = StyleProperties.new([old])
15
-
16
- instance.merge(StyleProperties.new([new])).properties.should == [old, new]
17
- instance.merge([new]).properties.should == [old, new]
18
-
19
- # Original is not mutated
20
- instance.properties.should == [old]
21
- end
22
-
23
- it "can be destructively merged with other properties" do
24
- old = StyleProperty.new("color", "red", false, 1)
25
- new = StyleProperty.new("color", "green", false, 5)
26
- instance = StyleProperties.new([old])
27
-
28
- instance.merge!([new])
29
- instance.properties.should == [old, new]
30
- end
31
-
32
- describe "string representation" do
33
- class MockProperty
34
- attr_reader :sort_value
35
- include Comparable
36
-
37
- def initialize(name, sort_value = 0)
38
- @name, @sort_value = name, sort_value
39
- end
40
-
41
- def <=>(other) @sort_value <=> other.sort_value end
42
- def to_s() @name.to_s end
43
- end
44
-
45
- it "joins properties together with semicolons" do
46
- property = MockProperty.new("foo:bar")
47
- StyleProperties.new([property, property]).to_s.should == "foo:bar;foo:bar"
48
- end
49
-
50
- it "sorts properties" do
51
- important = MockProperty.new("super important", 100)
52
- insignificant = MockProperty.new("insignificant", 2)
53
- common = MockProperty.new("common", 20)
54
-
55
- StyleProperties.new(
56
- [important, insignificant, common]
57
- ).to_s.should == "insignificant;common;super important"
58
- end
59
- end
60
- end
61
- end