Module: RspecInContext::InContext
- Defined in:
- lib/rspec_in_context/in_context.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
- .add_context(context_name, owner = nil, &block) ⇒ Object
- .contexts ⇒ Object
- .find_context(context_name) ⇒ Object
- .included(base) ⇒ Object
- .outside_define_context(context_name, &block) ⇒ Object
- .remove_context(current_class) ⇒ Object
Class Method Details
.add_context(context_name, owner = nil, &block) ⇒ Object
16 17 18 |
# File 'lib/rspec_in_context/in_context.rb', line 16 def add_context(context_name, owner = nil, &block) contexts[context_name] = Context.new(block, owner) end |
.contexts ⇒ Object
12 13 14 |
# File 'lib/rspec_in_context/in_context.rb', line 12 def contexts @contexts ||= ActiveSupport::HashWithIndifferentAccess.new end |
.find_context(context_name) ⇒ Object
20 21 22 23 |
# File 'lib/rspec_in_context/in_context.rb', line 20 def find_context(context_name) contexts[context_name] || (raise NoContextFound, "No context found with name #{context_name}") end |
.included(base) ⇒ Object
8 9 10 |
# File 'lib/rspec_in_context/in_context.rb', line 8 def included(base) base.extend ClassMethods end |
.outside_define_context(context_name, &block) ⇒ Object
29 30 31 |
# File 'lib/rspec_in_context/in_context.rb', line 29 def outside_define_context(context_name, &block) InContext.add_context(context_name, &block) end |
.remove_context(current_class) ⇒ Object
25 26 27 |
# File 'lib/rspec_in_context/in_context.rb', line 25 def remove_context(current_class) contexts.delete_if{ |_, context| context.owner == current_class } end |