Skip to content

Commit

Permalink
Suite docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
apotonick committed Jan 4, 2025
1 parent d9cda2e commit 6a8108c
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions test/docs/suite_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class MemoOperationTest < Minitest::Spec # test/memo/operation_test.rb

#:assert-pass
it "accepts {tag_list} and converts it to an array" do
assert_pass( {tag_list: "fridge,todo"}, {tag_list: ["fridge", "todo"]} )
assert_pass({tag_list: "fridge,todo"},
{tag_list: ["fridge", "todo"]}) # what we're expecting on the model.
end
#:assert-pass end
#~zoom end
Expand Down Expand Up @@ -162,45 +163,47 @@ class MemoOperationTest < Minitest::Spec # test/memo/operation_test.rb

# No {key: :song}.
class SongOperation_OMIT_KEY_Test < OperationSpec
module Song; end
module Memo; end

module Song::Operation
module Memo::Operation
class Create < Trailblazer::Operation
step Model(DocsSuiteAssertionsTest::Song, :new)
step Contract::Build(constant: DocsSuiteAssertionsTest::Song::Contract::Create)
step Model(DocsSuiteAssertionsTest::Memo, :new)
step Contract::Build(constant: DocsSuiteAssertionsTest::Memo::Operation::Create::Form)
step Contract::Validate()
step Contract::Persist()
end
end
let(:operation) { Song::Operation::Create }
let(:operation) { Memo::Operation::Create }
#:key_in_params
let(:key_in_params) { false }
#:key_in_params end

# What will the model look like after running the operation?
let(:expected_attributes) do
{
band: "Rancid",
title: "Timebomb",
title: "Todo",
content: "Stock up beer",
}
end

#:let-key-in-params-false
let(:key_in_params) { false }

let(:default_ctx) do
{
params: {
band: "Rancid",
title: "Timebomb",
title: "Todo",
content: "Stock up beer",
}
}
end
#:let-key-in-params-false end


it "passes with valid input, {duration} is optional" do
assert_pass( {}, {} )
end

#:omit-key-it
it "sets {title}" do
assert_pass( {title: "Ruby Soho"}, {title: "Ruby Soho"} )
assert_pass( {title: "Remember"}, {title: "Remember"} )
end
#:omit-key-it end

Expand All @@ -209,9 +212,9 @@ class Create < Trailblazer::Operation
end

it "Ctx()" do
assert_equal %{{:params=>{:band=>\"Rancid\"}}}, Ctx(exclude: [:title]).inspect
assert_equal %{{:params=>{:band=>\"Rancid\"}, :current_user=>Module}}, Ctx({current_user: Module}, exclude: [:title]).inspect
assert_equal %{{:params=>{:band=>\"Rancid\", :duration=>999}, :current_user=>Module}}, Ctx({current_user: Module, params: {duration: 999}}, exclude: [:title]).inspect
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
end
end # SongOperation_OMIT_KEY_Test

Expand Down

0 comments on commit 6a8108c

Please sign in to comment.