File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed
Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env ruby
2+ # frozen_string_literal: true
3+
4+ #
5+ $LOAD_PATH. unshift File . expand_path ( "../lib" , __dir__ )
6+ Dir . glob ( File . expand_path ( "../spec/**/*_test.rb" , __dir__ ) ) . each do |file |
7+ require file
8+ end
Original file line number Diff line number Diff line change 1+ require "minitest/autorun"
2+ require_relative "../lib/rbi_generator/generator"
3+
4+ class RbiGeneratorTest < Minitest ::Test
5+ def setup
6+ @test_file = "test/test_class.rb"
7+ File . write ( @test_file , <<~RUBY )
8+ class TestClass
9+ def hello; end
10+ def test(x); end
11+ def add(x, y); end
12+ end
13+ RUBY
14+ @generator = RbiGenerator ::Generator . new ( @test_file )
15+ end
16+
17+ def teardown
18+ File . delete ( @test_file ) if File . exist? ( @test_file )
19+ rbi_file = @test_file . sub ( /\. rb$/ , ".rbi" )
20+ File . delete ( rbi_file ) if File . exist? ( rbi_file )
21+ end
22+
23+ def test_generate_creates_rbi_file
24+ @generator . generate
25+ rbi_path = @test_file . sub ( /\. rb$/ , ".rbi" )
26+ assert File . exist? ( rbi_path ) , "RBI file should be created"
27+ content = File . read ( rbi_path )
28+ assert_includes content , "class TestClass"
29+ assert_includes content , "def hello; end"
30+ assert_includes content , "def test(x); end"
31+ assert_includes content , "def add(x, y); end"
32+ end
33+ end
You can’t perform that action at this time.
0 commit comments