Module: ActionFigure::Testing
- Defined in:
- lib/action_figure/testing/statuses.rb,
lib/action_figure/testing/rspec.rb,
lib/action_figure/testing/minitest.rb,
sig/action_figure.rbs
Overview
Helpers shared by the Minitest and RSpec testing adapters.
Defined Under Namespace
Constant Summary collapse
- SUCCESS_STATUSES =
Success-only statuses (Ok, Created, Accepted, NoContent).
{ Ok: :ok, Created: :created, Accepted: :accepted, NoContent: :no_content }.freeze
Class Method Summary collapse
-
.contract_for(action_class) ⇒ Object
Resolves an action class's validation contract (RSpec adapter helper).
-
.define_error_helper(name, status) ⇒ void
Defines assert_/refute_ and be_ helpers for a dynamically registered status.
-
.statuses ⇒ Hash[Symbol, Symbol]
Live map of status-helper names to status symbols: success statuses plus every registered error status.
Class Method Details
.contract_for(action_class) ⇒ Object
Resolves an action class's validation contract (RSpec adapter helper).
28 29 30 31 32 33 34 |
# File 'lib/action_figure/testing/statuses.rb', line 28 def self.contract_for(action_class) contract = action_class.contract return contract if contract raise ArgumentError, "#{action_class} defines no params_schema, so it has no contract to validate against" end |
.define_error_helper(name, status) ⇒ void
This method returns an undefined value.
Defines assert_/refute_ and be_ helpers for a dynamically registered status.
41 42 43 44 |
# File 'lib/action_figure/testing/statuses.rb', line 41 def self.define_error_helper(name, status) Minitest.define_status_assertions(name, status) if const_defined?(:Minitest, false) RSpec.define_status_matcher(name, status) if const_defined?(:RSpec, false) end |
.statuses ⇒ Hash[Symbol, Symbol]
Live map of status-helper names to status symbols: success statuses plus every registered error status.
22 23 24 |
# File 'lib/action_figure/testing/statuses.rb', line 22 def self.statuses SUCCESS_STATUSES.merge(ActionFigure.error_statuses) end |