Sha256: 005e7a587723515cb63f90102f48d0e5695a4934a837bc7a900b28e494a22eb1
Contents?: true
Size: 1.31 KB
Versions: 91
Compression:
Stored size: 1.31 KB
Contents
# encoding: utf-8 require 'spec_helper' require 'eval_helper' describe 'EvalHelper' do context :times_code do class EvalHelperTimesTest include EvalHelper def hoge(number, proc) code = times_code(number, proc) end end cases = [ { case_no: 1, case_title: 'single_line_proc case', number: 2, proc: 'puts "#{i}times"', expected: '2.times { |i| puts "#{i}times" }' }, { case_no: 2, case_title: 'multi_line_proc case', number: 3, proc: 'puts "#{i}times"\nputs "#{i*2}times"', expected: <<-EOS 3.times do |i| puts \"\#{i}times\" puts \"\#{i*2}times\" end EOS }, ] cases.each do |c| it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do begin case_before c # -- given -- # nothing # -- when -- actual = EvalHelperTimesTest.new.hoge c[:number], c[:proc] # -- then -- expect(actual).to eq(c[:expected]) ensure case_after c end end def case_before(c) # implement each case before end def case_after(c) # implement each case after end end end end
Version data entries
91 entries across 91 versions & 1 rubygems