Commit 5f7da1db6fdee040837dcfa7f6dd202c67a137f3
Exists in
colab
and in
4 other branches
Merge pull request #227 from mezuro/tutorials_not_found
Handle invalid tutorial names
Showing
2 changed files
with
19 additions
and
5 deletions
Show diff stats
app/controllers/tutorials_controller.rb
spec/controllers/tutorials_controller_spec.rb
| ... | ... | @@ -2,13 +2,25 @@ require 'rails_helper' |
| 2 | 2 | |
| 3 | 3 | describe TutorialsController do |
| 4 | 4 | describe 'view' do |
| 5 | - let!(:name) { "analyzing" } | |
| 5 | + context 'with a valid name' do | |
| 6 | + let!(:name) { "analyzing" } | |
| 6 | 7 | |
| 7 | - before :each do | |
| 8 | - get :view, name: name | |
| 8 | + before :each do | |
| 9 | + get :view, name: name | |
| 10 | + end | |
| 11 | + | |
| 12 | + it { is_expected.to render_template(name) } | |
| 13 | + it { is_expected.to respond_with(:success) } | |
| 9 | 14 | end |
| 10 | 15 | |
| 11 | - it { is_expected.to render_template(name) } | |
| 12 | - it { is_expected.to respond_with(:success) } | |
| 16 | + context 'with a invalid name' do | |
| 17 | + let!(:name) { "invalid_name" } | |
| 18 | + | |
| 19 | + before :each do | |
| 20 | + get :view, name: name | |
| 21 | + end | |
| 22 | + | |
| 23 | + it { is_expected.to respond_with(:not_found) } | |
| 24 | + end | |
| 13 | 25 | end |
| 14 | 26 | end | ... | ... |