0

Is there a way to generate RBS signatures from running tests?

From what I've been reading so far, I constructed this

RUBYOPT="-Ilib" rbs prototype runtime ruby -R ./forgiver.rb Forgiver ruby test/forgiver_test.rb

but it seems to me runtime does something different than what I think.

forgiver.rb:

# frozen_string_literal: true

# This just forgives ppl
class Forgiver
  def initialize(name:)
    @name = name
  end

  def forgive
    "I forgive you #{@name}"
  end
end

test/forgiver_test.rb:

# frozen_string_literal: true

require 'minitest/autorun'
require_relative '../forgiver.rb'

describe Forgiver do
  let(:forgiver) do
    something = 'John'
    Forgiver.new name: something
  end

  describe '#greet' do
    it 'greets' do
      forgiver.forgive.must_equal 'I forgive you John'
    end
  end
end
4

0 回答 0