Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Items, Widget, and Gears controller spec examples
# Client required that *all* routes for controllers are covered and
# do not allow guest access.
#
# There are several other controllers that, for guest test coverage,
# are identical to the Items Controller spec below
# Note: there are several non-CRUD methods; destroy makes a record
# inactive; there is no record removal revealed via the API (client's request)
# spec/controllers/items_controller_spec.rb
require 'spec_helper'
describe ItemsController do
context 'guest' do
describe 'GET to index' do
before { get :index }
specify { response.should redirect_to(login_path) }
specify { flash.alert.should =~ /You must be logged in to access this page/ }
end
describe 'GET to show' do
before { get :show, :id => 1 }
specify { response.should redirect_to(login_path) }
specify { flash.alert.should =~ /You must be logged in to access this page/ }
end
describe 'GET to export' do
before { get :export }
specify { response.should redirect_to(login_path) }
specify { flash.alert.should =~ /You must be logged in to access this page/ }
end
describe 'GET to new' do
before { get :new }
specify { response.should redirect_to(login_path) }
specify { flash.alert.should =~ /You must be logged in to access this page/ }
end
describe 'POST to create' do
before { post :create }
specify { response.should redirect_to(login_path) }
specify { flash.alert.should =~ /You must be logged in to access this page/ }
end
describe 'GET to edit' do
before { get :edit, :id => 1 }
specify { response.should redirect_to(login_path) }
specify { flash.alert.should =~ /You must be logged in to access this page/ }
end
describe 'PUT to update' do
before { put :update, :id => 1 }
specify { response.should redirect_to(login_path) }
specify { flash.alert.should =~ /You must be logged in to access this page/ }
end
describe 'DELETE to destroy' do
before { delete :destroy, :id => 1 }
specify { response.should redirect_to(login_path) }
specify { flash.alert.should =~ /You must be logged in to access this page/ }
end
describe 'PUT to activate' do
before { put :activate, :id => 1 }
specify { response.should redirect_to(login_path) }
specify { flash.alert.should =~ /You must be logged in to access this page/ }
end
end
end
# spec/controllers/widgets_controller_spec.rb
require 'spec_helper'
describe WidgetsController do
context 'guest' do
# same code as ItemsControllerSpec above
end
end
# spec/controllers/gears_controller_spec.rb
require 'spec_helper'
describe GearsController do
context 'guest' do
# same code as ItemsControllerSpec above
end
end
# etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.