Class: Graham::TestCase

Inherits:
Struct
  • Object
show all
Defined in:
lib/graham/test_case.rb

Overview

A struct for encapsulating test cases. Memoizes the case’s return value.

Defined Under Namespace

Classes: Proxy

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#argsObject

Returns the value of attribute args

Returns:

  • (Object)

    the current value of args



4
5
6
# File 'lib/graham/test_case.rb', line 4

def args
  @args
end

#blkObject

Returns the value of attribute blk

Returns:

  • (Object)

    the current value of blk



4
5
6
# File 'lib/graham/test_case.rb', line 4

def blk
  @blk
end

#msgObject

Returns the value of attribute msg

Returns:

  • (Object)

    the current value of msg



4
5
6
# File 'lib/graham/test_case.rb', line 4

def msg
  @msg
end

#objObject

Returns the value of attribute obj

Returns:

  • (Object)

    the current value of obj



4
5
6
# File 'lib/graham/test_case.rb', line 4

def obj
  @obj
end

Instance Method Details

#goObject



5
6
7
# File 'lib/graham/test_case.rb', line 5

def go
  defined?(@val) ? @val : (@val = obj.send msg, *args, &blk)
end

#to_sObject



9
10
11
# File 'lib/graham/test_case.rb', line 9

def to_s
  "#{Class===obj ? '::' : ?#}#{msg}(#{args.join ', '})#{" {...}" if blk}"
end