module RspecExtensions::BehaviorDSL

Constants

BehaviorNotification

Public Instance Methods

behavior(name, using: nil) { || ... } click to toggle source
# File lib/rspec_tapas/behavior_dsl.rb, line 14
def behavior(name, using: nil)
  if using.present?
    @controller_actions_called = []
    callback = lambda do |*args|
      options = args.extract_options!
      @controller_actions_called << "#{options[:controller]}##{options[:action]}"
    end
    ActiveSupport::Notifications.subscribed(callback, 'start_processing.action_controller') do
      yield
    end

    expect(@controller_actions_called).to(
      include(using),
      "expected #{using} to be used for #{name}, but it was not"
    )
  else
    yield
  end

  reporter.example_passed(BehaviorNotification.new(name))
end
reporter() click to toggle source
# File lib/rspec_tapas/behavior_dsl.rb, line 36
def reporter
  RSpec.current_example.reporter
end