test/class_dependencies_test.rb in trailblazer-operation-0.10.1 vs test/class_dependencies_test.rb in trailblazer-operation-0.11.0
- old
+ new
@@ -26,14 +26,18 @@
class Home < Trailblazer::Operation
step Subprocess(Index)
end
# "model.class" gets injected automatically just before {Index}.
- Home.({params: {}}).inspect.must_equal %{<Result:true #<Trailblazer::Context::Container wrapped_options={\"model.class\"=>Module} mutable_options=#<Trailblazer::Context::Container wrapped_options={:params=>{}} mutable_options={\"a\"=>Module}>> >}
+ result = Home.({params: {}})
+ assert_result result, {:"model.class"=>Module, :params=>{}, :a=>Module}
+ # .inspect.must_equal %{<Result:true #<Trailblazer::Context::Container wrapped_options={\"model.class\"=>Module} mutable_options=#<Trailblazer::Context::Container wrapped_options={:params=>{}} mutable_options={\"a\"=>Module}>> >}
# "model.class" gets injected by user and overrides class dependencies.
- Home.({params: {}, "model.class" => Symbol}).inspect.must_equal %{<Result:true #<Trailblazer::Context::Container wrapped_options={\"model.class\"=>Module} mutable_options=#<Trailblazer::Context::Container wrapped_options={:params=>{}, \"model.class\"=>Symbol} mutable_options={\"a\"=>Symbol}>> >}
+ result = Home.({params: {}, "model.class" => Symbol})
+ assert_result result, {:"model.class"=>Symbol, :params=>{}, :a=>Symbol }
+ # .inspect.must_equal %{<Result:true #<Trailblazer::Context::Container wrapped_options={\"model.class\"=>Module} mutable_options=#<Trailblazer::Context::Container wrapped_options={:params=>{}, \"model.class\"=>Symbol} mutable_options={\"a\"=>Symbol}>> >}
class Dashboard < Trailblazer::Operation
extend ClassDependencies
self["model.class"] = Float # this overrides {Index}'es dependency
@@ -41,11 +45,11 @@
pass ->(ctx, **) { ctx[:Dashboard] = ctx["model.class"] }
step Subprocess(Index)
end
# TODO: "model.class" gets injected automatically in {Dashboard} and overrides the {Index} input.
- Dashboard.({params: {}}).inspect.must_equal %{<Result:true #<Trailblazer::Context::Container wrapped_options={\"model.class\"=>Module} mutable_options=#<Trailblazer::Context::Container wrapped_options={\"model.class\"=>Float} mutable_options=#<Trailblazer::Context::Container wrapped_options={\"model.class\"=>Float} mutable_options=#<Trailblazer::Context::Container wrapped_options={:params=>{}} mutable_options={:Dashboard=>Float, \"a\"=>Float}>>>> >}
-
+ assert_equal Dashboard.({params: {}}).inspect,
+ %(<Result:true #<Trailblazer::Context::Container wrapped_options=#{{"model.class" => Module}} mutable_options=#<Trailblazer::Context::Container wrapped_options=#{{"model.class" => Float}} mutable_options=#<Trailblazer::Context::Container wrapped_options=#{{"model.class" => Float}} mutable_options=#<Trailblazer::Context::Container wrapped_options=#{{:params => {}}} mutable_options=#{{:Dashboard => Float, "a" => Float}}>>>> >)
end
describe "inheritance" do
it "reader/setter read from separate config" do
subclass = Class.new(Index)