Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ gemspec

group :test do
gem "quickdraw", github: "joeldrapper/quickdraw"
gem "minitest"
gem "rspec-expectations"
gem "simplecov", require: false, platform: :ruby
end

Expand Down
36 changes: 36 additions & 0 deletions config/quickdraw.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,40 @@

require "literally"

class Runner
def initialize
@failures = []
@errors = []
@successes = 0
end

attr_reader :failures, :successes, :errors

def failure!(failure)
@failures << failure
end

def success!(description)
@successes += 1
end

def error!(error)
@errors << error
end
end

class Quickdraw::Test
def assert_test(passes: 0, failures: 0, errors: 0, &block)
runner = Runner.new

Quickdraw::Test.new(description: nil, skip: false, block:).run(runner)

assert_equal runner.successes, passes
assert_equal runner.failures.size, failures
assert_equal runner.errors.size, errors

runner
end
end

Literally.init(include: ["#{Dir.pwd}/**/*"], exclude: ["**/excluded.rb"])
2 changes: 1 addition & 1 deletion lib/literally.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module Literally

CONFIG = Configuration.new

class TypedSignatureError = Class.new(StandardError)
TypedSignatureError = Class.new(StandardError)

# Initializes Literally so that code loaded after this point will be
# guarded against undefined instance variable reads. You can pass an array
Expand Down
1 change: 1 addition & 0 deletions lib/literally/processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,6 @@ def visit_def_node(node)
else
type = "::Literal::_Array(#{type_node.slice})"
end
end
end
end
133 changes: 133 additions & 0 deletions test/minitest.test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# frozen_string_literal: true

class MinitestTest < Quickdraw::Test
include Quickdraw::MinitestAdapter

def test_assert_equal
assert_equal(1, 1)
end

def test_assert_empty
assert_empty([])
end

def test_assert_in_delta
assert_in_delta(1.0, 1.0, 0.1)
end

def test_assert_in_epsilon
assert_in_epsilon(1.0, 1.0, 0.1)
end

def test_assert_includes
assert_includes([1, 2, 3], 3)
end

def test_assert_instance_of
assert_instance_of(String, "Hello")
end

def test_assert_kind_of
assert_kind_of(String, "Hello")
end

def test_assert_match
assert_match(/Hello/, "Hello")
end

def test_assert_nil
assert_nil(nil)
end

def test_assert_operator
assert_operator(1, :<, 2)
end

def test_assert_path_exists
assert_path_exists("test/minitest.test.rb")
end

def test_assert_pattern
assert_pattern { 1 => Integer }
end

def test_assert_predicate
assert_predicate(2, :even?)
end

def test_assert_raises
assert_raises(ArgumentError) { raise ArgumentError.new("Hello") }
end

def test_assert_respond_to
assert_respond_to(String, :new)
end

def test_assert_same
assert_same(1, 1)
end

def test_assert_throws
assert_throws(:foo) { throw :foo }
end

def test_refute_empty
refute_empty([1, 2, 3])
end

def test_refute_equal
refute_equal(1, 2)
end

def test_refute_in_delta
refute_in_delta(1.0, 1.2, 0.1)
end

def test_refute_in_epsilon
refute_in_epsilon(1.0, 1.2, 0.1)
end

def test_refute_includes
refute_includes([1, 2, 3], 4)
end

def test_refute_instance_of
refute_instance_of(String, 1)
end

def test_refute_kind_of
refute_kind_of(String, 1)
end

def test_refute_match
refute_match(/Hello/, "World")
end

def test_refute_nil
refute_nil(1)
end

def test_refute_operator
refute_operator(1, :>, 2)
end

def test_refute_path_exists
refute_path_exists("test/not_a_file.rb")
end

def test_refute_pattern
refute_pattern { 1 => String }
end

def test_refute_predicate
refute_predicate(2, :odd?)
end

def test_refute_respond_to
refute_respond_to(String, :to_i)
end

def test_refute_same
refute_same(1, 2)
end
end
4 changes: 2 additions & 2 deletions test/processor.test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def say_hello(name: ("World"));binding.assert(name: String);__literally_returns_
end

test "return type, keyword arg with default processes" do
assert_raises(RuntimeError) do
assert_raises(NameError) do
Literally::Processor.call(<<~'RUBY')
def say_hello(foo, name: String {"World"}) = String do
"Hello #{name}!"
Expand Down Expand Up @@ -388,4 +388,4 @@ def move_to(**position);binding.assert(position: Position);__literally_returns__
do_something
;);binding.assert(__literally_returns__: _Void);__literally_returns__;end
RUBY
end
end