Skip to content

Commit 2e6c090

Browse files
committed
add first minitest
1 parent 115bb79 commit 2e6c090

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

bin/test

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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

spec/generator_test.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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

0 commit comments

Comments
 (0)