Skip to content

Instantly share code, notes, and snippets.

@rzane
Created June 16, 2022 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rzane/c3753b4ab34b58948a410634f03f1493 to your computer and use it in GitHub Desktop.
Save rzane/c3753b4ab34b58948a410634f03f1493 to your computer and use it in GitHub Desktop.
Writing a controller spec outside of a Rails application
require 'spec_helper'
require 'rails'
require 'action_view'
require 'action_controller'
require 'rspec/rails'
class TestApplication < Rails::Application
end
RSpec.describe 'example', type: :controller do
controller do
def index
head :ok
end
end
it 'works' do
get :index
expect(response).to have_http_status(:ok)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment