high_voltage 2.0.0 → 2.1.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: 200549e039d8c31dc74ed8c376f5dd684314aa56
4
- data.tar.gz: 9bbe74af83cbb6ef5478451581df294b8830b82a
3
+ metadata.gz: 6132908ee3ceb8d0bd92c7904926e07aa25d33fa
4
+ data.tar.gz: 7380d36e82d395f54ba6a360ec6bf22d3a6d1f61
5
5
  SHA512:
6
- metadata.gz: 13a625a99201f9969aa48524fd001bd2eadbee5c42a0fc7fd0e956dbcaf875dd46dbafbcf407709e6042f1aa7576b9469f5f813bc95fe9cef1a96b6efb8c93f1
7
- data.tar.gz: ce011d7615d5f6e85450f1458aa901c49d69f0ad543ef6f73b26e543bebafc6ebd6d0532584f115f3d18a015e8023e3277067ea796f2ac0d8543e2bc5015fa19
6
+ metadata.gz: 46412825479d480b85bb248ac95c08f8428b8b8e95f0c1365ff5430377d197cfcf9faf1a3ba83f94fccb34ee4bf5c9c19ee43d3d2b49a88ec53549096a148c9d
7
+ data.tar.gz: 012bbf16df86ae556196514c59c21b963d9300a82245663ec0ae2eee0c007e66ceac20e21dba0072d9abd3cfac81af36ee82dd109864883cca6af97f80b2a38a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- high_voltage (2.0.0)
4
+ high_voltage (2.1.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -21,13 +21,6 @@ GEM
21
21
  childprocess (0.3.9)
22
22
  ffi (~> 1.0, >= 1.0.11)
23
23
  coderay (1.0.9)
24
- columnize (0.3.6)
25
- debugger (1.6.1)
26
- columnize (>= 0.3.1)
27
- debugger-linecache (~> 1.2.0)
28
- debugger-ruby_core_source (~> 1.2.3)
29
- debugger-linecache (1.2.0)
30
- debugger-ruby_core_source (1.2.3)
31
24
  diff-lcs (1.1.3)
32
25
  ffi (1.9.0)
33
26
  method_source (0.8.1)
@@ -40,9 +33,6 @@ GEM
40
33
  coderay (~> 1.0.5)
41
34
  method_source (~> 0.8)
42
35
  slop (~> 3.4)
43
- pry-debugger (0.2.2)
44
- debugger (~> 1.3)
45
- pry (~> 0.9.10)
46
36
  rack (1.5.2)
47
37
  rack-test (0.6.2)
48
38
  rack (>= 1.0)
@@ -76,5 +66,5 @@ DEPENDENCIES
76
66
  appraisal
77
67
  capybara (= 2.0.3)
78
68
  high_voltage!
79
- pry-debugger
69
+ pry
80
70
  rspec-rails
data/NEWS.md CHANGED
@@ -1,3 +1,9 @@
1
+ New for 2.1.0:
2
+ + Extract configuration options into a module
3
+ + Add ability to configure whether layout is cached with action_caching
4
+ + Add ability to configure a `home_page` for root routing to High Voltage
5
+ + Update README with new block style config
6
+
1
7
  New for 2.0.0:
2
8
  + Extract PagesController into a module
3
9
  + Update README with module usage instructions
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'
18
+ gem 'high_voltage', '~> 2.1.0'
19
19
  ```
20
20
 
21
21
  For Rails versions prior to 3.0, use the 0.9.2 tag of high_voltage:
@@ -43,7 +43,9 @@ link_to 'Q4 Reports', page_path('about/corporate/policies/HR/en_US/biz/sales/Qua
43
43
 
44
44
  Bam.
45
45
 
46
- ## Routes
46
+ ## Configuration
47
+
48
+ #### Routing overview
47
49
 
48
50
  By default, the static page routes will be like /pages/:id (where :id is the view filename).
49
51
 
@@ -55,39 +57,28 @@ get 'pages/home' => 'high_voltage/pages#show', id: 'home'
55
57
 
56
58
  In that case, you'd need an `app/views/pages/home.html.erb` file.
57
59
 
58
- Generally speaking, you need to route to the 'show' action with an :id param of the view filename.
60
+ Generally speaking, you need to route to the 'show' action with an `:id` param of the view filename.
59
61
 
60
- High Voltage will generate a named route method of `page_path` which you can use, as well. If you
61
- want to generate a named route (with the :as routing option) for some route which will be handled
62
- by High Voltage, make sure not to use :page as the name, because that will conflict with the named
63
- route generated by High Voltage itself.
62
+ High Voltage will generate a named route method of `page_path`. If you want to generate
63
+ your own named route (with the :as routing option), make sure not to use `:page`
64
+ as it will conflict with the High Voltage named route.
64
65
 
65
66
  #### Specifying a root path
66
67
 
67
- You can route the root route to a High Voltage page like this:
68
-
69
- ```ruby
70
- root :to => 'high_voltage/pages#show', id: 'home'
71
- ```
72
-
73
- Which will render a homepage from app/views/pages/home.html.erb
74
-
75
- #### Page titles and meta-data
76
-
77
- We suggest using `content_for` and `yield` for setting custom page titles and
78
- meta-data on High Voltage pages.
68
+ You can configure the root route to a High Voltage page like this:
79
69
 
80
70
  ```ruby
81
- # app/views/pages/about.html.erb
82
- <%= content_for :page_title, 'About Us - Custom page title' %>
71
+ # config/initializers/high_voltage.rb
72
+ HighVoltage.configure do |config|
73
+ config.home_page = 'home'
74
+ end
83
75
  ```
84
76
 
85
- Then print the contents of `:title` into the layout:
77
+ Which will render the page from `app/views/pages/home.html.erb` when the '/'
78
+ route of the site is accessed.
86
79
 
87
- ```ruby
88
- # app/views/layouts/application.html.erb
89
- <title><%= yield(:page_title) %></title>
90
- ```
80
+ Note: High Voltage also creates a search engine friendly 301 redirect. Any attempt to
81
+ access the path '/home' will be redirected to '/'.
91
82
 
92
83
  #### Top-level routes
93
84
 
@@ -102,23 +93,42 @@ Would look for corresponding files:
102
93
  app/views/pages/about.html.erb
103
94
  app/views/pages/company.html.erb
104
95
 
105
- This is accomplished by changing the `HighVoltage.route_drawer` to `HighVoltage::RouteDrawers::Root`
96
+ This is accomplished by setting the `route_drawer` to `HighVoltage::RouteDrawers::Root`
106
97
 
107
98
  ```ruby
108
99
  # config/initializers/high_voltage.rb
109
- HighVoltage.route_drawer = HighVoltage::RouteDrawers::Root
100
+ HighVoltage.configure do |config|
101
+ config.route_drawer = HighVoltage::RouteDrawers::Root
102
+ end
110
103
  ```
111
104
 
112
105
  #### Disabling routes
113
106
 
114
- The default routes can be completely removed by changing the `HighVoltage.routes`
115
- to `false`:
107
+ The default routes can be completely removed by setting the `routes` to `false`:
116
108
 
117
109
  ```ruby
118
110
  # config/initializers/high_voltage.rb
119
- HighVoltage.routes = false
111
+ HighVoltage.configure do |config|
112
+ config.routes = false
113
+ end
114
+ ```
115
+
116
+ #### Page titles and meta-data
117
+
118
+ We suggest using `content_for` and `yield` for setting custom page titles and
119
+ meta-data on High Voltage pages.
120
+
121
+ ```ruby
122
+ # app/views/pages/about.html.erb
123
+ <%= content_for :page_title, 'About Us - Custom page title' %>
120
124
  ```
121
125
 
126
+ Then print the contents of `:title` into the layout:
127
+
128
+ ```ruby
129
+ # app/views/layouts/application.html.erb
130
+ <title><%= yield(:page_title) %></title>
131
+ ```
122
132
  #### Content path
123
133
 
124
134
  High Voltage uses a default path and folder of 'pages', i.e. 'url.com/pages/contact',
@@ -128,20 +138,32 @@ You can change this in an initializer:
128
138
 
129
139
  ```ruby
130
140
  # config/initializers/high_voltage.rb
131
- HighVoltage.content_path = 'site/'
141
+ HighVoltage.configure do |config|
142
+ config.content_path = 'site/'
143
+ end
132
144
  ```
133
145
 
134
146
  #### Caching
135
147
 
136
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).
137
149
 
138
- To enable them you can add the following to your initializer:
150
+ To enable action-caching you can add the following to your initializer:
139
151
 
140
152
  ```ruby
141
153
  # config/initializers/high_voltage.rb
142
- HighVoltage.action_caching = true
143
- # OR
144
- HighVoltage.page_caching = true
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
145
167
  ```
146
168
 
147
169
  High Voltage will use your default cache store to store action caches.
@@ -170,17 +192,19 @@ Disable the default routes:
170
192
 
171
193
  ```ruby
172
194
  # config/initializers/high_voltage.rb
173
- HighVoltage.routes = false
195
+ HighVoltage.configure do |config|
196
+ config.routes = false
197
+ end
174
198
  ```
175
199
 
176
200
  Define a route for the new `PagesController`:
177
201
 
178
202
  ```ruby
179
203
  # config/routes.rb
180
- get "/pages/*id" => 'pages#show', :as => :page, :format => false
204
+ get "/pages/*id" => 'pages#show', as: :page, format: false
181
205
 
182
206
  # if routing the root path, update for your controller
183
- root :to => 'pages#show', :id => 'home'
207
+ root to: 'pages#show', id: 'home'
184
208
  ```
185
209
 
186
210
  Then modify new `PagesController` to include the High Voltage static page concern:
@@ -253,7 +277,7 @@ describe PagesController, '#show' do
253
277
  %w(earn_money screencast about contact).each do |page|
254
278
  context 'on GET to /pages/#{page}' do
255
279
  before do
256
- get :show, :id => page
280
+ get :show, id: page
257
281
  end
258
282
 
259
283
  it { should respond_with(:success) }
@@ -13,7 +13,8 @@ module HighVoltage::StaticPage
13
13
  end
14
14
 
15
15
  if respond_to?(:caches_action)
16
- caches_action :show, if: -> { HighVoltage.action_caching }
16
+ caches_action :show, layout: HighVoltage.action_caching_layout,
17
+ if: -> { HighVoltage.action_caching }
17
18
  end
18
19
 
19
20
  if respond_to?(:caches_page)
data/config/routes.rb CHANGED
@@ -1,4 +1,9 @@
1
1
  Rails.application.routes.draw do
2
+ if HighVoltage.home_page
3
+ get "/#{HighVoltage.home_page}", to: redirect('/')
4
+ root to: 'high_voltage/pages#show', id: HighVoltage.home_page
5
+ end
6
+
2
7
  if HighVoltage.routes
3
8
  get HighVoltage.route_drawer.match_attributes
4
9
  end
data/high_voltage.gemspec CHANGED
@@ -19,6 +19,6 @@ Gem::Specification.new do |s|
19
19
  s.add_development_dependency("activesupport", ">= 3.1.0")
20
20
  s.add_development_dependency("appraisal")
21
21
  s.add_development_dependency("capybara", "= 2.0.3")
22
- s.add_development_dependency("pry-debugger")
22
+ s.add_development_dependency("pry")
23
23
  s.add_development_dependency("rspec-rails")
24
24
  end
data/lib/high_voltage.rb CHANGED
@@ -1,32 +1,13 @@
1
- require 'high_voltage/version'
1
+ require 'active_support/core_ext/module/attribute_accessors'
2
+
3
+ require 'high_voltage/configuration'
2
4
  require 'high_voltage/constraints/root_route'
3
5
  require 'high_voltage/page_finder'
4
6
  require 'high_voltage/route_drawers/default'
5
7
  require 'high_voltage/route_drawers/root'
6
- require 'active_support/core_ext/module/attribute_accessors'
8
+ require 'high_voltage/version'
7
9
 
8
10
  module HighVoltage
9
- mattr_accessor :layout
10
- @@layout = 'application'
11
-
12
- mattr_accessor :content_path
13
- @@content_path = 'pages/'
14
-
15
- mattr_accessor :route_drawer
16
- @@route_drawer = HighVoltage::RouteDrawers::Default
17
-
18
- mattr_accessor :routes
19
- @@routes = true
20
-
21
- mattr_accessor :action_caching
22
- @@action_caching = false
23
-
24
- mattr_accessor :page_caching
25
- @@page_caching = false
26
-
27
- def self.setup
28
- yield self
29
- end
30
-
11
+ extend Configuration
31
12
  require 'high_voltage/engine' if defined?(Rails)
32
13
  end
@@ -0,0 +1,33 @@
1
+ module HighVoltage
2
+ module Configuration
3
+ attr_accessor(
4
+ :action_caching,
5
+ :action_caching_layout,
6
+ :content_path,
7
+ :home_page,
8
+ :layout,
9
+ :page_caching,
10
+ :route_drawer,
11
+ :routes,
12
+ )
13
+
14
+ def configure
15
+ yield self
16
+ end
17
+
18
+ def self.extended(base)
19
+ base.set_default_configuration
20
+ end
21
+
22
+ def set_default_configuration
23
+ self.action_caching = false
24
+ self.action_caching_layout = true
25
+ self.content_path = 'pages/'
26
+ self.home_page = nil
27
+ self.layout = 'application'
28
+ self.page_caching = false
29
+ self.route_drawer = HighVoltage::RouteDrawers::Default
30
+ self.routes = true
31
+ end
32
+ end
33
+ end
@@ -1,3 +1,3 @@
1
1
  module HighVoltage
2
- VERSION = '2.0.0'.freeze
2
+ VERSION = '2.1.0'.freeze
3
3
  end
@@ -1,23 +1,27 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe HighVoltage::PagesController, 'action_caching' do
4
- it 'caches the action when action_caching is set to true', enable_caching: true do
5
- expect do
3
+ describe HighVoltage::PagesController, '#action_caching' do
4
+ let(:page_name) { :exists }
5
+
6
+ context 'action_caching set to true' do
7
+ it 'caches the action', enable_caching: true do
6
8
  HighVoltage.action_caching = true
7
9
  concern_reload
8
- get :show, id: :exists
9
- end.to change { action_was_cached(:exists) }
10
+
11
+ expect { get :show, id: page_name }.to change { action_cache_exists? }
12
+ end
10
13
  end
11
14
 
12
- it 'does not cache the action when action_caching is set to false', enable_caching: true do
13
- expect do
15
+ context 'action_caching set to false' do
16
+ it 'does not cache the action', enable_caching: true do
14
17
  HighVoltage.action_caching = false
15
18
  concern_reload
16
- get :show, id: :exists
17
- end.to_not change { action_was_cached(:exists) }
19
+
20
+ expect { get :show, id: page_name }.to_not change { action_cache_exists? }
21
+ end
18
22
  end
19
23
 
20
- def action_was_cached(page)
21
- ActionController::Base.cache_store.exist?("views/test.host#{page_path(page)}")
24
+ def action_cache_exists?
25
+ ActionController::Base.cache_store.exist?("views/test.host#{page_path(page_name)}")
22
26
  end
23
27
  end
@@ -1,20 +1,28 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe HighVoltage::PagesController, 'action_caching' do
4
- it 'caches the page when page_caching is set to true', enable_caching: true do
5
- controller.should_receive(:cache_page).at_least(:once)
3
+ describe HighVoltage::PagesController, '#cache_page' do
4
+ let(:page_name) { :exists }
6
5
 
7
- HighVoltage.page_caching = true
8
- concern_reload
9
- get :show, id: :exists
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
10
+
11
+ controller.should_receive(:cache_page).at_least(:once)
12
+
13
+ get :show, id: page_name
14
+ end
10
15
  end
11
16
 
12
- it 'does not cache the page when page_caching is set to false', enable_caching: true do
13
- controller.should_receive(:cache_page).never
17
+ 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
14
23
 
15
- HighVoltage.page_caching = false
16
- concern_reload
17
- get :show, id: :exists
24
+ get :show, id: page_name
25
+ end
18
26
  end
19
27
  end
20
28
 
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require 'spec_helper'
3
2
 
4
3
  describe HighVoltage::PagesController do
@@ -50,15 +49,10 @@ describe HighVoltage::PagesController do
50
49
  end
51
50
 
52
51
  context 'using custom layout' do
53
- before(:all) do
54
- @original_layout = HighVoltage.layout
52
+ before(:each) do
55
53
  HighVoltage.layout = 'alternate'
56
54
  end
57
55
 
58
- after(:all) do
59
- HighVoltage.layout = @original_layout
60
- end
61
-
62
56
  describe 'on GET to /pages/exists' do
63
57
  before { get :show, :id => 'exists' }
64
58
 
@@ -70,13 +64,9 @@ describe HighVoltage::PagesController do
70
64
  end
71
65
 
72
66
  context 'using custom content path' do
73
- before(:all) do
74
- @original_content_path = HighVoltage.content_path
67
+ before(:each) do
75
68
  HighVoltage.content_path = 'other_pages/'
76
- end
77
-
78
- after(:all) do
79
- HighVoltage.content_path = @original_content_path
69
+ Rails.application.reload_routes!
80
70
  end
81
71
 
82
72
  describe 'on GET to /other_pages/also_exists' do
File without changes
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
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
15
+ end
16
+ end
17
+
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 }
25
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Home page route' do
4
+ before(:each) do
5
+ HighVoltage.home_page = 'home'
6
+ Rails.application.reload_routes!
7
+ end
8
+
9
+ it 'redirects the duplicate content to root' do
10
+ get '/home'
11
+ expect(response).to redirect_to('/')
12
+ end
13
+ end
@@ -1,42 +1,38 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'routes' do
4
- context 'using default configuration' do
5
- it 'should generate normal resource route with id' do
4
+ context 'default configuration' do
5
+ it 'generates a route' do
6
6
  page_path('one').should eq '/pages/one'
7
7
  end
8
8
 
9
- it 'should generate normal resource route with string' do
10
- page_path('one').should eq '/pages/one'
11
- end
12
-
13
- it 'should generate nested route with string' do
9
+ it 'generates a nested route' do
14
10
  page_path('one/two').should eq '/pages/one/two'
15
11
  end
16
12
 
17
- it 'should recognize nested route' do
13
+ it 'recognizes a route' do
18
14
  assert_recognizes(
19
15
  {
20
16
  :controller => 'high_voltage/pages',
21
17
  :action => 'show',
22
- :id => 'one/two'
18
+ :id => 'one'
23
19
  },
24
- '/pages/one/two'
20
+ '/pages/one'
25
21
  )
26
22
  end
27
23
 
28
- it 'should recognize normal route' do
24
+ it 'recognizes a nested route' do
29
25
  assert_recognizes(
30
26
  {
31
27
  :controller => 'high_voltage/pages',
32
28
  :action => 'show',
33
- :id => 'one'
29
+ :id => 'one/two'
34
30
  },
35
- '/pages/one'
31
+ '/pages/one/two'
36
32
  )
37
33
  end
38
34
 
39
- it 'should recognize normal route with dots' do
35
+ it 'recognizes a route with dots' do
40
36
  assert_recognizes(
41
37
  {
42
38
  :controller => 'high_voltage/pages',
@@ -49,69 +45,57 @@ describe 'routes' do
49
45
  end
50
46
 
51
47
  context 'using top-level routing configuration' do
52
- around do |example|
53
- cached_high_voltage_route_drawer = HighVoltage.route_drawer
48
+ before(:each) do
54
49
  HighVoltage.route_drawer = HighVoltage::RouteDrawers::Root
55
50
  Rails.application.reload_routes!
56
-
57
- example.run
58
-
59
- HighVoltage.route_drawer = cached_high_voltage_route_drawer
60
- Rails.application.reload_routes!
61
51
  end
62
52
 
63
- it 'should generate normal resource route with string' do
53
+ it 'generates a route' do
64
54
  page_path('one').should eq '/one'
65
55
  end
66
56
 
67
- it 'should generate nested route with string' do
57
+ it 'generates a nested route' do
68
58
  page_path('one/two').should eq '/one/two'
69
59
  end
70
60
  end
71
61
 
72
- context 'using a custom content_path' do
73
- around do |example|
74
- cached_high_voltage_content_path = HighVoltage.content_path
62
+ context 'custom content path' do
63
+ before(:each) do
75
64
  HighVoltage.content_path = 'other_pages/'
76
65
  Rails.application.reload_routes!
77
-
78
- example.run
79
-
80
- HighVoltage.content_path = cached_high_voltage_content_path
81
- Rails.application.reload_routes!
82
66
  end
83
67
 
84
- it 'should generate normal resource route with string' do
68
+ it 'generates a route' do
85
69
  page_path('one').should eq '/other_pages/one'
86
70
  end
87
71
 
88
- it 'should generate nested route with string' do
72
+ it 'generates a nested route' do
89
73
  page_path('one/two').should eq '/other_pages/one/two'
90
74
  end
91
75
 
92
- it 'should recognize nested route' do
76
+ it 'recognizes a route' do
93
77
  assert_recognizes(
94
78
  {
95
79
  :controller => 'high_voltage/pages',
96
80
  :action => 'show',
97
- :id => 'one/two'
81
+ :id => 'one'
98
82
  },
99
- '/other_pages/one/two'
83
+ '/other_pages/one'
100
84
  )
101
85
  end
102
86
 
103
- it 'should recognize normal route' do
87
+ it 'recognizes a nested route' do
104
88
  assert_recognizes(
105
89
  {
106
90
  :controller => 'high_voltage/pages',
107
91
  :action => 'show',
108
- :id => 'one'
92
+ :id => 'one/two'
109
93
  },
110
- '/other_pages/one'
94
+ '/other_pages/one/two'
111
95
  )
112
96
  end
113
97
 
114
- it 'should recognize normal route with dots' do
98
+ it 'recognizes a route with dots' do
115
99
  assert_recognizes(
116
100
  {
117
101
  :controller => 'high_voltage/pages',
@@ -123,19 +107,33 @@ describe 'routes' do
123
107
  end
124
108
  end
125
109
 
126
- context 'with default configuration disabled' do
127
- around do |example|
128
- cached_high_voltage_routes = HighVoltage.routes
129
- HighVoltage.routes = false
110
+ context 'home page route' do
111
+ it 'recognizes the root route' do
112
+ HighVoltage.home_page = 'home'
130
113
  Rails.application.reload_routes!
131
114
 
132
- example.run
115
+ assert_recognizes(
116
+ {
117
+ :controller => 'high_voltage/pages',
118
+ :action => 'show',
119
+ :id => 'home'
120
+ },
121
+ '/'
122
+ )
123
+ end
124
+ end
133
125
 
134
- HighVoltage.routes = cached_high_voltage_routes
135
- Rails.application.reload_routes!
126
+ context 'no home page route' do
127
+ it 'does generate a home page route' do
128
+ { :get => '/' }.should_not be_routable
136
129
  end
130
+ end
131
+
132
+ context 'disabled routes' do
133
+ it 'does not recognize routes' do
134
+ HighVoltage.routes = false
135
+ Rails.application.reload_routes!
137
136
 
138
- it 'should not recognize routes' do
139
137
  { :get => '/pages/one/two' }.should_not be_routable
140
138
  end
141
139
  end
data/spec/spec_helper.rb CHANGED
@@ -1,19 +1,26 @@
1
1
  ENV['RAILS_ENV'] = 'test'
2
2
 
3
- require File.expand_path("../dummy/config/environment.rb", __FILE__)
3
+ require File.expand_path('../dummy/config/environment.rb', __FILE__)
4
+
5
+ require 'capybara/rails'
4
6
  require 'pry'
5
7
  require 'rails/test_help'
8
+ require 'rspec/expectations'
6
9
  require 'rspec/rails'
7
- require 'capybara/rails'
8
10
 
9
11
  Rails.backtrace_cleaner.remove_silencers!
10
12
  Capybara.default_driver = :rack_test
11
13
  Capybara.default_selector = :css
12
14
 
13
- Dir[File.dirname(__FILE__) + '/support/**/*.rb'].each {|f| require f}
15
+ Dir[File.dirname(__FILE__) + '/support/**/*.rb'].each { |file| require file }
14
16
 
15
17
  RSpec.configure do |config|
16
- require 'rspec/expectations'
18
+ config.after(:each) do
19
+ HighVoltage.set_default_configuration
20
+ Rails.application.reload_routes!
21
+ end
22
+
17
23
  config.include RSpec::Matchers
18
24
  config.mock_with :rspec
25
+ config.order = 'random'
19
26
  end
@@ -1,12 +1,15 @@
1
1
  RSpec.configure do |config|
2
2
  config.around(:each, enable_caching: true) do |example|
3
+ previous_cache_store = ActionController::Base.cache_store
4
+
3
5
  ActionController::Base.perform_caching = true
4
- old_cache_store = ActionController::Base.cache_store
5
6
  ActionController::Base.cache_store = :memory_store
7
+ ActionController::Base.cache_store.clear
6
8
 
7
9
  example.run
8
10
 
9
- ActionController::Base.cache_store = old_cache_store
11
+ ActionController::Base.cache_store.clear
12
+ ActionController::Base.cache_store = previous_cache_store
10
13
  ActionController::Base.perform_caching = false
11
14
  end
12
15
  end
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.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Jankowski
@@ -16,34 +16,34 @@ authors:
16
16
  autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
- date: 2013-10-05 00:00:00.000000000 Z
19
+ date: 2013-12-30 00:00:00.000000000 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: activesupport
23
23
  requirement: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - '>='
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: 3.1.0
28
28
  type: :development
29
29
  prerelease: false
30
30
  version_requirements: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - '>='
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: 3.1.0
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: appraisal
37
37
  requirement: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  type: :development
43
43
  prerelease: false
44
44
  version_requirements: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - '>='
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0'
49
49
  - !ruby/object:Gem::Dependency
@@ -61,31 +61,31 @@ dependencies:
61
61
  - !ruby/object:Gem::Version
62
62
  version: 2.0.3
63
63
  - !ruby/object:Gem::Dependency
64
- name: pry-debugger
64
+ name: pry
65
65
  requirement: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - '>='
67
+ - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  type: :development
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - '>='
74
+ - - ">="
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  - !ruby/object:Gem::Dependency
78
78
  name: rspec-rails
79
79
  requirement: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - '>='
81
+ - - ">="
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  type: :development
85
85
  prerelease: false
86
86
  version_requirements: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - '>='
88
+ - - ">="
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  description: Fire in the disco. Fire in the ... taco bell.
@@ -95,8 +95,8 @@ executables: []
95
95
  extensions: []
96
96
  extra_rdoc_files: []
97
97
  files:
98
- - .gitignore
99
- - .travis.yml
98
+ - ".gitignore"
99
+ - ".travis.yml"
100
100
  - Appraisals
101
101
  - CONTRIBUTING.md
102
102
  - Gemfile
@@ -110,6 +110,7 @@ files:
110
110
  - config/routes.rb
111
111
  - high_voltage.gemspec
112
112
  - lib/high_voltage.rb
113
+ - lib/high_voltage/configuration.rb
113
114
  - lib/high_voltage/constraints/root_route.rb
114
115
  - lib/high_voltage/engine.rb
115
116
  - lib/high_voltage/page_finder.rb
@@ -165,12 +166,15 @@ files:
165
166
  - spec/dummy/public/javascripts/effects.js
166
167
  - spec/dummy/public/javascripts/prototype.js
167
168
  - spec/dummy/public/javascripts/rails.js
169
+ - spec/dummy/public/pages/exists.html
168
170
  - spec/dummy/public/stylesheets/.gitkeep
169
171
  - spec/dummy/script/rails
172
+ - spec/high_voltage/configuration_spec.rb
170
173
  - spec/high_voltage/page_finder_spec.rb
171
174
  - spec/high_voltage_spec.rb
172
175
  - spec/integration/navigation_spec.rb
173
176
  - spec/minimal_spec_helper.rb
177
+ - spec/requests/home_page_spec.rb
174
178
  - spec/routing/routes_spec.rb
175
179
  - spec/spec_helper.rb
176
180
  - spec/support/caching.rb
@@ -185,17 +189,17 @@ require_paths:
185
189
  - lib
186
190
  required_ruby_version: !ruby/object:Gem::Requirement
187
191
  requirements:
188
- - - '>='
192
+ - - ">="
189
193
  - !ruby/object:Gem::Version
190
194
  version: '0'
191
195
  required_rubygems_version: !ruby/object:Gem::Requirement
192
196
  requirements:
193
- - - '>='
197
+ - - ">="
194
198
  - !ruby/object:Gem::Version
195
199
  version: '0'
196
200
  requirements: []
197
201
  rubyforge_project:
198
- rubygems_version: 2.0.0
202
+ rubygems_version: 2.2.0
199
203
  signing_key:
200
204
  specification_version: 4
201
205
  summary: Simple static page rendering controller
@@ -249,12 +253,15 @@ test_files:
249
253
  - spec/dummy/public/javascripts/effects.js
250
254
  - spec/dummy/public/javascripts/prototype.js
251
255
  - spec/dummy/public/javascripts/rails.js
256
+ - spec/dummy/public/pages/exists.html
252
257
  - spec/dummy/public/stylesheets/.gitkeep
253
258
  - spec/dummy/script/rails
259
+ - spec/high_voltage/configuration_spec.rb
254
260
  - spec/high_voltage/page_finder_spec.rb
255
261
  - spec/high_voltage_spec.rb
256
262
  - spec/integration/navigation_spec.rb
257
263
  - spec/minimal_spec_helper.rb
264
+ - spec/requests/home_page_spec.rb
258
265
  - spec/routing/routes_spec.rb
259
266
  - spec/spec_helper.rb
260
267
  - spec/support/caching.rb