class Object

Public Instance Methods

call_action() click to toggle source
# File lib/service_operation/spec/support/action_contexts.rb, line 11
def call_action
  contexts << described_class.call(input)
  contexts.last
end
call_action!() click to toggle source
# File lib/service_operation/spec/support/action_contexts.rb, line 16
def call_action!
  context = call_action
  expect_success(context)
  context
end
call_operation() click to toggle source
# File lib/service_operation/spec/support/operation_contexts.rb, line 11
def call_operation
  outputs << described_class.call(input)
  outputs.last
end
call_operation!() click to toggle source
# File lib/service_operation/spec/support/operation_contexts.rb, line 16
def call_operation!
  output = call_operation
  expect_success(output)
  output
end
expect_action_to() { || ... } click to toggle source
# File lib/service_operation/spec/support/action_contexts.rb, line 26
def expect_action_to
  expect { context }.to yield
end
expect_error(error = nil) click to toggle source

expect_error('blah') expect_error(/blah/) expect_error(/blah/).not_to eq('blah') expect_error.to include(“blah”)

# File lib/service_operation/spec/support/action_contexts.rb, line 45
def expect_error(error = nil)
  expect_failure

  expectation = expect(context.error)

  if error
    expectation.to eq(error)
  else
    expectation
  end
end
expect_failure(obj = context) click to toggle source
# File lib/service_operation/spec/support/action_contexts.rb, line 36
def expect_failure(obj = context)
  raise 'failed without error' if obj.failure? && obj.error.nil? && obj.errors.blank?
  expect(obj).not_to be_success
end
expect_operation_to() { || ... } click to toggle source
# File lib/service_operation/spec/support/operation_contexts.rb, line 26
def expect_operation_to
  expect { output }.to yield
end
expect_success(obj = context) click to toggle source
# File lib/service_operation/spec/support/action_contexts.rb, line 30
def expect_success(obj = context)
  expect(obj.error).to eq(nil)
  expect(obj.errors).to eq({}) if obj.errors
  expect(obj).to be_success
end
last_context() click to toggle source
# File lib/service_operation/spec/support/action_contexts.rb, line 22
def last_context
  contexts.last || call_service
end
last_operation() click to toggle source
# File lib/service_operation/spec/support/operation_contexts.rb, line 22
def last_operation
  operations.last || call_operation
end