test/operation/pundit_test.rb in trailblazer-macro-2.1.15 vs test/operation/pundit_test.rb in trailblazer-macro-2.1.16
- old
+ new
@@ -25,52 +25,55 @@
end
# successful.
it do
result = Create.(params: {}, current_user: Module)
- result[:process].must_equal true
+
+ assert_equal result[:process], true
#- result object, policy
- result[:"result.policy.default"].success?.must_equal true
- result[:"result.policy.default"][:message].must_be_nil
+ assert_equal result[:"result.policy.default"].success?, true
+ assert_nil result[:"result.policy.default"][:message]
# result[:valid].must_be_nil
- result[:"policy.default"].inspect.must_equal %{<Auth: user:Module, model:nil>}
+ assert_equal result[:"policy.default"].inspect, %{<Auth: user:Module, model:nil>}
end
# breach.
it do
result = Create.(params: {}, current_user: nil)
- result[:process].must_be_nil
+ assert_nil result[:process]
#- result object, policy
- result[:"result.policy.default"].success?.must_equal false
- result[:"result.policy.default"][:message].must_equal "Breach"
+ assert_equal result[:"result.policy.default"].success?, false
+ assert_equal result[:"result.policy.default"][:message], "Breach"
end
- # inject different policy.Condition it { Create.(params: {}, current_user: Object, "policy.default.eval" => Trailblazer::Operation::Policy::Pundit::Condition.new(Auth, :user_object?))["process"].must_equal true }
- it { Create.(params: {}, current_user: Module, :"policy.default.eval" => Trailblazer::Operation::Policy::Pundit::Condition.new(Auth, :user_object?))[:process].must_be_nil }
+ # inject different policy.Condition it { Create.(params: {}, current_user: Object, "policy.default.eval" => Trailblazer::Operation::Policy::Pundit::Condition.new(Auth, :user_object?))["process"], true }
+ it { assert_nil Create.(params: {}, current_user: Module, :"policy.default.eval" => Trailblazer::Operation::Policy::Pundit::Condition.new(Auth, :user_object?))[:process] }
#---
# inheritance, adding Model
class Show < Create
step Model( Song, :new ), before: :"policy.default.eval"
end
- it { Trailblazer::Developer.railway(Show).must_equal %{[>model.build,>policy.default.eval,>process]} }
+ it { assert_equal Trailblazer::Developer.railway(Show), %{[>model.build,>policy.default.eval,>process]} }
# invalid because user AND model.
it do
result = Show.(params: {}, current_user: Module)
- result[:process].must_be_nil
- result[:model].inspect.must_equal %{#<struct PolicyTest::Song id=nil>}
- # result["policy"].inspect.must_equal %{#<struct PolicyTest::Song id=nil>}
+ assert_nil result[:process]
+
+ assert_equal result[:model].inspect, %{#<struct PolicyTest::Song id=nil>}
+ # result["policy"].inspect, %{#<struct PolicyTest::Song id=nil>}
end
# valid because new policy.
it do
# puts Show["pipetree"].inspect
result = Show.(params: {}, current_user: Module, :"policy.default.eval" => Trailblazer::Operation::Policy::Pundit::Condition.new(Auth, :user_and_model?))
- result[:process].must_equal true
- result[:model].inspect.must_equal %{#<struct PolicyTest::Song id=nil>}
- result[:"policy.default"].inspect.must_equal %{<Auth: user:Module, model:#<struct PolicyTest::Song id=nil>>}
+
+ assert_equal result[:process], true
+ assert_equal result[:model].inspect, %{#<struct PolicyTest::Song id=nil>}
+ assert_equal result[:"policy.default"].inspect, %{<Auth: user:Module, model:#<struct PolicyTest::Song id=nil>>}
end
##--
# TOOOODOOO: Policy and Model before Build ("External" or almost Resolver)
class Edit < Trailblazer::Operation
@@ -84,22 +87,25 @@
end
# successful.
it do
result = Edit.(params: { id: 1 }, current_user: Module)
- result[:process].must_equal true
- result[:model].inspect.must_equal %{#<struct PolicyTest::Song id=1>}
- result[:"result.policy.default"].success?.must_equal true
- result[:"result.policy.default"][:message].must_be_nil
+
+ assert_equal result[:process], true
+ assert_equal result[:model].inspect, %{#<struct PolicyTest::Song id=1>}
+ assert_equal result[:"result.policy.default"].success?, true
+ assert_nil result[:"result.policy.default"][:message]
# result[:valid].must_be_nil
- result[:"policy.default"].inspect.must_equal %{<Auth: user:Module, model:#<struct PolicyTest::Song id=1>>}
+ assert_equal result[:"policy.default"].inspect, %{<Auth: user:Module, model:#<struct PolicyTest::Song id=1>>}
end
# breach.
it do
result = Edit.(params: { id: 4 }, current_user: nil)
- result[:model].inspect.must_equal %{#<struct PolicyTest::Song id=4>}
- result[:process].must_be_nil
- result[:"result.policy.default"].success?.must_equal false
- result[:"result.policy.default"][:message].must_equal "Breach"
+
+ assert_equal result[:model].inspect, %{#<struct PolicyTest::Song id=4>}
+ assert_nil result[:process]
+
+ assert_equal result[:"result.policy.default"].success?, false
+ assert_equal result[:"result.policy.default"][:message], "Breach"
end
end