Skip to content

Instantly share code, notes, and snippets.

@josegomezr
Created June 1, 2023 15:21
Show Gist options
  • Save josegomezr/3ffdbb049eb28fa38984182ba1aaf40d to your computer and use it in GitHub Desktop.
Save josegomezr/3ffdbb049eb28fa38984182ba1aaf40d to your computer and use it in GitHub Desktop.
Reminder for myself: self contained file for making quick isolated rails tests
#!/usr/bin/env ruby
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'rails', '~> 6.1'
gem 'byebug'
end
require "action_dispatch/railtie"
require "action_controller/railtie"
class TestApp < Rails::Application
routes.draw do
get '/random', to: 'sample#index'
end
end
class SampleController < ActionController::Base
def index
end
end
require "minitest/autorun"
class BugTest < ActionDispatch::IntegrationTest
def test_association_stuff
assert_recognizes({controller: 'sample', action: 'index'}, 'random')
end
def setup
@routes = app.routes
end
private
def app
Rails.application
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment