Skip to content

Commit

Permalink
make tests 3.4 savvy.
Browse files Browse the repository at this point in the history
  • Loading branch information
apotonick committed Jan 23, 2025
1 parent d4c974d commit dc74341
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions test/docs/suite_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class MemoOperationTest < Minitest::Spec # test/memo/operation_test.rb

assert_pass ctx, {}
#~skip
assert_equal %({:params=>{:memo=>{:title=>\"Todo\", :content=>\"Stock up beer\"}}, :current_user=>\"Yogi\"}), ctx.inspect
assert_equal CU.inspect(ctx), %({:params=>{:memo=>{:title=>\"Todo\", :content=>\"Stock up beer\"}}, :current_user=>\"Yogi\"})
#~skip end
end
#:ctx-inject end
Expand Down Expand Up @@ -143,7 +143,7 @@ class MemoOperationTest < Minitest::Spec # test/memo/operation_test.rb
#:ctx-merge-actual end
=end
#~skip
assert_equal ctx.inspect, %({:params=>{:memo=>{:title=>\"Reminder\", :content=>\"Stock up beer\"}}, :current_user=>\"Yogi\"})
assert_equal CU.inspect(ctx), %({:params=>{:memo=>{:title=>\"Reminder\", :content=>\"Stock up beer\"}}, :current_user=>\"Yogi\"})

#~skip end
end
Expand All @@ -155,7 +155,7 @@ class MemoOperationTest < Minitest::Spec # test/memo/operation_test.rb

assert_fail ctx, [:title]
#~skip
assert_equal %{{:params=>{:memo=>{:content=>\"Stock up beer\"}}}}, ctx.inspect
assert_equal CU.inspect(ctx), %{{:params=>{:memo=>{:content=>\"Stock up beer\"}}}}
#~skip end
end
#:ctx-exclude end
Expand All @@ -166,7 +166,7 @@ class MemoOperationTest < Minitest::Spec # test/memo/operation_test.rb
#=> {:params=>{:memo=>{:content=>"Stock up beer", :tag_list=>"todo"}}}
#:ctx-exclude-params-merge end

assert_equal ctx.inspect, %({:params=>{:memo=>{:content=>"Stock up beer", :tag_list=>"todo"}}})
assert_equal CU.inspect(ctx), %({:params=>{:memo=>{:content=>"Stock up beer", :tag_list=>"todo"}}})
end

#:ctx-exclude-merge
Expand All @@ -175,15 +175,15 @@ class MemoOperationTest < Minitest::Spec # test/memo/operation_test.rb
#=> {:params=>{:memo=>{:content=>"Stock up beer"}},
# :current_user=>#<User name="Yogi">}
#~skip
assert_equal ctx.inspect, %({:params=>{:memo=>{:content=>\"Stock up beer\"}}, :current_user=>\"Yogi\"})
assert_equal CU.inspect(ctx), %({:params=>{:memo=>{:content=>\"Stock up beer\"}}, :current_user=>\"Yogi\"})
#~skip end
end
#:ctx-exclude-merge end

it "{Ctx} provides {merge: false} to allow direct ctx building without any automatic merging" do
ctx = Ctx({current_user: yogi}, merge: false)

assert_equal %({:current_user=>\"Yogi\"}), ctx.inspect
assert_equal CU.inspect(ctx), %({:current_user=>\"Yogi\"})
end

#~meths end
Expand Down Expand Up @@ -241,9 +241,9 @@ class Create < Trailblazer::Operation
end

it "Ctx()" do
assert_equal %{{:params=>{:content=>\"Stock up beer\"}}}, Ctx(exclude: [:title]).inspect
assert_equal %{{:params=>{:content=>\"Stock up beer\"}, :current_user=>Module}}, Ctx({current_user: Module}, exclude: [:title]).inspect
assert_equal %{{:params=>{:content=>\"Stock up beer\", :duration=>999}, :current_user=>Module}}, Ctx({current_user: Module, params: {duration: 999}}, exclude: [:title]).inspect
assert_equal CU.inspect(Ctx(exclude: [:title])), %({:params=>{:content=>\"Stock up beer\"}})
assert_equal CU.inspect(Ctx({current_user: Module}, exclude: [:title])), %({:params=>{:content=>\"Stock up beer\"}, :current_user=>Module})
assert_equal CU.inspect(Ctx({current_user: Module, params: {duration: 999}}, exclude: [:title])), %({:params=>{:content=>\"Stock up beer\", :duration=>999}, :current_user=>Module})
end
end # SongOperation_OMIT_KEY_Test
end
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ def assert_test_case_fails(test, number, error_message)
failures, assertions, _ = test_case.()

assert_equal failures.size, 1
assert_equal failures[0].to_s, error_message
assert_equal CU.inspect(failures[0].to_s), error_message
end
end
2 changes: 1 addition & 1 deletion trailblazer-test.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "trailblazer-macro-contract"
# spec.add_development_dependency "reform-rails"
spec.add_development_dependency "dry-validation"
spec.add_development_dependency "trailblazer-core-utils"
spec.add_development_dependency "trailblazer-core-utils", ">= 0.0.5"

spec.add_dependency "trailblazer-activity-dsl-linear", ">= 1.2.6"
end

0 comments on commit dc74341

Please sign in to comment.