Skip to content

Instantly share code, notes, and snippets.

@tlatsas
Last active July 22, 2022 11:29
Show Gist options
  • Save tlatsas/6fcc521d3c60394eaff260ff83ef920a to your computer and use it in GitHub Desktop.
Save tlatsas/6fcc521d3c60394eaff260ff83ef920a to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby "2.7.2"
gem "rails"
gem "rspec-rails"
end
require "action_controller/railtie"
class TestApp < Rails::Application
secrets.secret_token = "secret_token"
secrets.secret_key_base = "secret_key_base"
config.logger = Logger.new($stdout)
Rails.logger = config.logger
routes.draw do
resources :movies, only: :index
end
end
class MoviesController < ActionController::Base
#include Rails.application.routes.url_helpers
def index
render inline: "<div>It Works!</div>"
end
end
module ApplicationHelper
end
require "rspec/rails"
require "rspec/autorun"
RSpec.describe "Movies index", type: :request do
before do
get "/movies"
end
it "responds successfully" do
expect(response).to have_http_status(:ok)
end
it "renders correctly" do
expect(response.body).to include("It Works!")
end
end
# Run with RAILS_ENV=test ruby ./inline_rails.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment