Created
June 1, 2023 15:21
-
-
Save josegomezr/3ffdbb049eb28fa38984182ba1aaf40d to your computer and use it in GitHub Desktop.
Reminder for myself: self contained file for making quick isolated rails tests
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
#!/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