Module: Trailblazer::Test::Suite
- Defined in:
- lib/trailblazer/test/suite.rb,
lib/trailblazer/test/suite/ctx.rb,
lib/trailblazer/test/suite/assert.rb
Overview
Offers the assertions ‘#assert_pass` and friends but with a configuration “DSL”. That means you can write super short and concise test cases using the defaulting in this module.
Defined Under Namespace
Modules: Assert, Spec, Test
Classes: CtxHash
Class Method Summary
collapse
Instance Method Summary
collapse
-
#assert_fail(params_fragment, expected_errors = nil, assertion: Assertion::AssertFail, **kws, &block) ⇒ Object
-
#assert_fail?(*args, **kws, &block) ⇒ Boolean
-
#assert_pass(params_fragment, expected_attributes_to_merge = {}, assertion: Assertion::AssertPass, **kws, &block) ⇒ Object
The assertions and helpers included into the actual test.
-
#assert_pass?(*args, **kws, &block) ⇒ Boolean
Class Method Details
.Ctx(merge_with_ctx = {}, exclude: false, merge: true, **kws) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/trailblazer/test/suite/ctx.rb', line 20
def Ctx(merge_with_ctx={}, exclude: false, merge: true, **kws)
if merge
options = Suite::Assert.normalize_kws_for_ctx(test: self, **kws) key_in_params = options[:key_in_params]
default_ctx = options[:default_ctx]
default_params = key_in_params ? default_ctx[:params][key_in_params] : default_ctx[:params]
filtered_default_params =
if exclude
default_params.slice(*(default_params.keys - exclude))
else
default_params end
default_params_for_ctx = key_in_params ? {key_in_params => filtered_default_params} : filtered_default_params
ctx = default_ctx.merge({params: default_params_for_ctx})
else ctx = {}
end
ctx = Suite.merge_for(ctx, merge_with_ctx, true)
Trailblazer::Test::Context[ctx] end
|
.merge_for(dest, source, deep_merge) ⇒ Object
14
15
16
17
18
|
# File 'lib/trailblazer/test/suite/ctx.rb', line 14
def merge_for(dest, source, deep_merge)
return dest.merge(source) unless deep_merge
CtxHash[dest].deep_merge(CtxHash[source]) end
|
Instance Method Details
#assert_fail(params_fragment, expected_errors = nil, assertion: Assertion::AssertFail, **kws, &block) ⇒ Object
41
42
43
|
# File 'lib/trailblazer/test/suite.rb', line 41
def assert_fail(params_fragment, expected_errors=nil, assertion: Assertion::AssertFail, **kws, &block)
Assert.assert_fail(params_fragment, expected_errors, test: self, user_block: block, assertion: assertion, **kws)
end
|
#assert_fail?(*args, **kws, &block) ⇒ Boolean
49
50
51
|
# File 'lib/trailblazer/test/suite.rb', line 49
def assert_fail?(*args, **kws, &block)
assert_fail(*args, **kws, invoke: Assertion.method(:invoke_operation_with_wtf), &block)
end
|
#assert_pass(params_fragment, expected_attributes_to_merge = {}, assertion: Assertion::AssertPass, **kws, &block) ⇒ Object
The assertions and helpers included into the actual test.
37
38
39
|
# File 'lib/trailblazer/test/suite.rb', line 37
def assert_pass(params_fragment, expected_attributes_to_merge={}, assertion: Assertion::AssertPass, **kws, &block)
Assert.assert_pass(params_fragment, test: self, user_block: block, assertion: assertion, expected_attributes_to_merge: expected_attributes_to_merge, **kws)
end
|
#assert_pass?(*args, **kws, &block) ⇒ Boolean
45
46
47
|
# File 'lib/trailblazer/test/suite.rb', line 45
def assert_pass?(*args, **kws, &block)
assert_pass(*args, **kws, invoke: Assertion.method(:invoke_operation_with_wtf), &block)
end
|