Sha256: 19417cb60ac0b38b3d5fbf838f3d9826b2d5692391750b4fc89f228e27a7728f
Contents?: true
Size: 1 KB
Versions: 16
Compression:
Stored size: 1 KB
Contents
require File.expand_path('../../generator', __FILE__) module TestCase class Generator include ::Generator attr_reader :test_file, :string def setup(test_file) super @test_file = test_file @prelude = "" @before_tests = "" @body = "" @number_of_tests = 0 end def add_to_prelude(string) @prelude << string + "\n" end def add_to_before_tests(content) @before_tests << content + "\n" end def add_to_body(content) @body << content + "\n" end def add_test(body) @body << build_test(@number_of_tests, body) + "\n" @number_of_tests += 1 end def add_working_test add_test <<-EOT object = Object.new mock(object).foo object.foo EOT end def call lines = [] lines << @prelude lines << start_of_test_case lines << @before_tests lines << @body lines << "end" @string = lines.map { |line| line + "\n" }.join end end end
Version data entries
16 entries across 16 versions & 1 rubygems