Module: Shoulda::Let::TestCaseSupport

Defined in:
lib/shoulda/let/test_case_support.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *arguments, &block) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/shoulda/let/test_case_support.rb', line 11

def method_missing(name, *arguments, &block)
  name = name.to_sym
  if @shoulda_context && arguments.length == 0 && !block && @shoulda_context.let_defined?(name)
    let(name)
  else
    super
  end
end

Instance Method Details

#let(name) ⇒ Object

instance method used inside of should block assert_equal @result, let(:foo)



6
7
8
9
# File 'lib/shoulda/let/test_case_support.rb', line 6

def let(name)
  @let_cache ||= {}
  @let_cache[name] ||= instance_exec(&@shoulda_context.let(name))
end

#respond_to?(name, *arguments, &block) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/shoulda/let/test_case_support.rb', line 20

def respond_to?(name, *arguments, &block)
  ( @shoulda_context and @shoulda_context.let_defined?(name) ) or super
end