Skip to content

Commit

Permalink
clean up tests.o
Browse files Browse the repository at this point in the history
  • Loading branch information
apotonick committed Jan 22, 2025
1 parent 0157e18 commit d702fda
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 65 deletions.
3 changes: 0 additions & 3 deletions lib/trailblazer/test/testing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ def parse_tag_list(ctx, **)
ctx["contract.default"].tag_list = tags
end
end # Create

class Update < Create
end
end
end

Expand Down
64 changes: 2 additions & 62 deletions test/assertion_test.rb
Original file line number Diff line number Diff line change
@@ -1,66 +1,8 @@
require "test_helper"

class AssertionsTest < Minitest::Spec
Record = Struct.new(:id, :persisted?, :title, :genre, keyword_init: true)

class Create < Trailblazer::Operation
step :model

def model(ctx, params:, **)
ctx[:model] = Record.new(**params)
end
end

class Update < Trailblazer::Operation
step :validate

def validate(ctx, params:, **)
return true if params[:record]

ctx[:"contract.default"] = Struct.new(:errors).new(Struct.new(:messages).new({:title => ["is missing"]}))
false
end
end

# TODO: should we test the "meat" of these assertions here?
it "#assert_exposes" do
test =
Class.new(Test) do
include Trailblazer::Test::Assertion::AssertExposes

# test_0001_anonymous
it do
record = Record.new(id: 1, persisted?: true)

assert_exposes record,
id: 1,
persisted?: true
end

# test_0002_anonymous
it do
record = Record.new(id: 1, persisted?: true)

assert_exposes record,
id: 2,
persisted?: nil
end
end

test_1 = test.new(:test_0001_anonymous)
failures = test_1.()
assert_equal failures.size, 0

test_2 = test.new(:test_0002_anonymous)
failures = test_2.()
assert_equal 1, failures.size
assert_equal failures[0].inspect, %(#<Minitest::Assertion: Property [id] mismatch.
Expected: 2
Actual: 1>)
end

# Trailblazer::Test::Assertion.module!(self)

# UNCOMMENT for quick debugging.
# Trailblazer::Test::Assertion.module!(self)
it "#assert_pass" do
# assert_pass? Create, {params: {title: "Somewhere Far Beyond"}}, title: "Somewhere Far Beyond"

Expand Down Expand Up @@ -402,8 +344,6 @@ def model(ctx, params:, **)
class AssertionActivityTest < Minitest::Spec
Trailblazer::Test::Assertion.module!(self, activity: true)

Record = AssertionsTest::Record

class Create < Trailblazer::Activity::FastTrack
step :validate
step :model
Expand Down

0 comments on commit d702fda

Please sign in to comment.