Class: RspecVarsHelper::ClassMethods::VarsDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_vars_helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ VarsDSL

Returns a new instance of VarsDSL.



6
7
8
# File 'lib/rspec_vars_helper.rb', line 6

def initialize(klass)
  @klass = klass
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/rspec_vars_helper.rb', line 10

def method_missing(method_name, *args, &block)
  case method_name
  when /!$/
    @klass.class_eval { let!(:"#{method_name.to_s.sub(/!$/,'')}", &block) }
  else
    @klass.class_eval { let(method_name, &block) }
  end
end