high_voltage 2.1.0 → 2.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6132908ee3ceb8d0bd92c7904926e07aa25d33fa
4
- data.tar.gz: 7380d36e82d395f54ba6a360ec6bf22d3a6d1f61
3
+ metadata.gz: 7f93b914b6966f7141851a562ce82ffe1e218e01
4
+ data.tar.gz: d6456e304488fec82214e584d9dbd8f261151d69
5
5
  SHA512:
6
- metadata.gz: 46412825479d480b85bb248ac95c08f8428b8b8e95f0c1365ff5430377d197cfcf9faf1a3ba83f94fccb34ee4bf5c9c19ee43d3d2b49a88ec53549096a148c9d
7
- data.tar.gz: 012bbf16df86ae556196514c59c21b963d9300a82245663ec0ae2eee0c007e66ceac20e21dba0072d9abd3cfac81af36ee82dd109864883cca6af97f80b2a38a
6
+ metadata.gz: eabead4dde04710b58c97047ca3d0b18af4694696b0e800af9ad0618d08d37c358071999f2fb4a56455857c501d1204a1df73c91c85f58e1fe4d9c71a915d93d
7
+ data.tar.gz: 8a0b9a4dabe052d01a1b2f4edc91cc7bd15a36eff75ab49d7db3e4c18fe9509203edc214fc2a5d2767022cdfac32c384b94af8023583a5e39944fd94830be8ba
@@ -1,8 +1,8 @@
1
1
  language:
2
2
  - ruby
3
3
  install:
4
- - 'bundle install'
4
+ - 'travis_retry bundle install'
5
5
  rvm:
6
- - 1.9.2
7
6
  - 1.9.3
8
7
  - 2.0.0
8
+ - 2.1.2
data/Appraisals CHANGED
@@ -1,5 +1,5 @@
1
1
  if RUBY_VERSION >= '2.0'
2
- rails_versions = ['~> 3.2.13', '~> 4.0.0']
2
+ rails_versions = ['~> 3.2.13', '~> 4.0.0', '~> 4.1.0']
3
3
  else
4
4
  rails_versions = ['~> 3.1.12', '~> 3.2.13']
5
5
  end
@@ -8,7 +8,7 @@ rails_versions.each do |rails_version|
8
8
  appraise "rails#{rails_version.slice(/\d+\.\d+/)}" do
9
9
  gem 'rails', rails_version
10
10
 
11
- if rails_version == '~> 4.0.0'
11
+ if ['~> 4.0.0', '~> 4.1.0'].include? rails_version
12
12
  gem 'actionpack-action_caching'
13
13
  gem 'actionpack-page_caching'
14
14
  end
@@ -1,62 +1,71 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- high_voltage (2.1.0)
4
+ high_voltage (2.2.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
- activesupport (3.1.12)
10
- multi_json (~> 1.0)
11
- appraisal (0.5.2)
9
+ actionpack (4.1.1)
10
+ actionview (= 4.1.1)
11
+ activesupport (= 4.1.1)
12
+ rack (~> 1.5.2)
13
+ rack-test (~> 0.6.2)
14
+ actionview (4.1.1)
15
+ activesupport (= 4.1.1)
16
+ builder (~> 3.1)
17
+ erubis (~> 2.7.0)
18
+ activemodel (4.1.1)
19
+ activesupport (= 4.1.1)
20
+ builder (~> 3.1)
21
+ activesupport (4.1.1)
22
+ i18n (~> 0.6, >= 0.6.9)
23
+ json (~> 1.7, >= 1.7.7)
24
+ minitest (~> 5.1)
25
+ thread_safe (~> 0.1)
26
+ tzinfo (~> 1.1)
27
+ appraisal (1.0.0)
12
28
  bundler
13
29
  rake
14
- capybara (2.0.3)
15
- mime-types (>= 1.16)
16
- nokogiri (>= 1.3.3)
17
- rack (>= 1.0.0)
18
- rack-test (>= 0.5.4)
19
- selenium-webdriver (~> 2.0)
20
- xpath (~> 1.0.0)
21
- childprocess (0.3.9)
22
- ffi (~> 1.0, >= 1.0.11)
23
- coderay (1.0.9)
24
- diff-lcs (1.1.3)
25
- ffi (1.9.0)
26
- method_source (0.8.1)
27
- mime-types (1.23)
28
- mini_portile (0.5.1)
29
- multi_json (1.7.7)
30
- nokogiri (1.6.0)
31
- mini_portile (~> 0.5.0)
32
- pry (0.9.12.2)
33
- coderay (~> 1.0.5)
30
+ thor (>= 0.14.0)
31
+ builder (3.2.2)
32
+ coderay (1.1.0)
33
+ diff-lcs (1.2.5)
34
+ erubis (2.7.0)
35
+ i18n (0.6.9)
36
+ json (1.8.1)
37
+ method_source (0.8.2)
38
+ minitest (5.3.3)
39
+ pry (0.9.12.6)
40
+ coderay (~> 1.0)
34
41
  method_source (~> 0.8)
35
42
  slop (~> 3.4)
36
43
  rack (1.5.2)
37
44
  rack-test (0.6.2)
38
45
  rack (>= 1.0)
39
- rake (10.1.0)
40
- rspec (2.1.0)
41
- rspec-core (~> 2.1.0)
42
- rspec-expectations (~> 2.1.0)
43
- rspec-mocks (~> 2.1.0)
44
- rspec-core (2.1.0)
45
- rspec-expectations (2.1.0)
46
- diff-lcs (~> 1.1.2)
47
- rspec-mocks (2.1.0)
48
- rspec-rails (2.1.0)
49
- rspec (~> 2.1.0)
50
- rubyzip (0.9.9)
51
- selenium-webdriver (2.33.0)
52
- childprocess (>= 0.2.5)
53
- multi_json (~> 1.0)
54
- rubyzip
55
- websocket (~> 1.0.4)
56
- slop (3.4.5)
57
- websocket (1.0.7)
58
- xpath (1.0.0)
59
- nokogiri (~> 1.3)
46
+ railties (4.1.1)
47
+ actionpack (= 4.1.1)
48
+ activesupport (= 4.1.1)
49
+ rake (>= 0.8.7)
50
+ thor (>= 0.18.1, < 2.0)
51
+ rake (10.3.1)
52
+ rspec-core (2.14.8)
53
+ rspec-expectations (2.14.5)
54
+ diff-lcs (>= 1.1.3, < 2.0)
55
+ rspec-mocks (2.14.6)
56
+ rspec-rails (2.14.2)
57
+ actionpack (>= 3.0)
58
+ activemodel (>= 3.0)
59
+ activesupport (>= 3.0)
60
+ railties (>= 3.0)
61
+ rspec-core (~> 2.14.0)
62
+ rspec-expectations (~> 2.14.0)
63
+ rspec-mocks (~> 2.14.0)
64
+ slop (3.5.0)
65
+ thor (0.19.1)
66
+ thread_safe (0.3.3)
67
+ tzinfo (1.1.0)
68
+ thread_safe (~> 0.1)
60
69
 
61
70
  PLATFORMS
62
71
  ruby
@@ -64,7 +73,6 @@ PLATFORMS
64
73
  DEPENDENCIES
65
74
  activesupport (>= 3.1.0)
66
75
  appraisal
67
- capybara (= 2.0.3)
68
76
  high_voltage!
69
77
  pry
70
78
  rspec-rails
@@ -1,4 +1,4 @@
1
- Copyright 2010-2013 thoughtbot, inc.
1
+ Copyright 2010-2014 thoughtbot, inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/NEWS.md CHANGED
@@ -1,3 +1,11 @@
1
+ New for 2.2.0:
2
+ + Deprecate caching because page and action caching was removed in Rails 4
3
+ + Refactor test suite to use rspec `expect` syntax consistently.
4
+ + Added Rails 4.1 to test suite.
5
+ + Remove Ruby 1.9.2 from test suite.
6
+ + Remove Capybara from test suite.
7
+ + Support dependency injection for Rails engine to define routes on
8
+
1
9
  New for 2.1.0:
2
10
  + Extract configuration options into a module
3
11
  + Add ability to configure whether layout is cached with action_caching
data/README.md CHANGED
@@ -15,7 +15,7 @@ Yeah, like "About us", "Directions", marketing pages, etc.
15
15
  Include in your Gemfile:
16
16
 
17
17
  ```ruby
18
- gem 'high_voltage', '~> 2.1.0'
18
+ gem 'high_voltage', '~> 2.2.0'
19
19
  ```
20
20
 
21
21
  For Rails versions prior to 3.0, use the 0.9.2 tag of high_voltage:
@@ -113,6 +113,18 @@ HighVoltage.configure do |config|
113
113
  end
114
114
  ```
115
115
 
116
+ #### Specifying Rails engine for routes
117
+
118
+ If you are using multiple Rails engines within your application, you can
119
+ specify which engine to define the default HighVoltage routes on.
120
+
121
+ ```ruby
122
+ # config/initializers/high_voltage.rb
123
+ HighVoltage.configure do |config|
124
+ config.parent_engine = MyEngine
125
+ end
126
+ ```
127
+
116
128
  #### Page titles and meta-data
117
129
 
118
130
  We suggest using `content_for` and `yield` for setting custom page titles and
@@ -145,36 +157,12 @@ end
145
157
 
146
158
  #### Caching
147
159
 
148
- High Voltage supports both [page](http://guides.rubyonrails.org/caching_with_rails.html#page-caching) and [action caching](http://guides.rubyonrails.org/caching_with_rails.html#action-caching).
160
+ Caching has been deprecated and will be removed in the next release.
149
161
 
150
- To enable action-caching you can add the following to your initializer:
151
-
152
- ```ruby
153
- # config/initializers/high_voltage.rb
154
- HighVolgate.configure do |config|
155
- config.action_caching = true
156
- config.action_caching_layout = false # optionally do not cache layout. default is true.
157
- end
158
- ```
159
-
160
- To enable page-caching:
161
-
162
- ```ruby
163
- # config/initializers/high_voltage.rb
164
- HighVolgate.configure do |config|
165
- config.page_caching = true
166
- end
167
- ```
168
-
169
- High Voltage will use your default cache store to store action caches.
170
-
171
- Using caching with Ruby on Rails 4 or higher requires gems:
172
-
173
- ```ruby
174
- # Gemfile
175
- gem 'actionpack-action_caching'
176
- gem 'actionpack-page_caching'
177
- ```
162
+ Page caching and action caching can be done via Rails. Visit the [Caching with
163
+ Rails: An overview](http://guides.rubyonrails.org/caching_with_rails.html) guide
164
+ for more details. You can utilize the methods described there by overriding the
165
+ HighVoltage controller as described [below](#override).
178
166
 
179
167
  ## Override
180
168
 
@@ -230,6 +218,15 @@ class PagesController < ApplicationController
230
218
  end
231
219
  ```
232
220
 
221
+ To set up a different layout for all High Voltage static pages, use an initializer:
222
+
223
+ ```ruby
224
+ # config/initializers/high_voltage.rb
225
+ HighVoltage.configure do |config|
226
+ config.layout = 'your_layout'
227
+ end
228
+ ```
229
+
233
230
  ## Custom finding
234
231
 
235
232
  You can further control the algorithm used to find pages by overriding
@@ -309,5 +306,5 @@ The names and logos for thoughtbot are trademarks of thoughtbot, inc.
309
306
 
310
307
  ## License
311
308
 
312
- High Voltage is Copyright © 2009-2013 thoughtbot. It is free software, and may
309
+ High Voltage is Copyright © 2009-2014 thoughtbot. It is free software, and may
313
310
  be redistributed under the terms specified in the MIT-LICENSE file.
@@ -1,4 +1,4 @@
1
- Rails.application.routes.draw do
1
+ HighVoltage.parent_engine.routes.draw do
2
2
  if HighVoltage.home_page
3
3
  get "/#{HighVoltage.home_page}", to: redirect('/')
4
4
  root to: 'high_voltage/pages#show', id: HighVoltage.home_page
@@ -18,7 +18,6 @@ Gem::Specification.new do |s|
18
18
 
19
19
  s.add_development_dependency("activesupport", ">= 3.1.0")
20
20
  s.add_development_dependency("appraisal")
21
- s.add_development_dependency("capybara", "= 2.0.3")
22
21
  s.add_development_dependency("pry")
23
22
  s.add_development_dependency("rspec-rails")
24
23
  end
@@ -1,3 +1,4 @@
1
+ require 'active_support/core_ext/string'
1
2
  require 'active_support/core_ext/module/attribute_accessors'
2
3
 
3
4
  require 'high_voltage/configuration'
@@ -1,16 +1,21 @@
1
1
  module HighVoltage
2
2
  module Configuration
3
+ CACHING_DEPRECATION_WARNING = <<-WARNING.strip_heredoc.squish
4
+ Caching support has been deprecated and will be removed
5
+ in the next release.
6
+ WARNING
7
+
3
8
  attr_accessor(
4
- :action_caching,
5
- :action_caching_layout,
6
9
  :content_path,
7
10
  :home_page,
8
11
  :layout,
9
- :page_caching,
12
+ :parent_engine,
10
13
  :route_drawer,
11
14
  :routes,
12
15
  )
13
16
 
17
+ attr_reader :action_caching, :action_caching_layout, :page_caching
18
+
14
19
  def configure
15
20
  yield self
16
21
  end
@@ -19,13 +24,29 @@ module HighVoltage
19
24
  base.set_default_configuration
20
25
  end
21
26
 
27
+ def action_caching=(value)
28
+ ActiveSupport::Deprecation.warn(CACHING_DEPRECATION_WARNING)
29
+ @action_caching = value
30
+ end
31
+
32
+ def action_caching_layout=(value)
33
+ ActiveSupport::Deprecation.warn(CACHING_DEPRECATION_WARNING)
34
+ @action_caching_layout = value
35
+ end
36
+
37
+ def page_caching=(value)
38
+ ActiveSupport::Deprecation.warn(CACHING_DEPRECATION_WARNING)
39
+ @page_caching = value
40
+ end
41
+
22
42
  def set_default_configuration
23
- self.action_caching = false
24
- self.action_caching_layout = true
43
+ @action_caching = false
44
+ @action_caching_layout = true
45
+ @page_caching = false
46
+
25
47
  self.content_path = 'pages/'
26
48
  self.home_page = nil
27
49
  self.layout = 'application'
28
- self.page_caching = false
29
50
  self.route_drawer = HighVoltage::RouteDrawers::Default
30
51
  self.routes = true
31
52
  end
@@ -1,13 +1,15 @@
1
1
  module HighVoltage
2
2
  class Engine < Rails::Engine
3
+ initializer 'Set up default parent engine' do |app|
4
+ HighVoltage.parent_engine ||= Rails.application
5
+ end
6
+
3
7
  initializer 'Require concerns path' do |app|
4
8
  concerns_path = 'app/controllers/concerns'
5
9
 
6
10
  unless app.paths.keys.include?(concerns_path)
7
11
  app.paths.add(concerns_path)
8
12
  end
9
-
10
- require 'concerns/high_voltage/static_page'
11
13
  end
12
14
  end
13
15
  end
@@ -1,3 +1,3 @@
1
1
  module HighVoltage
2
- VERSION = '2.1.0'.freeze
2
+ VERSION = '2.2.0'.freeze
3
3
  end
@@ -1,25 +1,21 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe HighVoltage::Constraints::RootRoute, '.matches?' do
4
- context 'view file exists' do
5
- it 'should return true' do
6
- request = double(path: 'index')
7
- Dir.stub(:glob).and_return(['about.html.erb'])
4
+ it 'returns true when the view file exists' do
5
+ request = double(path: 'index')
6
+ Dir.stub(:glob).and_return(['about.html.erb'])
8
7
 
9
- result = HighVoltage::Constraints::RootRoute.matches?(request)
8
+ result = HighVoltage::Constraints::RootRoute.matches?(request)
10
9
 
11
- expect(result).to be_true
12
- end
10
+ expect(result).to be_true
13
11
  end
14
12
 
15
- context 'view file does not exist' do
16
- it 'should return false' do
17
- request = double(path: 'index')
18
- File.stub(:glob).and_return([])
13
+ it 'returns false when the view files does not exist' do
14
+ request = double(path: 'index')
15
+ File.stub(:glob).and_return([])
19
16
 
20
- result = HighVoltage::Constraints::RootRoute.matches?(request)
17
+ result = HighVoltage::Constraints::RootRoute.matches?(request)
21
18
 
22
- expect(result).to be_false
23
- end
19
+ expect(result).to be_false
24
20
  end
25
21
  end
@@ -4,24 +4,35 @@ describe HighVoltage::PagesController, '#action_caching' do
4
4
  let(:page_name) { :exists }
5
5
 
6
6
  context 'action_caching set to true' do
7
- it 'caches the action', enable_caching: true do
8
- HighVoltage.action_caching = true
9
- concern_reload
7
+ after do
8
+ set_action_caching_without_deprecation(false)
9
+ end
10
+
11
+ it 'caches the action' do
12
+ allow(controller).to receive(:_save_fragment)
13
+ set_action_caching_without_deprecation(true)
14
+
15
+ get :show, id: page_name
10
16
 
11
- expect { get :show, id: page_name }.to change { action_cache_exists? }
17
+ expect(controller).to have_received(:_save_fragment)
18
+ .with("test.host#{page_path(page_name)}", {})
12
19
  end
13
20
  end
14
21
 
15
22
  context 'action_caching set to false' do
16
- it 'does not cache the action', enable_caching: true do
17
- HighVoltage.action_caching = false
18
- concern_reload
23
+ it 'does not cache the action' do
24
+ allow(controller).to receive(:_save_fragment)
25
+ set_action_caching_without_deprecation(false)
19
26
 
20
- expect { get :show, id: page_name }.to_not change { action_cache_exists? }
27
+ get :show, id: page_name
28
+
29
+ expect(controller).not_to have_received(:_save_fragment)
21
30
  end
22
31
  end
23
32
 
24
- def action_cache_exists?
25
- ActionController::Base.cache_store.exist?("views/test.host#{page_path(page_name)}")
33
+ def set_action_caching_without_deprecation(value)
34
+ ActiveSupport::Deprecation.silence do
35
+ HighVoltage.action_caching = value
36
+ end
26
37
  end
27
38
  end
@@ -6,7 +6,7 @@ describe AlternativeFinderController do
6
6
  it 'renders the file from the alternative directory' do
7
7
  get :show, :id => 'ebg13'
8
8
 
9
- response.should be_success
10
- response.should render_template('rot13')
9
+ expect(response).to be_success
10
+ expect(response).to render_template('rot13')
11
11
  end
12
12
  end
@@ -4,25 +4,34 @@ describe HighVoltage::PagesController, '#cache_page' do
4
4
  let(:page_name) { :exists }
5
5
 
6
6
  context 'page_caching set to true' do
7
- it 'caches the page', enable_caching: true do
8
- HighVoltage.page_caching = true
9
- concern_reload
7
+ after do
8
+ set_page_caching_without_deprecation(false)
9
+ end
10
10
 
11
- controller.should_receive(:cache_page).at_least(:once)
11
+ it 'caches the page' do
12
+ allow(controller).to receive(:cache_page)
13
+ set_page_caching_without_deprecation(true)
12
14
 
13
15
  get :show, id: page_name
16
+
17
+ expect(controller).to have_received(:cache_page)
14
18
  end
15
19
  end
16
20
 
17
21
  context 'page_caching set to false' do
18
- it 'does not cache the page', enable_caching: true do
19
- HighVoltage.page_caching = false
20
- concern_reload
21
-
22
- controller.should_receive(:cache_page).never
22
+ it 'does not cache the page' do
23
+ allow(controller).to receive(:cache_page)
24
+ set_page_caching_without_deprecation(false)
23
25
 
24
26
  get :show, id: page_name
27
+
28
+ expect(controller).not_to have_received(:cache_page)
25
29
  end
26
30
  end
27
- end
28
31
 
32
+ def set_page_caching_without_deprecation(value)
33
+ ActiveSupport::Deprecation.silence do
34
+ HighVoltage.page_caching = value
35
+ end
36
+ end
37
+ end
@@ -7,44 +7,38 @@ describe HighVoltage::PagesController do
7
7
  describe 'on GET to /pages/exists' do
8
8
  before { get :show, :id => 'exists' }
9
9
 
10
- it 'should respond with success and render template' do
11
- response.should be_success
12
- response.should render_template('exists')
10
+ it 'responds with success and render template' do
11
+ expect(response).to be_success
12
+ expect(response).to render_template('exists')
13
13
  end
14
14
 
15
- it 'should use the default layout used by ApplicationController' do
16
- response.should render_template('layouts/application')
15
+ it 'uses the default layout used by ApplicationController' do
16
+ expect(response).to render_template('layouts/application')
17
17
  end
18
18
  end
19
19
 
20
20
  describe 'on GET to /pages/dir/nested' do
21
21
  before { get :show, :id => 'dir/nested' }
22
22
 
23
- it 'should respond with success and render template' do
24
- response.should be_success
25
- response.should render_template('pages/dir/nested')
23
+ it 'responds with success and render template' do
24
+ expect(response).to be_success
25
+ expect(response).to render_template('pages/dir/nested')
26
26
  end
27
27
  end
28
28
 
29
- it 'should raise a routing error for an invalid page' do
30
- lambda {
31
- get :show,
32
- :id => 'invalid'
33
- }.should raise_error(ActionController::RoutingError)
29
+ it 'raises a routing error for an invalid page' do
30
+ expect { get :show, id: 'invalid' }
31
+ .to raise_error(ActionController::RoutingError)
34
32
  end
35
33
 
36
- it 'should raise a routing error for a page in another directory' do
37
- lambda {
38
- get :show,
39
- :id => '../other/wrong'
40
- }.should raise_error(ActionController::RoutingError)
34
+ it 'raises a routing error for a page in another directory' do
35
+ expect { get :show, id: '../other/wrong' }
36
+ .to raise_error(ActionController::RoutingError)
41
37
  end
42
38
 
43
- it 'should raise missing template error for valid page with invalid partial' do
44
- lambda {
45
- get :show,
46
- :id => 'exists_but_references_nonexistent_partial'
47
- }.should raise_error(ActionView::MissingTemplate)
39
+ it 'raises a missing template error for valid page with invalid partial' do
40
+ expect { get :show, id: 'exists_but_references_nonexistent_partial' }
41
+ .to raise_error(ActionView::MissingTemplate)
48
42
  end
49
43
  end
50
44
 
@@ -56,9 +50,9 @@ describe HighVoltage::PagesController do
56
50
  describe 'on GET to /pages/exists' do
57
51
  before { get :show, :id => 'exists' }
58
52
 
59
- it 'should use the custom configured layout' do
60
- response.should_not render_template('layouts/application')
61
- response.should render_template('layouts/alternate')
53
+ it 'uses the custom configured layout' do
54
+ expect(response).not_to render_template('layouts/application')
55
+ expect(response).to render_template('layouts/alternate')
62
56
  end
63
57
  end
64
58
  end
@@ -72,47 +66,43 @@ describe HighVoltage::PagesController do
72
66
  describe 'on GET to /other_pages/also_exists' do
73
67
  before { get :show, :id => 'also_exists' }
74
68
 
75
- it 'should respond with success and render template' do
76
- response.should be_success
77
- response.should render_template('other_pages/also_exists')
69
+ it 'responds with success and render template' do
70
+ expect(response).to be_success
71
+ expect(response).to render_template('other_pages/also_exists')
78
72
  end
79
73
  end
80
74
 
81
75
  describe 'on GET to /other_pages/also_dir/nested' do
82
76
  before { get :show, :id => 'also_dir/also_nested' }
83
77
 
84
- it 'should respond with success and render template' do
85
- response.should be_success
86
- response.should render_template('other_pages/also_dir/also_nested')
78
+ it 'responds with success and render template' do
79
+ expect(response).to be_success
80
+ expect(response).to render_template('other_pages/also_dir/also_nested')
87
81
  end
88
82
  end
89
83
 
90
- it 'should raise a routing error for an invalid page' do
91
- lambda {
92
- get :show,
93
- :id => 'also_invalid'
94
- }.should raise_error(ActionController::RoutingError)
84
+ it 'raises a routing error for an invalid page' do
85
+ expect { get :show, id: 'also_invalid' }
86
+ .to raise_error(ActionController::RoutingError)
95
87
  end
96
88
 
97
- it 'should raise a routing error for a page in another directory' do
98
- lambda {
99
- get :show,
100
- :id => '../other/wrong'
101
- }.should raise_error(ActionController::RoutingError)
102
- end
89
+ context 'page in another directory' do
90
+ it 'raises a routing error' do
91
+ expect { get :show, id: '../other_wrong' }
92
+ .to raise_error(ActionController::RoutingError)
93
+ end
103
94
 
104
- it 'should raise a routing error for a page in another directory when using a Unicode exploit' do
105
- lambda {
106
- get :show,
107
- :id => '/\\../other/wrong'
108
- }.should raise_error(ActionController::RoutingError)
95
+ it 'raises a routing error when using a Unicode exploit' do
96
+ expect { get :show, id: '/\\../other/wrong' }
97
+ .to raise_error(ActionController::RoutingError)
98
+ end
109
99
  end
110
100
 
111
- it 'should raise missing template error for valid page with invalid partial' do
112
- lambda {
113
- get :show,
114
- :id => 'also_exists_but_references_nonexistent_partial'
115
- }.should raise_error(ActionView::MissingTemplate)
101
+ it 'raises a missing template error for valid page with invalid partial' do
102
+ id = 'also_exists_but_references_nonexistent_partial'
103
+
104
+ expect { get :show, id: id }
105
+ .to raise_error(ActionView::MissingTemplate)
116
106
  end
117
107
  end
118
108
  end
@@ -6,35 +6,29 @@ describe SubclassedPagesController do
6
6
  describe 'on GET to /subclassed_pages/also_exists' do
7
7
  before { get :show, :id => 'also_exists' }
8
8
 
9
- it 'should respond with success and render template' do
10
- response.should be_success
11
- response.should render_template('also_exists')
9
+ it 'responds with success and render template' do
10
+ expect(response).to be_succes
11
+ expect(response).to render_template('also_exists')
12
12
  end
13
13
 
14
- it 'should use the custom configured layout' do
15
- response.should_not render_template('layouts/application')
16
- response.should render_template('layouts/alternate')
14
+ it 'uses the custom configured layout' do
15
+ expect(response).not_to render_template('layouts/application')
16
+ expect(response).to render_template('layouts/alternate')
17
17
  end
18
18
  end
19
19
 
20
- it 'should raise a routing error for an invalid page' do
21
- lambda {
22
- get :show,
23
- :id => 'invalid'
24
- }.should raise_error(ActionController::RoutingError)
20
+ it 'raises a routing error for an invalid page' do
21
+ expect { get :show, id: 'invalid' }
22
+ .to raise_error(ActionController::RoutingError)
25
23
  end
26
24
 
27
- it 'should raise a routing error for a page in another directory' do
28
- lambda {
29
- get :show,
30
- :id => '../other/wrong'
31
- }.should raise_error(ActionController::RoutingError)
25
+ it 'raises a routing error for a page in another directory' do
26
+ expect { get :show, id: '../other/wrong' }
27
+ .to raise_error(ActionController::RoutingError)
32
28
  end
33
29
 
34
- it 'should raise missing template error for valid page with invalid partial' do
35
- lambda {
36
- get :show,
37
- :id => 'also_exists_but_references_nonexistent_partial'
38
- }.should raise_error(ActionView::MissingTemplate)
30
+ it 'raises a missing template error for valid page with invalid partial' do
31
+ expect { get :show, id: 'also_exists_but_references_nonexistent_partial' }
32
+ .to raise_error(ActionView::MissingTemplate)
39
33
  end
40
34
  end
@@ -11,7 +11,8 @@ Dummy::Application.configure do
11
11
 
12
12
  # Show full error reports and disable caching
13
13
  config.consider_all_requests_local = true
14
- config.action_controller.perform_caching = false
14
+ config.action_controller.perform_caching = true
15
+ config.action_controller.cache_store = :memory_store
15
16
 
16
17
  # Raise exceptions instead of rendering exception templates
17
18
  config.action_dispatch.show_exceptions = false
@@ -1,25 +1,88 @@
1
- require 'spec_helper'
1
+ require 'minimal_spec_helper'
2
2
 
3
3
  describe HighVoltage::Configuration do
4
- let(:config_value) { 'fake_config_value' }
5
-
6
- before(:each) do
7
- HighVoltage.configure do |config|
8
- config.action_caching = config_value
9
- config.action_caching_layout = config_value
10
- config.content_path = config_value
11
- config.layout = config_value
12
- config.page_caching = config_value
13
- config.route_drawer = config_value
14
- config.routes = config_value
4
+ describe 'basic config assignment' do
5
+ let(:config_value) { 'fake_config_value' }
6
+
7
+ before(:each) do
8
+ HighVoltage.configure do |config|
9
+ ActiveSupport::Deprecation.silence do
10
+ config.action_caching = config_value
11
+ config.action_caching_layout = config_value
12
+ config.content_path = config_value
13
+ config.layout = config_value
14
+ config.page_caching = config_value
15
+ config.parent_engine = config_value
16
+ config.route_drawer = config_value
17
+ config.routes = config_value
18
+ end
19
+ end
20
+ end
21
+
22
+ after(:each) do
23
+ HighVoltage.configure do |config|
24
+ config.parent_engine = Rails.application
25
+ end
26
+ end
27
+
28
+ it { expect(HighVoltage.action_caching).to eq config_value }
29
+ it { expect(HighVoltage.action_caching_layout).to eq config_value }
30
+ it { expect(HighVoltage.content_path).to eq config_value }
31
+ it { expect(HighVoltage.layout).to eq config_value }
32
+ it { expect(HighVoltage.page_caching).to eq config_value }
33
+ it { expect(HighVoltage.parent_engine).to eq config_value }
34
+ it { expect(HighVoltage.route_drawer).to eq config_value }
35
+ it { expect(HighVoltage.routes).to eq config_value }
36
+ end
37
+
38
+ describe '#action_caching=' do
39
+ it 'displays a deprecation warning' do
40
+ allow(ActiveSupport::Deprecation).to receive(:warn)
41
+
42
+ HighVoltage.configure do |config|
43
+ config.action_caching = true
44
+ end
45
+
46
+ expect(ActiveSupport::Deprecation).to have_received(:warn)
47
+ .with(HighVoltage::Configuration::CACHING_DEPRECATION_WARNING)
15
48
  end
16
49
  end
17
50
 
18
- it { expect(HighVoltage.action_caching).to eq config_value }
19
- it { expect(HighVoltage.action_caching_layout).to eq config_value }
20
- it { expect(HighVoltage.content_path).to eq config_value }
21
- it { expect(HighVoltage.layout).to eq config_value }
22
- it { expect(HighVoltage.page_caching).to eq config_value }
23
- it { expect(HighVoltage.route_drawer).to eq config_value }
24
- it { expect(HighVoltage.routes).to eq config_value }
51
+ describe '#action_caching_layout=' do
52
+ it 'displays a deprecation warning' do
53
+ allow(ActiveSupport::Deprecation).to receive(:warn)
54
+
55
+ HighVoltage.configure do |config|
56
+ config.action_caching_layout = true
57
+ end
58
+
59
+ expect(ActiveSupport::Deprecation).to have_received(:warn)
60
+ .with(HighVoltage::Configuration::CACHING_DEPRECATION_WARNING)
61
+ end
62
+ end
63
+
64
+ describe '#page_caching=' do
65
+ it 'displays a deprecation warning' do
66
+ allow(ActiveSupport::Deprecation).to receive(:warn)
67
+
68
+ HighVoltage.configure do |config|
69
+ config.page_caching = true
70
+ end
71
+
72
+ expect(ActiveSupport::Deprecation).to have_received(:warn)
73
+ .with(HighVoltage::Configuration::CACHING_DEPRECATION_WARNING)
74
+ end
75
+ end
76
+
77
+ describe '#set_default_configuration' do
78
+ it 'defaults caching without a deprecation warning' do
79
+ allow(ActiveSupport::Deprecation).to receive(:warn)
80
+
81
+ Class.new do
82
+ extend HighVoltage::Configuration
83
+ end
84
+
85
+ expect(ActiveSupport::Deprecation).not_to have_received(:warn)
86
+ end
87
+ end
25
88
  end
@@ -2,22 +2,22 @@ require 'spec_helper'
2
2
 
3
3
  describe HighVoltage::PageFinder do
4
4
  it 'produces the name of an existing template' do
5
- find('existing').should eq 'pages/existing'
5
+ expect(find('existing')).to eq 'pages/existing'
6
6
  end
7
7
 
8
8
  it 'produces the name of a nested template' do
9
- find('dir/nested').should eq 'pages/dir/nested'
9
+ expect(find('dir/nested')).to eq 'pages/dir/nested'
10
10
  end
11
11
 
12
12
  it 'uses a custom content path' do
13
13
  with_content_path('other_pages/') do
14
- find('also_exists').should eq 'other_pages/also_exists'
14
+ expect(find('also_exists')).to eq 'other_pages/also_exists'
15
15
  end
16
16
  end
17
17
 
18
18
  it 'exposes the content path' do
19
19
  with_content_path('another_thing/') do
20
- page_finder.content_path.should eq 'another_thing/'
20
+ expect(page_finder.content_path).to eq 'another_thing/'
21
21
  end
22
22
  end
23
23
 
@@ -28,7 +28,7 @@ describe HighVoltage::PageFinder do
28
28
  end
29
29
  end
30
30
 
31
- subclass.new('sweet page').page_name.should eq 'the page is sweet page'
31
+ expect(subclass.new('sweet page').page_name).to eq 'the page is sweet page'
32
32
  end
33
33
 
34
34
  private
@@ -1,11 +1,11 @@
1
1
  require 'minimal_spec_helper'
2
2
 
3
3
  describe HighVoltage do
4
- it 'should be valid' do
5
- HighVoltage.should be_a(Module)
4
+ it 'is valid' do
5
+ expect(HighVoltage).to be_a(Module)
6
6
  end
7
7
 
8
- it 'should be loadable without preloading rails' do
8
+ it 'is loadable without preloading rails' do
9
9
  expect { require 'high_voltage' }.not_to raise_error
10
10
  end
11
11
  end
@@ -1,9 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'Navigation' do
4
- include Capybara::DSL
5
-
6
- it 'should be a valid app' do
7
- ::Rails.application.should be_a(Dummy::Application)
4
+ it 'is a valid app' do
5
+ expect(::Rails.application).to be_a(Dummy::Application)
8
6
  end
9
7
  end
@@ -8,6 +8,6 @@ describe 'Home page route' do
8
8
 
9
9
  it 'redirects the duplicate content to root' do
10
10
  get '/home'
11
- expect(response).to redirect_to('/')
11
+ expect(response.headers['Location']).to eq 'http://www.example.com/'
12
12
  end
13
13
  end
@@ -3,11 +3,11 @@ require 'spec_helper'
3
3
  describe 'routes' do
4
4
  context 'default configuration' do
5
5
  it 'generates a route' do
6
- page_path('one').should eq '/pages/one'
6
+ expect(page_path('one')).to eq '/pages/one'
7
7
  end
8
8
 
9
9
  it 'generates a nested route' do
10
- page_path('one/two').should eq '/pages/one/two'
10
+ expect(page_path('one/two')).to eq '/pages/one/two'
11
11
  end
12
12
 
13
13
  it 'recognizes a route' do
@@ -51,11 +51,11 @@ describe 'routes' do
51
51
  end
52
52
 
53
53
  it 'generates a route' do
54
- page_path('one').should eq '/one'
54
+ expect(page_path('one')).to eq '/one'
55
55
  end
56
56
 
57
57
  it 'generates a nested route' do
58
- page_path('one/two').should eq '/one/two'
58
+ expect(page_path('one/two')).to eq '/one/two'
59
59
  end
60
60
  end
61
61
 
@@ -66,11 +66,11 @@ describe 'routes' do
66
66
  end
67
67
 
68
68
  it 'generates a route' do
69
- page_path('one').should eq '/other_pages/one'
69
+ expect(page_path('one')).to eq '/other_pages/one'
70
70
  end
71
71
 
72
72
  it 'generates a nested route' do
73
- page_path('one/two').should eq '/other_pages/one/two'
73
+ expect(page_path('one/two')).to eq '/other_pages/one/two'
74
74
  end
75
75
 
76
76
  it 'recognizes a route' do
@@ -125,7 +125,7 @@ describe 'routes' do
125
125
 
126
126
  context 'no home page route' do
127
127
  it 'does generate a home page route' do
128
- { :get => '/' }.should_not be_routable
128
+ expect(get: '/').not_to be_routable
129
129
  end
130
130
  end
131
131
 
@@ -134,7 +134,7 @@ describe 'routes' do
134
134
  HighVoltage.routes = false
135
135
  Rails.application.reload_routes!
136
136
 
137
- { :get => '/pages/one/two' }.should_not be_routable
137
+ expect(get: '/pages/one/two').not_to be_routable
138
138
  end
139
139
  end
140
140
  end
@@ -2,15 +2,12 @@ ENV['RAILS_ENV'] = 'test'
2
2
 
3
3
  require File.expand_path('../dummy/config/environment.rb', __FILE__)
4
4
 
5
- require 'capybara/rails'
6
5
  require 'pry'
7
6
  require 'rails/test_help'
8
7
  require 'rspec/expectations'
9
8
  require 'rspec/rails'
10
9
 
11
10
  Rails.backtrace_cleaner.remove_silencers!
12
- Capybara.default_driver = :rack_test
13
- Capybara.default_selector = :css
14
11
 
15
12
  Dir[File.dirname(__FILE__) + '/support/**/*.rb'].each { |file| require file }
16
13
 
@@ -20,6 +17,10 @@ RSpec.configure do |config|
20
17
  Rails.application.reload_routes!
21
18
  end
22
19
 
20
+ config.expect_with :rspec do |c|
21
+ c.syntax = :expect
22
+ end
23
+
23
24
  config.include RSpec::Matchers
24
25
  config.mock_with :rspec
25
26
  config.order = 'random'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: high_voltage
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Jankowski
@@ -16,7 +16,7 @@ authors:
16
16
  autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
- date: 2013-12-30 00:00:00.000000000 Z
19
+ date: 2014-06-24 00:00:00.000000000 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: activesupport
@@ -46,20 +46,6 @@ dependencies:
46
46
  - - ">="
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0'
49
- - !ruby/object:Gem::Dependency
50
- name: capybara
51
- requirement: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - '='
54
- - !ruby/object:Gem::Version
55
- version: 2.0.3
56
- type: :development
57
- prerelease: false
58
- version_requirements: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - '='
61
- - !ruby/object:Gem::Version
62
- version: 2.0.3
63
49
  - !ruby/object:Gem::Dependency
64
50
  name: pry
65
51
  requirement: !ruby/object:Gem::Requirement
@@ -177,8 +163,6 @@ files:
177
163
  - spec/requests/home_page_spec.rb
178
164
  - spec/routing/routes_spec.rb
179
165
  - spec/spec_helper.rb
180
- - spec/support/caching.rb
181
- - spec/support/concern_reload.rb
182
166
  homepage: http://github.com/thoughtbot/high_voltage
183
167
  licenses:
184
168
  - MIT
@@ -199,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
183
  version: '0'
200
184
  requirements: []
201
185
  rubyforge_project:
202
- rubygems_version: 2.2.0
186
+ rubygems_version: 2.2.2
203
187
  signing_key:
204
188
  specification_version: 4
205
189
  summary: Simple static page rendering controller
@@ -264,5 +248,3 @@ test_files:
264
248
  - spec/requests/home_page_spec.rb
265
249
  - spec/routing/routes_spec.rb
266
250
  - spec/spec_helper.rb
267
- - spec/support/caching.rb
268
- - spec/support/concern_reload.rb
@@ -1,15 +0,0 @@
1
- RSpec.configure do |config|
2
- config.around(:each, enable_caching: true) do |example|
3
- previous_cache_store = ActionController::Base.cache_store
4
-
5
- ActionController::Base.perform_caching = true
6
- ActionController::Base.cache_store = :memory_store
7
- ActionController::Base.cache_store.clear
8
-
9
- example.run
10
-
11
- ActionController::Base.cache_store.clear
12
- ActionController::Base.cache_store = previous_cache_store
13
- ActionController::Base.perform_caching = false
14
- end
15
- end
@@ -1,11 +0,0 @@
1
- def concern_reload
2
- HighVoltage::PagesController.class_eval do
3
- if respond_to?(:caches_action)
4
- caches_action :show, if: -> { HighVoltage.action_caching }
5
- end
6
-
7
- if respond_to?(:caches_page)
8
- caches_page :show, if: -> { HighVoltage.page_caching }
9
- end
10
- end
11
- end