high_voltage 2.1.0 → 2.2.1

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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.travis.yml +19 -3
  4. data/Appraisals +2 -2
  5. data/Gemfile +2 -0
  6. data/Gemfile.lock +54 -46
  7. data/MIT-LICENSE +1 -1
  8. data/NEWS.md +11 -0
  9. data/README.md +28 -31
  10. data/Rakefile +9 -4
  11. data/config/routes.rb +1 -1
  12. data/gemfiles/rails3.1.gemfile +8 -0
  13. data/gemfiles/rails3.1.gemfile.lock +121 -0
  14. data/gemfiles/rails3.2.gemfile +8 -0
  15. data/gemfiles/rails3.2.gemfile.lock +119 -0
  16. data/gemfiles/rails4.0.gemfile +10 -0
  17. data/gemfiles/rails4.0.gemfile.lock +118 -0
  18. data/gemfiles/rails4.1.gemfile +10 -0
  19. data/gemfiles/rails4.1.gemfile.lock +124 -0
  20. data/high_voltage.gemspec +0 -2
  21. data/lib/high_voltage/configuration.rb +27 -6
  22. data/lib/high_voltage/engine.rb +12 -3
  23. data/lib/high_voltage/version.rb +1 -1
  24. data/lib/high_voltage.rb +1 -0
  25. data/spec/constraints/root_route_spec.rb +10 -14
  26. data/spec/controllers/action_caching_controller_spec.rb +21 -10
  27. data/spec/controllers/alternative_finder_controller_spec.rb +2 -2
  28. data/spec/controllers/page_caching_controller_spec.rb +19 -10
  29. data/spec/controllers/pages_controller_spec.rb +43 -53
  30. data/spec/controllers/subclassed_pages_controller_spec.rb +15 -21
  31. data/spec/dummy/config/environments/test.rb +2 -1
  32. data/spec/high_voltage/configuration_spec.rb +82 -19
  33. data/spec/high_voltage/page_finder_spec.rb +5 -5
  34. data/spec/high_voltage_spec.rb +3 -3
  35. data/spec/integration/navigation_spec.rb +2 -4
  36. data/spec/requests/home_page_spec.rb +1 -1
  37. data/spec/routing/routes_spec.rb +8 -8
  38. data/spec/spec_helper.rb +4 -3
  39. metadata +11 -35
  40. data/spec/support/caching.rb +0 -15
  41. data/spec/support/concern_reload.rb +0 -11
@@ -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
data/spec/spec_helper.rb CHANGED
@@ -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.1
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-07-23 00:00:00.000000000 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: activesupport
@@ -32,34 +32,6 @@ dependencies:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: 3.1.0
35
- - !ruby/object:Gem::Dependency
36
- name: appraisal
37
- requirement: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- version: '0'
42
- type: :development
43
- prerelease: false
44
- version_requirements: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
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
35
  - !ruby/object:Gem::Dependency
64
36
  name: pry
65
37
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +80,14 @@ files:
108
80
  - app/controllers/concerns/high_voltage/static_page.rb
109
81
  - app/controllers/high_voltage/pages_controller.rb
110
82
  - config/routes.rb
83
+ - gemfiles/rails3.1.gemfile
84
+ - gemfiles/rails3.1.gemfile.lock
85
+ - gemfiles/rails3.2.gemfile
86
+ - gemfiles/rails3.2.gemfile.lock
87
+ - gemfiles/rails4.0.gemfile
88
+ - gemfiles/rails4.0.gemfile.lock
89
+ - gemfiles/rails4.1.gemfile
90
+ - gemfiles/rails4.1.gemfile.lock
111
91
  - high_voltage.gemspec
112
92
  - lib/high_voltage.rb
113
93
  - lib/high_voltage/configuration.rb
@@ -177,8 +157,6 @@ files:
177
157
  - spec/requests/home_page_spec.rb
178
158
  - spec/routing/routes_spec.rb
179
159
  - spec/spec_helper.rb
180
- - spec/support/caching.rb
181
- - spec/support/concern_reload.rb
182
160
  homepage: http://github.com/thoughtbot/high_voltage
183
161
  licenses:
184
162
  - MIT
@@ -199,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
177
  version: '0'
200
178
  requirements: []
201
179
  rubyforge_project:
202
- rubygems_version: 2.2.0
180
+ rubygems_version: 2.2.2
203
181
  signing_key:
204
182
  specification_version: 4
205
183
  summary: Simple static page rendering controller
@@ -264,5 +242,3 @@ test_files:
264
242
  - spec/requests/home_page_spec.rb
265
243
  - spec/routing/routes_spec.rb
266
244
  - 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