Method: RSpec::Core::Configuration#extend

Defined in:
lib/rspec/core/configuration.rb

#extend(mod, *filters) ⇒ void

Tells RSpec to extend example groups with mod. Methods defined in mod are exposed to example groups (not examples). Use filters to constrain the groups to extend.

Similar to include, but behavior is added to example groups, which are classes, rather than the examples, which are instances of those classes.

Examples:


module UiHelpers
  def run_in_browser
    # ...
  end
end

module PermissionHelpers
  def define_permissions
    # ...
  end
end

RSpec.configure do |config|
  config.extend(UiHelpers, :type => :request)
  config.extend(PermissionHelpers, :with_permissions, :type => :request)
end

describe "edit profile", :with_permissions, :type => :request do
  run_in_browser
  define_permissions

  it "does stuff in the client" do
    # ...
  end
end

See Also:



1518
1519
1520
1521
1522
# File 'lib/rspec/core/configuration.rb', line 1518

def extend(mod, *filters)
  define_mixed_in_module(mod, filters, @extend_modules, :extend) do |group|
    safe_extend(mod, group)
  end
end