roadie 2.3.3 → 2.3.4

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.
@@ -2,7 +2,19 @@
2
2
 
3
3
  [full changelog](https://github.com/Mange/roadie/compare/v2.3.3...master)
4
4
 
5
- * No changes yet.
5
+ * Nothing yet
6
+
7
+ ### 2.3.4
8
+
9
+ [full changelog](https://github.com/Mange/roadie/compare/v2.3.3...v2.3.4)
10
+
11
+ * Enhancements:
12
+ * Add `config.roadie.enabled` that can be set to `false` to disable Roadie completely.
13
+ * Bug fixes:
14
+ * Proc objects to the `:css` option is now run in the context of the mailer instance, mirroring similar options from ActionMailer.
15
+ * Fix some tests that would always pass
16
+ * Improve JRuby compatibility
17
+ * Update Gemfile.lock and fix issues with newer gem versions
6
18
 
7
19
  ### 2.3.3
8
20
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- roadie (2.3.3)
4
+ roadie (2.3.4)
5
5
  actionmailer (> 3.0.0, < 3.3.0)
6
6
  css_parser
7
7
  nokogiri (>= 1.4.4)
@@ -11,12 +11,12 @@ GEM
11
11
  remote: http://rubygems.org/
12
12
  specs:
13
13
  abstract (1.0.0)
14
- actionmailer (3.0.12)
15
- actionpack (= 3.0.12)
14
+ actionmailer (3.0.17)
15
+ actionpack (= 3.0.17)
16
16
  mail (~> 2.2.19)
17
- actionpack (3.0.12)
18
- activemodel (= 3.0.12)
19
- activesupport (= 3.0.12)
17
+ actionpack (3.0.17)
18
+ activemodel (= 3.0.17)
19
+ activesupport (= 3.0.17)
20
20
  builder (~> 2.1.2)
21
21
  erubis (~> 2.6.6)
22
22
  i18n (~> 0.5.0)
@@ -24,99 +24,118 @@ GEM
24
24
  rack-mount (~> 0.6.14)
25
25
  rack-test (~> 0.5.7)
26
26
  tzinfo (~> 0.3.23)
27
- activemodel (3.0.12)
28
- activesupport (= 3.0.12)
27
+ activemodel (3.0.17)
28
+ activesupport (= 3.0.17)
29
29
  builder (~> 2.1.2)
30
30
  i18n (~> 0.5.0)
31
- activerecord (3.0.12)
32
- activemodel (= 3.0.12)
33
- activesupport (= 3.0.12)
31
+ activerecord (3.0.17)
32
+ activemodel (= 3.0.17)
33
+ activesupport (= 3.0.17)
34
34
  arel (~> 2.0.10)
35
35
  tzinfo (~> 0.3.23)
36
- activeresource (3.0.12)
37
- activemodel (= 3.0.12)
38
- activesupport (= 3.0.12)
39
- activesupport (3.0.12)
36
+ activeresource (3.0.17)
37
+ activemodel (= 3.0.17)
38
+ activesupport (= 3.0.17)
39
+ activesupport (3.0.17)
40
40
  addressable (2.3.2)
41
- appraisal (0.4.1)
41
+ appraisal (0.5.0)
42
42
  bundler
43
43
  rake
44
44
  arel (2.0.10)
45
45
  builder (2.1.2)
46
+ coderay (1.0.8)
46
47
  css_parser (1.2.6)
47
48
  addressable
48
49
  rdoc
49
50
  diff-lcs (1.1.3)
50
51
  erubis (2.6.6)
51
52
  abstract (>= 1.0.0)
52
- ffi (1.0.11)
53
53
  growl (1.0.3)
54
- guard (1.0.1)
55
- ffi (>= 0.5.0)
56
- thor (~> 0.14.6)
57
- guard-rspec (0.6.0)
58
- guard (>= 0.10.0)
54
+ guard (1.5.3)
55
+ listen (>= 0.4.2)
56
+ lumberjack (>= 1.0.2)
57
+ pry (>= 0.9.10)
58
+ thor (>= 0.14.6)
59
+ guard-rspec (2.1.1)
60
+ guard (>= 1.1)
61
+ rspec (~> 2.11)
59
62
  hike (1.2.1)
60
63
  i18n (0.5.0)
61
- json (1.6.5)
64
+ json (1.7.5)
65
+ json (1.7.5-java)
66
+ listen (0.5.3)
67
+ lumberjack (1.0.2)
62
68
  mail (2.2.19)
63
69
  activesupport (>= 2.3.6)
64
70
  i18n (>= 0.4.0)
65
71
  mime-types (~> 1.16)
66
72
  treetop (~> 1.4.8)
67
- mime-types (1.18)
68
- multi_json (1.3.6)
73
+ method_source (0.8.1)
74
+ mime-types (1.19)
75
+ multi_json (1.3.7)
69
76
  nokogiri (1.5.5)
70
77
  polyglot (0.3.3)
78
+ pry (0.9.10)
79
+ coderay (~> 1.0.5)
80
+ method_source (~> 0.8)
81
+ slop (~> 3.3.1)
82
+ pry (0.9.10-java)
83
+ coderay (~> 1.0.5)
84
+ method_source (~> 0.8)
85
+ slop (~> 3.3.1)
86
+ spoon (~> 0.0)
71
87
  rack (1.2.5)
72
88
  rack-mount (0.6.14)
73
89
  rack (>= 1.0.0)
74
90
  rack-test (0.5.7)
75
91
  rack (>= 1.0)
76
- rails (3.0.12)
77
- actionmailer (= 3.0.12)
78
- actionpack (= 3.0.12)
79
- activerecord (= 3.0.12)
80
- activeresource (= 3.0.12)
81
- activesupport (= 3.0.12)
92
+ rails (3.0.17)
93
+ actionmailer (= 3.0.17)
94
+ actionpack (= 3.0.17)
95
+ activerecord (= 3.0.17)
96
+ activeresource (= 3.0.17)
97
+ activesupport (= 3.0.17)
82
98
  bundler (~> 1.0)
83
- railties (= 3.0.12)
84
- railties (3.0.12)
85
- actionpack (= 3.0.12)
86
- activesupport (= 3.0.12)
99
+ railties (= 3.0.17)
100
+ railties (3.0.17)
101
+ actionpack (= 3.0.17)
102
+ activesupport (= 3.0.17)
87
103
  rake (>= 0.8.7)
88
104
  rdoc (~> 3.4)
89
105
  thor (~> 0.14.4)
90
106
  rake (0.9.2.2)
91
- rb-fsevent (0.9.0)
107
+ rb-fsevent (0.9.2)
92
108
  rdoc (3.12)
93
109
  json (~> 1.4)
94
- rspec (2.9.0)
95
- rspec-core (~> 2.9.0)
96
- rspec-expectations (~> 2.9.0)
97
- rspec-mocks (~> 2.9.0)
98
- rspec-core (2.9.0)
99
- rspec-expectations (2.9.0)
110
+ rspec (2.11.0)
111
+ rspec-core (~> 2.11.0)
112
+ rspec-expectations (~> 2.11.0)
113
+ rspec-mocks (~> 2.11.0)
114
+ rspec-core (2.11.1)
115
+ rspec-expectations (2.11.3)
100
116
  diff-lcs (~> 1.1.3)
101
- rspec-mocks (2.9.0)
102
- rspec-rails (2.9.0)
117
+ rspec-mocks (2.11.3)
118
+ rspec-rails (2.11.4)
103
119
  actionpack (>= 3.0)
104
120
  activesupport (>= 3.0)
105
121
  railties (>= 3.0)
106
- rspec (~> 2.9.0)
107
- sprockets (2.3.1)
122
+ rspec (~> 2.11.0)
123
+ slop (3.3.3)
124
+ spoon (0.0.1)
125
+ sprockets (2.8.1)
108
126
  hike (~> 1.2)
109
127
  multi_json (~> 1.0)
110
128
  rack (~> 1.0)
111
129
  tilt (~> 1.1, != 1.3.0)
112
130
  thor (0.14.6)
113
131
  tilt (1.3.3)
114
- treetop (1.4.10)
132
+ treetop (1.4.12)
115
133
  polyglot
116
134
  polyglot (>= 0.3.1)
117
- tzinfo (0.3.32)
135
+ tzinfo (0.3.35)
118
136
 
119
137
  PLATFORMS
138
+ java
120
139
  ruby
121
140
 
122
141
  DEPENDENCIES
data/Guardfile CHANGED
@@ -1,6 +1,8 @@
1
- guard 'rspec', :version => 2, :rvm => ['1.8.7', '1.9.2'] do
1
+ guard 'rspec', :rvm => ['1.9.3', 'jruby-head', 'ruby-1.8.7-p358'] do
2
2
  watch(%r{^spec/.+_spec\.rb$})
3
3
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
- watch('spec/spec_helper.rb') { "spec" }
4
+
5
+ watch(%r{spec/support/.*\.rb}) { "spec" }
6
+ watch('spec/spec_helper.rb') { "spec" }
5
7
  end
6
8
 
data/README.md CHANGED
@@ -70,8 +70,9 @@ Configuring
70
70
 
71
71
  Roadie listens to the following options (set in `Application.rb` or in your environment's configuration files:
72
72
 
73
- * `config.action_mailer.default_url_options` - Used for making URLs absolute
74
- * `config.assets.enabled` - If the asset pipeline is turned off, Roadie will default to searching for assets in `public/stylesheets`
73
+ * `config.roadie.enabled` - Set this to `false` to disable Roadie from working on your emails. Useful if you want to disable Roadie in some environments.
74
+ * `config.action_mailer.default_url_options` - Used for making URLs absolute.
75
+ * `config.assets.enabled` - If the asset pipeline is turned off, Roadie will default to searching for assets in `public/stylesheets`.
75
76
  * `config.roadie.provider` - Set the provider manually, ignoring all other options. Use for advanced cases, or when you have non-default paths or other options.
76
77
 
77
78
  Usage
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mange/Projects/roadie
3
3
  specs:
4
- roadie (2.3.2)
4
+ roadie (2.3.3)
5
5
  actionmailer (> 3.0.0, < 3.3.0)
6
6
  css_parser
7
7
  nokogiri (>= 1.4.4)
@@ -37,7 +37,7 @@ GEM
37
37
  activemodel (= 3.0.12)
38
38
  activesupport (= 3.0.12)
39
39
  activesupport (3.0.12)
40
- addressable (2.2.7)
40
+ addressable (2.3.2)
41
41
  appraisal (0.4.1)
42
42
  bundler
43
43
  rake
@@ -52,14 +52,16 @@ GEM
52
52
  hike (1.2.1)
53
53
  i18n (0.5.0)
54
54
  json (1.6.5)
55
+ json (1.6.5-java)
55
56
  mail (2.2.19)
56
57
  activesupport (>= 2.3.6)
57
58
  i18n (>= 0.4.0)
58
59
  mime-types (~> 1.16)
59
60
  treetop (~> 1.4.8)
60
61
  mime-types (1.18)
61
- multi_json (1.1.0)
62
- nokogiri (1.5.2)
62
+ multi_json (1.3.7)
63
+ nokogiri (1.5.5)
64
+ nokogiri (1.5.5-java)
63
65
  polyglot (0.3.3)
64
66
  rack (1.2.5)
65
67
  rack-mount (0.6.14)
@@ -109,6 +111,7 @@ GEM
109
111
  tzinfo (0.3.32)
110
112
 
111
113
  PLATFORMS
114
+ java
112
115
  ruby
113
116
 
114
117
  DEPENDENCIES
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mange/Projects/roadie
3
3
  specs:
4
- roadie (2.3.2)
4
+ roadie (2.3.3)
5
5
  actionmailer (> 3.0.0, < 3.3.0)
6
6
  css_parser
7
7
  nokogiri (>= 1.4.4)
@@ -38,7 +38,7 @@ GEM
38
38
  activesupport (= 3.1.4)
39
39
  activesupport (3.1.4)
40
40
  multi_json (~> 1.0)
41
- addressable (2.2.8)
41
+ addressable (2.3.2)
42
42
  appraisal (0.4.1)
43
43
  bundler
44
44
  rake
@@ -52,6 +52,7 @@ GEM
52
52
  hike (1.2.1)
53
53
  i18n (0.6.0)
54
54
  json (1.6.5)
55
+ json (1.6.5-java)
55
56
  mail (2.3.3)
56
57
  i18n (>= 0.4.0)
57
58
  mime-types (~> 1.16)
@@ -59,6 +60,7 @@ GEM
59
60
  mime-types (1.18)
60
61
  multi_json (1.1.0)
61
62
  nokogiri (1.5.5)
63
+ nokogiri (1.5.5-java)
62
64
  polyglot (0.3.3)
63
65
  rack (1.3.6)
64
66
  rack-cache (1.2)
@@ -112,6 +114,7 @@ GEM
112
114
  tzinfo (0.3.32)
113
115
 
114
116
  PLATFORMS
117
+ java
115
118
  ruby
116
119
 
117
120
  DEPENDENCIES
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mange/Projects/roadie
3
3
  specs:
4
- roadie (2.3.2)
4
+ roadie (2.3.3)
5
5
  actionmailer (> 3.0.0, < 3.3.0)
6
6
  css_parser
7
7
  nokogiri (>= 1.4.4)
@@ -37,7 +37,7 @@ GEM
37
37
  activesupport (3.2.2)
38
38
  i18n (~> 0.6)
39
39
  multi_json (~> 1.0)
40
- addressable (2.2.8)
40
+ addressable (2.3.2)
41
41
  appraisal (0.4.1)
42
42
  bundler
43
43
  rake
@@ -52,6 +52,7 @@ GEM
52
52
  i18n (0.6.0)
53
53
  journey (1.0.3)
54
54
  json (1.6.5)
55
+ json (1.6.5-java)
55
56
  mail (2.4.4)
56
57
  i18n (>= 0.4.0)
57
58
  mime-types (~> 1.16)
@@ -59,6 +60,7 @@ GEM
59
60
  mime-types (1.18)
60
61
  multi_json (1.1.0)
61
62
  nokogiri (1.5.5)
63
+ nokogiri (1.5.5-java)
62
64
  polyglot (0.3.3)
63
65
  rack (1.4.1)
64
66
  rack-cache (1.2)
@@ -110,6 +112,7 @@ GEM
110
112
  tzinfo (0.3.32)
111
113
 
112
114
  PLATFORMS
115
+ java
113
116
  ruby
114
117
 
115
118
  DEPENDENCIES
@@ -16,6 +16,15 @@ module Roadie
16
16
  [AssetPipelineProvider, FilesystemProvider]
17
17
  end
18
18
 
19
+ # Returns the value of +config.roadie.enabled+.
20
+ #
21
+ # Roadie will disable all processing if this config is set to +false+. If
22
+ # you just want to disable CSS inlining without disabling the rest of
23
+ # Roadie, pass +css: nil+ to the +defaults+ method inside your mailers.
24
+ def enabled?
25
+ config.roadie.enabled
26
+ end
27
+
19
28
  # Returns the active provider
20
29
  #
21
30
  # If no provider has been configured a new provider will be instantiated
@@ -29,7 +29,11 @@ module Roadie
29
29
 
30
30
  def collect_responses_and_parts_order_with_inline_styles(headers, &block)
31
31
  responses, order = collect_responses_and_parts_order_without_inline_styles(headers, &block)
32
- [responses.map { |response| inline_style_response(response) }, order]
32
+ if Roadie.enabled?
33
+ [responses.map { |response| inline_style_response(response) }, order]
34
+ else
35
+ [responses, order]
36
+ end
33
37
  end
34
38
 
35
39
  private
@@ -50,7 +54,9 @@ module Roadie
50
54
  end
51
55
 
52
56
  def resolve_target(target)
53
- if target.respond_to? :call
57
+ if target.respond_to? :bind
58
+ target.bind(self).call
59
+ elsif target.respond_to? :call
54
60
  target.call
55
61
  else
56
62
  target
@@ -11,7 +11,9 @@ module Roadie
11
11
  # inside the parenthesis. There's much room for improvement, of course.
12
12
  CSS_URL_REGEXP = %r{
13
13
  url\(
14
- (["']?)
14
+ (
15
+ (?:["']|%22)? # Optional opening quote
16
+ )
15
17
  (
16
18
  [^(]* # Text leading up to before opening parens
17
19
  (?:\([^)]*\))* # Texts containing parens pairs
@@ -4,16 +4,21 @@ require 'roadie/action_mailer_extensions'
4
4
 
5
5
  module Roadie
6
6
  # {Roadie::Railtie} registers {Roadie} with the current Rails application
7
- # It adds another configuration option:
7
+ # It adds configuration options:
8
+ #
9
+ # config.roadie.enabled = true
10
+ # Set this to false to disable Roadie completely. This could be useful if
11
+ # you don't want Roadie in certain environments.
8
12
  #
9
13
  # config.roadie.provider = nil
14
+ # You can use this to set a provider yourself. See {Roadie::AssetProvider}.
10
15
  #
11
- # You can use this to set a provider yourself.
12
16
  #
13
17
  # @see Roadie
14
18
  # @see AssetProvider
15
19
  class Railtie < Rails::Railtie
16
20
  config.roadie = ActiveSupport::OrderedOptions.new
21
+ config.roadie.enabled = true
17
22
  config.roadie.provider = nil
18
23
 
19
24
  initializer "roadie.extend_action_mailer" do
@@ -1,3 +1,3 @@
1
1
  module Roadie
2
- VERSION = '2.3.3'
2
+ VERSION = '2.3.4'
3
3
  end
@@ -25,6 +25,10 @@ module Roadie
25
25
  end
26
26
  end
27
27
 
28
+ def parse_html_in_email(mail)
29
+ Nokogiri::HTML.parse mail.html_part.body.decoded
30
+ end
31
+
28
32
  before(:each) do
29
33
  change_default_url_options(:host => 'example.app.org')
30
34
  mailer.delivery_method = :test
@@ -37,17 +41,16 @@ module Roadie
37
41
  email.from.should == ['john@example.com']
38
42
  email.should have(2).parts
39
43
 
40
- email.parts.find { |part| part.mime_type == 'text/html' }.tap do |html_part|
41
- document = Nokogiri::HTML.parse(html_part.body.decoded)
42
- document.should have_selector('html > head + body')
43
- document.should have_selector('body #message h1')
44
- document.should have_styling('background' => 'url(https://example.app.org/images/dots.png) repeat-x').at_selector('body')
45
- document.should have_selector('strong[contains("quota")]')
46
- end
44
+ email.text_part.body.decoded.should_not match(/<.*>/)
47
45
 
48
- email.parts.find { |part| part.mime_type == 'text/plain' }.tap do |plain_part|
49
- plain_part.body.decoded.should_not match(/<.*>/)
50
- end
46
+ html = email.html_part.body.decoded
47
+ html.should include '<!DOCTYPE'
48
+ html.should include '<head'
49
+
50
+ document = parse_html_in_email(email)
51
+ document.should have_selector('body #message h1')
52
+ document.should have_styling('background' => 'url(https://example.app.org/images/dots.png) repeat-x').at_selector('body')
53
+ document.should have_selector('strong[contains("quota")]')
51
54
 
52
55
  # If we deliver mails we can catch weird problems with headers being invalid
53
56
  email.deliver
@@ -65,12 +68,32 @@ module Roadie
65
68
 
66
69
  it "applies CSS3 styles" do
67
70
  email = mailer.notification('doe@example.com', 'your quota limit has been reached')
68
- document = Nokogiri::HTML.parse(email.html_part.body.decoded)
71
+ document = parse_html_in_email(email)
69
72
  strong_node = document.css('strong').first
70
73
  stylings = SpecHelpers.styling_of_node(strong_node)
71
74
  stylings.should include(['box-shadow', '#62b0d7 1px 1px 1px 1px inset, #aaaaaa 1px 1px 3px 0'])
72
75
  stylings.should include(['-o-box-shadow', '#62b0d7 1px 1px 1px 1px inset, #aaaaaa 1px 1px 3px 0'])
73
76
  end
77
+
78
+ it "only removes the css option when disabled" do
79
+ Rails.application.config.roadie.enabled = false
80
+
81
+ email = mailer.notification('doe@example.com', 'your quota limit has been reached')
82
+
83
+ email.header.fields.map(&:name).should_not include('css')
84
+
85
+ email.to.should == ['doe@example.com']
86
+ email.from.should == ['john@example.com']
87
+ email.should have(2).parts
88
+
89
+ html = email.html_part.body.decoded
90
+ html.should_not include '<!DOCTYPE'
91
+ html.should_not include '<head'
92
+
93
+ document = parse_html_in_email(email)
94
+ document.should_not have_styling('color' => '#eee').at_selector('h1')
95
+ document.should_not have_styling('background' => 'url(https://example.app.org/images/dots.png) repeat-x').at_selector('body')
96
+ end
74
97
  end
75
98
 
76
99
  describe "filesystem integration" do
@@ -41,11 +41,25 @@ module Roadie
41
41
  end
42
42
 
43
43
  it "allows procs defining the CSS files to use" do
44
- expect_global_css ['from proc']
45
44
  proc = lambda { 'from proc' }
45
+
46
+ expect_global_css ['from proc']
46
47
  mailer.override_css([proc])
47
48
  end
48
49
 
50
+ it "runs procs in the context of the instance" do
51
+ new_mailer = Class.new(mailer) do
52
+ private
53
+ def a_private_method
54
+ 'from private method'
55
+ end
56
+ end
57
+ proc = lambda { a_private_method }
58
+
59
+ expect_global_css ['from private method']
60
+ new_mailer.override_css([proc])
61
+ end
62
+
49
63
  it "uses no global CSS when :css is set to nil" do
50
64
  expect_global_css []
51
65
  mailer.override_css(nil)
@@ -105,6 +119,12 @@ module Roadie
105
119
  Roadie.should_receive(:inline_css).with(provider, ['simple'], 'Hello HTML', anything).and_return('html')
106
120
  mailer.singlepart_html.body.decoded.should == 'html'
107
121
  end
122
+
123
+ it "does not inline css when Roadie is disabled" do
124
+ Roadie.stub :enabled? => false
125
+ Roadie.should_not_receive(:inline_css)
126
+ mailer.singlepart_html.body.decoded.should == 'Hello HTML'
127
+ end
108
128
  end
109
129
 
110
130
  describe "for multipart" do
@@ -118,6 +138,14 @@ module Roadie
118
138
  email.html_part.body.decoded.should == 'html'
119
139
  email.text_part.body.decoded.should == 'Hello Text'
120
140
  end
141
+
142
+ it "does not inline css when Roadie is disabled" do
143
+ Roadie.stub :enabled? => false
144
+ Roadie.should_not_receive(:inline_css)
145
+ email = mailer.multipart
146
+ email.html_part.body.decoded.should == 'Hello HTML'
147
+ email.text_part.body.decoded.should == 'Hello Text'
148
+ end
121
149
  end
122
150
  end
123
151
  end
@@ -446,7 +446,7 @@ describe Roadie::Inliner do
446
446
  end
447
447
 
448
448
  it "sets xmlns of <html> to that of XHTML" do
449
- rendering('<html><body></body></html>').should have_selector('html[xmlns="http://www.w3.org/1999/xhtml"]')
449
+ rendering('<html><body></body></html>').should have_node('html').with_attributes("xmlns" => "http://www.w3.org/1999/xhtml")
450
450
  end
451
451
 
452
452
  it "inserts basic html structure if not present" do
@@ -1,6 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Roadie do
4
+ let(:config) { Rails.application.config }
5
+
4
6
  describe ".inline_css" do
5
7
  it "creates an instance of Roadie::Inliner and execute it" do
6
8
  Roadie::Inliner.should_receive(:new).with('attri', 'butes').and_return(double('inliner', :execute => 'html'))
@@ -22,9 +24,17 @@ describe Roadie do
22
24
  end
23
25
  end
24
26
 
27
+ describe ".enabled?" do
28
+ it "returns the value of config.roadie.enabled" do
29
+ config.roadie.stub :enabled => true
30
+ Roadie.should be_enabled
31
+ config.roadie.stub :enabled => false
32
+ Roadie.should_not be_enabled
33
+ end
34
+ end
35
+
25
36
  describe ".current_provider" do
26
37
  let(:provider) { double("provider instance") }
27
- let(:config) { Roadie.app.config }
28
38
 
29
39
  context "with a set provider in the config" do
30
40
  it "uses the set provider" do
@@ -40,7 +40,7 @@ class TestApplication < Rails::Application
40
40
  @config = OpenStruct.new({
41
41
  :action_mailer => OpenStruct.new(:default_url_options => {}),
42
42
  :assets => OpenStruct.new(:enabled => false),
43
- :roadie => OpenStruct.new(:provider => nil),
43
+ :roadie => OpenStruct.new(:provider => nil, :enabled => true),
44
44
  })
45
45
  change_default_url_options(:host => "example.com")
46
46
  end
@@ -10,7 +10,7 @@ RSpec::Matchers.define :have_attribute do |attribute|
10
10
  expected == attribute(document, name)
11
11
  end
12
12
 
13
- describe { "have attribute #{attribute.inspect} at selector #{@selector.inspect}" }
13
+ description { "have attribute #{attribute.inspect} at selector #{@selector.inspect}" }
14
14
  failure_message_for_should 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}"
@@ -0,0 +1,19 @@
1
+ RSpec::Matchers.define :have_node do |selector|
2
+ chain(:with_attributes) { |attributes| @attributes = attributes }
3
+ match do |document|
4
+ node = document.at_css(selector)
5
+ if @attributes
6
+ node.present? and match_attributes(node.attributes)
7
+ else
8
+ node.present?
9
+ end
10
+ end
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}"}
14
+
15
+ def match_attributes(node_attributes)
16
+ attributes = Hash[node_attributes.map { |name, attribute| [name, attribute.value] }]
17
+ @attributes == attributes
18
+ end
19
+ end
@@ -13,7 +13,7 @@ RSpec::Matchers.define :have_styling do |rules|
13
13
  end
14
14
  end
15
15
 
16
- describe { "have styles #{rules.inspect} at selector #{@selector.inspect}" }
16
+ description { "have styles #{rules.inspect} at selector #{@selector.inspect}" }
17
17
  failure_message_for_should { |document| "expected styles at #{@selector.inspect} to be #{rules.inspect} but was #{parsed_styles(document).inspect}" }
18
18
  failure_message_for_should_not { "expected styles at #{@selector.inspect} to not be #{rules.inspect}" }
19
19
 
@@ -9,9 +9,17 @@ module SpecHelpers
9
9
  end
10
10
 
11
11
  def parse_styling(styles)
12
- styles.split(';').inject([]) do |array, item|
13
- array << item.split(':', 2).map(&:strip)
14
- end
12
+ styles.split(';').map { |style| parse_style(style) }
15
13
  end
14
+
15
+ private
16
+ def parse_style(style)
17
+ rule, value = style.split(':', 2).map(&:strip)
18
+ [rule, normalize_escaped_quotes(value)]
19
+ end
20
+
21
+ def normalize_escaped_quotes(string)
22
+ string.gsub('%22', '"')
23
+ end
16
24
  end
17
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roadie
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.3
4
+ version: 2.3.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-22 00:00:00.000000000 Z
12
+ date: 2012-11-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -189,6 +189,7 @@ files:
189
189
  - spec/support/anonymous_mailer.rb
190
190
  - spec/support/change_url_options.rb
191
191
  - spec/support/have_attribute_matcher.rb
192
+ - spec/support/have_node_matcher.rb
192
193
  - spec/support/have_selector_matcher.rb
193
194
  - spec/support/have_styling_matcher.rb
194
195
  - spec/support/parse_styling.rb
@@ -206,7 +207,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
206
207
  version: '0'
207
208
  segments:
208
209
  - 0
209
- hash: 2753670790342683218
210
+ hash: -214488827015921512
210
211
  required_rubygems_version: !ruby/object:Gem::Requirement
211
212
  none: false
212
213
  requirements:
@@ -215,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
216
  version: '0'
216
217
  segments:
217
218
  - 0
218
- hash: 2753670790342683218
219
+ hash: -214488827015921512
219
220
  requirements: []
220
221
  rubyforge_project:
221
222
  rubygems_version: 1.8.24
@@ -241,6 +242,7 @@ test_files:
241
242
  - spec/support/anonymous_mailer.rb
242
243
  - spec/support/change_url_options.rb
243
244
  - spec/support/have_attribute_matcher.rb
245
+ - spec/support/have_node_matcher.rb
244
246
  - spec/support/have_selector_matcher.rb
245
247
  - spec/support/have_styling_matcher.rb
246
248
  - spec/support/parse_styling.rb