summaryrefslogtreecommitdiff
path: root/spec/integration/hanami_spec.rb
blob: 71f89ab9b5e40cd92980f86b1999dad1f0628961 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# frozen_string_literal: true

require "shellwords"
require 'rbconfig'

RSpec.describe "Hanami integration" do
  before :all do
    @ruby = RbConfig.ruby.shellescape
    @pry_dir = File.expand_path(File.join(__FILE__, '../../../lib')).shellescape
  end

  it "does not enter an infinite loop (#1471, #1621)" do
    code = <<-RUBY
        require "pry"
        require "timeout"
        module Prepend1
          def call(arg)
            super
          end
        end
        module Prepend2
          def call(arg)
            super
          end
        end
        class Action
          prepend Prepend1
          prepend Prepend2
          def call(arg)
            binding.pry input: StringIO.new("exit"), output: StringIO.new
          end
        end
        Timeout.timeout(1) { Action.new.call("define prison, in the abstract sense") }
        exit 42
    RUBY
    `#{@ruby} -I#{@pry_dir} -e'#{code}'`
    expect($CHILD_STATUS.exitstatus).to eq(42)
  end
end