Skip to content

Commit

Permalink
Merge pull request #63 from seuros/freshtest
Browse files Browse the repository at this point in the history
chore: remove deprecated test syntax
  • Loading branch information
apotonick authored May 28, 2024
2 parents b8da95a + 7a9e4e5 commit acadd20
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
32 changes: 16 additions & 16 deletions test/circuit_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ class CircuitTest < Minitest::Spec

last_signal, (ctx, i, j, *bla) = circuit.([ctx, 1, 2], task: Start)

expect(ctx.inspect).must_equal %{{:start=>1, :a=>2, :b=>3, :_end=>4}}
expect(last_signal).must_equal "the end"
expect(i).must_equal 1
expect(j).must_equal 2
expect(bla).must_equal []
assert_equal ctx.inspect, %{{:start=>1, :a=>2, :b=>3, :_end=>4}}
assert_equal last_signal, "the end"
assert_equal i, 1
assert_equal j, 2
assert_equal bla, []

# ---

Expand All @@ -33,7 +33,7 @@ class CircuitTest < Minitest::Spec

last_signal, (ctx, i, j, *bla) = circuit.([ctx, flow_options, 2], task: Start, runner: MyRunner)

expect(flow_options).must_equal(stack: [Start, A, B, End])
assert_equal flow_options, { stack: [Start, A, B, End] }
end

MyRunner = ->(task, args, **circuit_options) do
Expand Down Expand Up @@ -76,11 +76,11 @@ class CircuitTest < Minitest::Spec

last_signal, (ctx, i, j, *bla) = outer.([ctx, {}, 2], task: Start)

expect(ctx.inspect).must_equal %{{:start=>1, :a=>2, :c=>6, :_end=>4, :b=>3}}
expect(last_signal).must_equal "the end"
expect(i).must_equal({})
expect(j).must_equal 2
expect(bla).must_equal []
assert_equal ctx.inspect, %{{:start=>1, :a=>2, :c=>6, :_end=>4, :b=>3}}
assert_equal last_signal, "the end"
assert_equal i,({})
assert_equal j, 2
assert_equal bla, []
end

it "allows using a custom :runner" do
Expand All @@ -89,11 +89,11 @@ class CircuitTest < Minitest::Spec

last_signal, (ctx, flow_options, j, *bla) = outer.([ctx, flow_options, 2], task: Start, runner: MyRunner)

expect(ctx.inspect).must_equal %{{:start=>1, :a=>2, :c=>6, :_end=>4, :b=>3}}
expect(last_signal).must_equal "the end"
expect(flow_options).must_equal(stack: [Start, A, nestable, Start, C, End, B, End], runner: MyRunner)
expect(j).must_equal 2
expect(bla).must_equal []
assert_equal ctx.inspect, %{{:start=>1, :a=>2, :c=>6, :_end=>4, :b=>3}}
assert_equal last_signal, "the end"
assert_equal flow_options, { stack: [Start, A, nestable, Start, C, End, B, End], runner: MyRunner }
assert_equal j, 2
assert_equal bla, []
end

let(:wicked_circuit) do
Expand Down
6 changes: 3 additions & 3 deletions test/intermediate_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,21 +164,21 @@ def implementation(c_extensions)

schema = Inter::Compiler.(intermediate, implementation([ext_a, ext_b, ext_d, ext_e]))

expect(schema[:config].to_h.inspect).must_equal %{{:wrap_static=>{}, :a=>\"bla\", :b=>\"blubb\", :C=>1, :e=>2}}
assert_equal schema[:config].to_h.inspect, %{{:wrap_static=>{}, :a=>\"bla\", :b=>\"blubb\", :C=>1, :e=>2}}
end

# {Implementation.call()} allows to pass {config} data
describe "{Implementation.call()}" do
it "accepts {config_merge:} data that is merged into {config}" do
schema = Inter::Compiler.(intermediate, implementation([]), config_merge: {beer: "yes"})

expect(schema[:config].to_h.inspect).must_equal %{{:wrap_static=>{}, :beer=>\"yes\"}}
assert_equal schema[:config].to_h.inspect, %{{:wrap_static=>{}, :beer=>\"yes\"}}
end

it "{:config_merge} overrides values in {default_config}" do
schema = Inter::Compiler.(intermediate, implementation([]), config_merge: {beer: "yes", wrap_static: "yo"})

expect(schema[:config].to_h.inspect).must_equal %{{:wrap_static=>"yo", :beer=>\"yes\"}}
assert_equal schema[:config].to_h.inspect, %{{:wrap_static=>"yo", :beer=>\"yes\"}}
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions test/structures_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ class StructuresTest < Minitest::Spec
it "#call always returns the End instance itself" do
signal, (_ctx, _flow_options) = evt.([{a: 1}, {}])

expect(signal).must_equal evt
assert_equal signal, evt
end

it "responds to #to_h" do
expect(evt.to_h).must_equal({semantic: :meaning})
assert_equal evt.to_h, {semantic: :meaning}
end

it "has strict object identity" do
expect(evt).wont_equal Activity::End(:meaning)
refute_equal evt, Activity::End(:meaning)
end

it "responds to #inspect" do
expect(evt.inspect).must_equal %{#<Trailblazer::Activity::End semantic=:meaning>}
assert_equal evt.inspect, %(#<Trailblazer::Activity::End semantic=:meaning>)
end

it "allows more variables" do
expect(Activity::End.new(semantic: :success, type: :event).to_h).must_equal(semantic: :success, type: :event)
assert_equal Activity::End.new(semantic: :success, type: :event).to_h, { semantic: :success, type: :event }
end
end
end

0 comments on commit acadd20

Please sign in to comment.