-
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test against Rails 5 release instead of Beta
Rails 5 raises a `ActionView::Template::Error` instead of `ActionView::MissingTemplate` when a partial is missing now. This adds a shim to handle the difference in testing across different versions of Rails.
- Loading branch information
Damian Galarza
committed
Dec 5, 2016
1 parent
cbab60f
commit 3ed17de
Showing
10 changed files
with
58 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ source "https://rubygems.org" | |
gemspec | ||
|
||
gem "appraisal" | ||
gem "rspec-rails", "~> 3.2" | ||
gem "rspec-rails", "~> 3.5.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
require 'spec_helper' | ||
require "spec_helper" | ||
|
||
describe SubclassedPagesController do | ||
render_views | ||
|
||
describe 'on GET to /subclassed_pages/also_exists' do | ||
before { get :show, :id => 'also_exists' } | ||
describe "on GET to /subclassed_pages/also_exists" do | ||
before { get :show, id: "also_exists" } | ||
|
||
it 'responds with success and render template' do | ||
it "responds with success and render template" do | ||
expect(response).to be_succes | ||
expect(response).to render_template('also_exists') | ||
expect(response).to render_template("also_exists") | ||
end | ||
|
||
it 'uses the custom configured layout' do | ||
expect(response).not_to render_template('layouts/application') | ||
expect(response).to render_template('layouts/alternate') | ||
it "uses the custom configured layout" do | ||
expect(response).not_to render_template("layouts/application") | ||
expect(response).to render_template("layouts/alternate") | ||
end | ||
end | ||
|
||
it 'raises a routing error for an invalid page' do | ||
expect { get :show, id: 'invalid' } | ||
.to raise_error(ActionController::RoutingError) | ||
expect { get :show, id: "invalid" }. | ||
to raise_error(ActionController::RoutingError) | ||
end | ||
|
||
it 'raises a routing error for a page in another directory' do | ||
expect { get :show, id: '../other/wrong' } | ||
.to raise_error(ActionController::RoutingError) | ||
expect { get :show, id: "../other/wrong" }. | ||
to raise_error(ActionController::RoutingError) | ||
end | ||
|
||
it 'raises a missing template error for valid page with invalid partial' do | ||
expect { get :show, id: 'also_exists_but_references_nonexistent_partial' } | ||
.to raise_error(ActionView::MissingTemplate) | ||
expect { get :show, id: "also_exists_but_references_nonexistent_partial" }. | ||
to raise_error(missing_template_error) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module MissingTemplateErrorShim | ||
def missing_template_error | ||
if Rails::VERSION::MAJOR >= 5 | ||
ActionView::Template::Error | ||
else | ||
ActionView::MissingTemplate | ||
end | ||
end | ||
end | ||
|
||
RSpec.configure do |config| | ||
config.include MissingTemplateErrorShim, type: :controller | ||
end |