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
@@ -0,0 +1,118 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ high_voltage (2.2.0)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ actionmailer (4.0.5)
10
+ actionpack (= 4.0.5)
11
+ mail (~> 2.5.4)
12
+ actionpack (4.0.5)
13
+ activesupport (= 4.0.5)
14
+ builder (~> 3.1.0)
15
+ erubis (~> 2.7.0)
16
+ rack (~> 1.5.2)
17
+ rack-test (~> 0.6.2)
18
+ actionpack-action_caching (1.1.1)
19
+ actionpack (>= 4.0.0, < 5.0)
20
+ actionpack-page_caching (1.0.2)
21
+ actionpack (>= 4.0.0, < 5)
22
+ activemodel (4.0.5)
23
+ activesupport (= 4.0.5)
24
+ builder (~> 3.1.0)
25
+ activerecord (4.0.5)
26
+ activemodel (= 4.0.5)
27
+ activerecord-deprecated_finders (~> 1.0.2)
28
+ activesupport (= 4.0.5)
29
+ arel (~> 4.0.0)
30
+ activerecord-deprecated_finders (1.0.3)
31
+ activesupport (4.0.5)
32
+ i18n (~> 0.6, >= 0.6.9)
33
+ minitest (~> 4.2)
34
+ multi_json (~> 1.3)
35
+ thread_safe (~> 0.1)
36
+ tzinfo (~> 0.3.37)
37
+ appraisal (1.0.0)
38
+ bundler
39
+ rake
40
+ thor (>= 0.14.0)
41
+ arel (4.0.2)
42
+ builder (3.1.4)
43
+ coderay (1.1.0)
44
+ diff-lcs (1.2.5)
45
+ erubis (2.7.0)
46
+ hike (1.2.3)
47
+ i18n (0.6.11)
48
+ mail (2.5.4)
49
+ mime-types (~> 1.16)
50
+ treetop (~> 1.4.8)
51
+ method_source (0.8.2)
52
+ mime-types (1.25.1)
53
+ minitest (4.7.5)
54
+ multi_json (1.10.1)
55
+ polyglot (0.3.5)
56
+ pry (0.10.0)
57
+ coderay (~> 1.1.0)
58
+ method_source (~> 0.8.1)
59
+ slop (~> 3.4)
60
+ rack (1.5.2)
61
+ rack-test (0.6.2)
62
+ rack (>= 1.0)
63
+ rails (4.0.5)
64
+ actionmailer (= 4.0.5)
65
+ actionpack (= 4.0.5)
66
+ activerecord (= 4.0.5)
67
+ activesupport (= 4.0.5)
68
+ bundler (>= 1.3.0, < 2.0)
69
+ railties (= 4.0.5)
70
+ sprockets-rails (~> 2.0.0)
71
+ railties (4.0.5)
72
+ actionpack (= 4.0.5)
73
+ activesupport (= 4.0.5)
74
+ rake (>= 0.8.7)
75
+ thor (>= 0.18.1, < 2.0)
76
+ rake (10.3.2)
77
+ rspec-core (2.14.8)
78
+ rspec-expectations (2.14.5)
79
+ diff-lcs (>= 1.1.3, < 2.0)
80
+ rspec-mocks (2.14.6)
81
+ rspec-rails (2.14.2)
82
+ actionpack (>= 3.0)
83
+ activemodel (>= 3.0)
84
+ activesupport (>= 3.0)
85
+ railties (>= 3.0)
86
+ rspec-core (~> 2.14.0)
87
+ rspec-expectations (~> 2.14.0)
88
+ rspec-mocks (~> 2.14.0)
89
+ slop (3.5.0)
90
+ sprockets (2.12.0)
91
+ hike (~> 1.2)
92
+ multi_json (~> 1.0)
93
+ rack (~> 1.0)
94
+ tilt (~> 1.1, != 1.3.0)
95
+ sprockets-rails (2.0.1)
96
+ actionpack (>= 3.0)
97
+ activesupport (>= 3.0)
98
+ sprockets (~> 2.8)
99
+ thor (0.19.1)
100
+ thread_safe (0.3.4)
101
+ tilt (1.4.1)
102
+ treetop (1.4.15)
103
+ polyglot
104
+ polyglot (>= 0.3.1)
105
+ tzinfo (0.3.39)
106
+
107
+ PLATFORMS
108
+ ruby
109
+
110
+ DEPENDENCIES
111
+ actionpack-action_caching
112
+ actionpack-page_caching
113
+ activesupport (>= 3.1.0)
114
+ appraisal
115
+ high_voltage!
116
+ pry
117
+ rails (~> 4.0.0)
118
+ rspec-rails
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rails", "~> 4.1.0"
7
+ gem "actionpack-action_caching"
8
+ gem "actionpack-page_caching"
9
+
10
+ gemspec :path => "../"
@@ -0,0 +1,124 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ high_voltage (2.2.0)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ actionmailer (4.1.4)
10
+ actionpack (= 4.1.4)
11
+ actionview (= 4.1.4)
12
+ mail (~> 2.5.4)
13
+ actionpack (4.1.4)
14
+ actionview (= 4.1.4)
15
+ activesupport (= 4.1.4)
16
+ rack (~> 1.5.2)
17
+ rack-test (~> 0.6.2)
18
+ actionpack-action_caching (1.1.1)
19
+ actionpack (>= 4.0.0, < 5.0)
20
+ actionpack-page_caching (1.0.2)
21
+ actionpack (>= 4.0.0, < 5)
22
+ actionview (4.1.4)
23
+ activesupport (= 4.1.4)
24
+ builder (~> 3.1)
25
+ erubis (~> 2.7.0)
26
+ activemodel (4.1.4)
27
+ activesupport (= 4.1.4)
28
+ builder (~> 3.1)
29
+ activerecord (4.1.4)
30
+ activemodel (= 4.1.4)
31
+ activesupport (= 4.1.4)
32
+ arel (~> 5.0.0)
33
+ activesupport (4.1.4)
34
+ i18n (~> 0.6, >= 0.6.9)
35
+ json (~> 1.7, >= 1.7.7)
36
+ minitest (~> 5.1)
37
+ thread_safe (~> 0.1)
38
+ tzinfo (~> 1.1)
39
+ appraisal (1.0.0)
40
+ bundler
41
+ rake
42
+ thor (>= 0.14.0)
43
+ arel (5.0.1.20140414130214)
44
+ builder (3.2.2)
45
+ coderay (1.1.0)
46
+ diff-lcs (1.2.5)
47
+ erubis (2.7.0)
48
+ hike (1.2.3)
49
+ i18n (0.6.11)
50
+ json (1.8.1)
51
+ mail (2.5.4)
52
+ mime-types (~> 1.16)
53
+ treetop (~> 1.4.8)
54
+ method_source (0.8.2)
55
+ mime-types (1.25.1)
56
+ minitest (5.4.0)
57
+ multi_json (1.10.1)
58
+ polyglot (0.3.5)
59
+ pry (0.10.0)
60
+ coderay (~> 1.1.0)
61
+ method_source (~> 0.8.1)
62
+ slop (~> 3.4)
63
+ rack (1.5.2)
64
+ rack-test (0.6.2)
65
+ rack (>= 1.0)
66
+ rails (4.1.4)
67
+ actionmailer (= 4.1.4)
68
+ actionpack (= 4.1.4)
69
+ actionview (= 4.1.4)
70
+ activemodel (= 4.1.4)
71
+ activerecord (= 4.1.4)
72
+ activesupport (= 4.1.4)
73
+ bundler (>= 1.3.0, < 2.0)
74
+ railties (= 4.1.4)
75
+ sprockets-rails (~> 2.0)
76
+ railties (4.1.4)
77
+ actionpack (= 4.1.4)
78
+ activesupport (= 4.1.4)
79
+ rake (>= 0.8.7)
80
+ thor (>= 0.18.1, < 2.0)
81
+ rake (10.3.2)
82
+ rspec-core (2.14.8)
83
+ rspec-expectations (2.14.5)
84
+ diff-lcs (>= 1.1.3, < 2.0)
85
+ rspec-mocks (2.14.6)
86
+ rspec-rails (2.14.2)
87
+ actionpack (>= 3.0)
88
+ activemodel (>= 3.0)
89
+ activesupport (>= 3.0)
90
+ railties (>= 3.0)
91
+ rspec-core (~> 2.14.0)
92
+ rspec-expectations (~> 2.14.0)
93
+ rspec-mocks (~> 2.14.0)
94
+ slop (3.5.0)
95
+ sprockets (2.12.0)
96
+ hike (~> 1.2)
97
+ multi_json (~> 1.0)
98
+ rack (~> 1.0)
99
+ tilt (~> 1.1, != 1.3.0)
100
+ sprockets-rails (2.1.3)
101
+ actionpack (>= 3.0)
102
+ activesupport (>= 3.0)
103
+ sprockets (~> 2.8)
104
+ thor (0.19.1)
105
+ thread_safe (0.3.4)
106
+ tilt (1.4.1)
107
+ treetop (1.4.15)
108
+ polyglot
109
+ polyglot (>= 0.3.1)
110
+ tzinfo (1.2.1)
111
+ thread_safe (~> 0.1)
112
+
113
+ PLATFORMS
114
+ ruby
115
+
116
+ DEPENDENCIES
117
+ actionpack-action_caching
118
+ actionpack-page_caching
119
+ activesupport (>= 3.1.0)
120
+ appraisal
121
+ high_voltage!
122
+ pry
123
+ rails (~> 4.1.0)
124
+ rspec-rails
data/high_voltage.gemspec CHANGED
@@ -17,8 +17,6 @@ Gem::Specification.new do |s|
17
17
  s.require_paths = ["lib"]
18
18
 
19
19
  s.add_development_dependency("activesupport", ">= 3.1.0")
20
- s.add_development_dependency("appraisal")
21
- s.add_development_dependency("capybara", "= 2.0.3")
22
20
  s.add_development_dependency("pry")
23
21
  s.add_development_dependency("rspec-rails")
24
22
  end
@@ -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,22 @@
1
1
  module HighVoltage
2
2
  class Engine < Rails::Engine
3
- initializer 'Require concerns path' do |app|
4
- concerns_path = 'app/controllers/concerns'
3
+ initializer "Set up default parent engine" do |app|
4
+ HighVoltage.parent_engine ||= Rails.application
5
+ end
6
+
7
+ initializer "Require concerns path" do |app|
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
13
+ end
9
14
 
10
- require 'concerns/high_voltage/static_page'
15
+ initializer "Require for Rails 3" do |app|
16
+ if defined?(Rails) && Rails::VERSION::MAJOR == 3
17
+ require "concerns/high_voltage/static_page"
18
+ require "high_voltage/pages_controller"
19
+ end
11
20
  end
12
21
  end
13
22
  end
@@ -1,3 +1,3 @@
1
1
  module HighVoltage
2
- VERSION = '2.1.0'.freeze
2
+ VERSION = "2.2.1".freeze
3
3
  end
data/lib/high_voltage.rb CHANGED
@@ -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,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