ShouldI.Matchers.Context

Convenience macros for generating short test cases of common structure. These matchers work with the context.

Source

Summary

should_assign_key(list)

Exactly match a key in the context to a value

should_have_key(key)

Check for existence of a key in the context returned by setup

should_match_key(list)

Pattern match against context[key]

should_not_have_key(key)

Negative check for existence of a key in the context returned by setup

Macros

should_assign_key(list)

Exactly match a key in the context to a value.

Examples

setup context do
  assign context, key_from_context_returned_by_setup: "exact expected value"
end

should_assign_key key_from_context_returned_by_setup: "exact expected value"
Source
should_have_key(key)

Check for existence of a key in the context returned by setup.

Examples

should_have_key :must_be_present
Source
should_match_key(list)

Pattern match against context[key]

Examples

should_match_key context_key: {:ok, _}
Source
should_not_have_key(key)

Negative check for existence of a key in the context returned by setup.

Examples

should_not_have_key :must_not_be_present
Source