class Matest::Example
Attributes
code[R]
Public Class Methods
let(var_name, &block)
click to toggle source
# File lib/matest/example.rb, line 30 def self.let(var_name, &block) define_method(var_name) do instance_variable_set(:"@#{var_name}__from_let", block.call) end end
local_var(var_name)
click to toggle source
# File lib/matest/example.rb, line 36 def self.local_var(var_name) define_method(var_name) do instance_variable_get(:"@#{var_name}") end define_method("#{var_name}=") do |value| instance_variable_set(:"@#{var_name}", value) end end
new(example_block, description, lets)
click to toggle source
# File lib/matest/example.rb, line 4 def initialize(example_block, description, lets) @example_block__for_internal_use = ExampleBlock.new(example_block) @description__for_internal_use = description @lets__for_internal_use = lets lets.each do |let| self.class.let(let.var_name, &let.block) send(let.var_name) if let.bang end end
Public Instance Methods
call()
click to toggle source
# File lib/matest/example.rb, line 26 def call instance_eval(&example_block.block) end
description()
click to toggle source
# File lib/matest/example.rb, line 22 def description @description__for_internal_use end
example_block()
click to toggle source
# File lib/matest/example.rb, line 18 def example_block @example_block__for_internal_use end
just_before_assertion()
click to toggle source
def without_block
the_new = self.clone the_new.instance_variable_set(:@example_block__for_internal_use, nil) the_new
end
# File lib/matest/example.rb, line 68 def just_before_assertion # return a clone of self, but with ExampleBeforeAssertion.new(example_block.block, description, lets) end
lets()
click to toggle source
# File lib/matest/example.rb, line 14 def lets @lets__for_internal_use end
track_lets()
click to toggle source
# File lib/matest/example.rb, line 51 def track_lets instance_variables.select {|var| var.to_s =~ /__from_let\Z/ }.map {|var| name = var.to_s name["__from_let"] = "" name[0] = "" [name, instance_variable_get(var)] } end
track_variables()
click to toggle source
# File lib/matest/example.rb, line 45 def track_variables instance_variables.reject {|var| var.to_s =~ /__for_internal_use\Z/ || var.to_s =~ /__from_let\Z/ }.map {|var| [var, instance_variable_get(var)] } end