Skip to content

Commit 0b21c1d

Browse files
committed
Set up ActionDispatch integration tests
1 parent 80a6cdf commit 0b21c1d

File tree

5 files changed

+64
-2
lines changed

5 files changed

+64
-2
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
RSpec.describe 'Integration with ActionDispatch', type: :integration, action_dispatch: true do
6+
context "when using 'super_diff/rspec-rails'" do
7+
include_context 'integration with ActionDispatch'
8+
9+
def make_program(test, color_enabled:)
10+
make_rspec_rails_test_program(test, color_enabled: color_enabled)
11+
end
12+
end
13+
14+
context "when using 'super_diff/action_dispatch'" do
15+
include_context 'integration with ActionDispatch'
16+
17+
def make_program(test, color_enabled:)
18+
make_rspec_action_dispatch_program(test, color_enabled: color_enabled)
19+
end
20+
end
21+
end

spec/support/integration/helpers.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ def make_rspec_active_support_program(test, color_enabled:)
3030
TestPrograms::RSpecActiveSupport.new(test, color_enabled: color_enabled)
3131
end
3232

33+
def make_rspec_action_dispatch_program(test, color_enabled:)
34+
TestPrograms::RSpecActionDispatch.new(test, color_enabled: color_enabled)
35+
end
36+
3337
def make_rspec_rails_test_program(test, color_enabled:)
3438
TestPrograms::RSpecRails.new(test, color_enabled: color_enabled)
3539
end
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# frozen_string_literal: true
2+
3+
module SuperDiff
4+
module IntegrationTests
5+
module TestPrograms
6+
class RSpecActionDispatch < Base
7+
protected
8+
9+
def test_plan_prelude
10+
<<~PRELUDE.strip
11+
test_plan.boot
12+
test_plan.boot_action_dispatch
13+
PRELUDE
14+
end
15+
16+
def test_plan_command
17+
'run_rspec_action_dispatch_test'
18+
end
19+
end
20+
end
21+
end
22+
end
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# frozen_string_literal: true
2+
3+
shared_examples_for 'integration with ActionDispatch' do
4+
end

support/test_plan.rb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,14 @@ def boot_active_support
6262
require 'active_support/core_ext/hash/indifferent_access'
6363
rescue LoadError => e
6464
# active_support may not be in the Gemfile, so that's okay
65-
puts "Error in TestPlan#boot_active_support: #{e.message}"
65+
puts "Error in TestPlan##{__method__}: #{e.message}"
66+
end
67+
68+
def boot_action_dispatch
69+
require 'action_dispatch'
70+
rescue LoadError => e
71+
# action_dispatch may not be in the Gemfile, so that's okay
72+
puts "Error in TestPlan##{__method__}: #{e.message}"
6673
end
6774

6875
def boot_active_record
@@ -86,7 +93,7 @@ def boot_active_record
8693
.each { |path| require path }
8794
rescue LoadError => e
8895
# active_record may not be in the Gemfile, so that's okay
89-
puts "Error in TestPlan#boot_active_record: #{e.message}"
96+
puts "Error in TestPlan##{__method__}: #{e.message}"
9097
end
9198

9299
def boot_rails
@@ -113,6 +120,10 @@ def run_rspec_active_record_test
113120
run_test_with_libraries('super_diff/rspec', 'super_diff/active_record')
114121
end
115122

123+
def run_rspec_action_dispatch_test
124+
run_test_with_libraries('super_diff/rspec', 'super_diff/action_dispatch')
125+
end
126+
116127
def run_rspec_rails_test
117128
run_test_with_libraries('super_diff/rspec-rails')
118129
end

0 commit comments

Comments
 (0)