gemini-suggestions, tests-fail
This commit is contained in:
parent
016de072ea
commit
5f4b1f74e5
8 changed files with 429 additions and 15 deletions
31
spec/spec_helper.rb
Normal file
31
spec/spec_helper.rb
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# spec/spec_helper.rb
|
||||
ENV['RACK_ENV'] = 'test' # Set environment to test, important for Sinatra config
|
||||
|
||||
require 'rack/test'
|
||||
require 'rspec' # For RSpec
|
||||
require 'json' # Required if you're testing JSON responses
|
||||
|
||||
# --- CRITICAL APP LOADING ---
|
||||
# Adjust this path if your app.rb is NOT directly in the parent directory of 'spec/'
|
||||
# Example: If app.rb is in `src/app.rb`, use `require_relative '../src/app.rb'`
|
||||
require_relative '../app'
|
||||
|
||||
# Configure Rack::Test
|
||||
RSpec.configure do |config|
|
||||
config.include Rack::Test::Methods # Include Rack::Test methods
|
||||
|
||||
# This is *THE* most critical part for Sinatra tests.
|
||||
# It must return the instance of your Sinatra application.
|
||||
def app
|
||||
# Option 1: For classic style Sinatra apps (most common for small apps)
|
||||
# where you just have `get '/' do ... end` directly in app.rb
|
||||
Sinatra::Application
|
||||
|
||||
# Option 2: For modular Sinatra apps (if your app.rb defines a class)
|
||||
# class MyApp < Sinatra::Base; ... end
|
||||
# If this is your case, uncomment the line below and replace 'MyApp'
|
||||
# MyApp.new
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue