Skip to content

Commit bec37f6

Browse files
committed
Update examples/rails_app to use OpenapiFirst::Test.setup
1 parent fa6c099 commit bec37f6

4 files changed

Lines changed: 9 additions & 23 deletions

File tree

examples/rails_app/test/integration/attachments_api_test.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
require 'test_helper'
44

55
class StationsApiTest < ActionDispatch::IntegrationTest
6-
include OpenapiFirst::Test::Methods
7-
86
test 'GET /attachments/{attachment_id}' do
97
get '/attachments/42abc', as: :json
8+
109
assert_api_conform(status: 200, api: :attachments)
1110
end
1211
end

examples/rails_app/test/integration/stations_api_test.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
require 'test_helper'
44

55
class StationsApiTest < ActionDispatch::IntegrationTest
6-
include OpenapiFirst::Test::Methods
7-
86
test 'GET /stations' do
97
get '/stations'
108

examples/rails_app/test/integration/trips_api_test.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
require 'test_helper'
22

33
class TripsApiTest < ActionDispatch::IntegrationTest
4-
include OpenapiFirst::Test::Methods
5-
64
test 'GET /trips' do
75
get '/trips',
86
params: { origin: 'efdbb9d1-02c2-4bc3-afb7-6788d8782b1e', destination: 'b2e783e1-c824-4d63-b37a-d8d698862f1d',
Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
ENV['RAILS_ENV'] ||= 'test'
2-
require_relative '../config/environment'
3-
require 'rails/test_help'
42

53
require 'openapi_first'
6-
OpenapiFirst::Test.register(Rails.root.join('../../spec/data/train-travel-api/openapi.yaml'))
7-
OpenapiFirst::Test.register(Rails.root.join('../../spec/data/attachments_openapi.yaml'), as: :attachments)
8-
9-
OpenapiFirst::Test::Coverage.register(
10-
Rails.root.join('../../spec/data/train-travel-api/openapi.yaml'),
11-
Rails.root.join('../../spec/data/attachments_openapi.yaml')
12-
)
13-
OpenapiFirst::Test::Coverage.start
14-
15-
Minitest.after_run do
16-
OpenapiFirst::Test::Coverage.report
4+
OpenapiFirst::Test.setup do |test|
5+
test.register Rails.root.join('../../spec/data/train-travel-api/openapi.yaml')
6+
test.register Rails.root.join('../../spec/data/attachments_openapi.yaml'), as: :attachments
7+
test.coverage_formatter_options = { verbose: true }
178
end
189

10+
require_relative '../config/environment'
11+
require 'rails/test_help'
12+
1913
module ActiveSupport
2014
class TestCase
2115
# Run tests in parallel with specified workers
@@ -25,12 +19,9 @@ class TestCase
2519
end
2620
end
2721

28-
TEST_APP = OpenapiFirst::Test.app(TrainTravel::Application, spec: Rails.root.join('../../spec/data/attachments_openapi.yaml'))
2922

3023
module ActionDispatch
3124
class IntegrationTest
32-
def app
33-
TEST_APP
34-
end
25+
include OpenapiFirst::Test::Methods[TrainTravel::Application]
3526
end
3627
end

0 commit comments

Comments
 (0)