lib/transproc/rspec.rb in transproc-0.3.2 vs lib/transproc/rspec.rb in transproc-0.4.0

- old
+ new

@@ -3,20 +3,27 @@ # ============================================================================== # Examples for testing transproc functions # ============================================================================== shared_context :call_transproc do - let!(:__initial__) { input.dup rescue input } - let!(:__fn__) { described_class[*arguments] } + let!(:__fn__) { described_class[*arguments] } + let!(:__initial__) do + begin + input.dup + rescue + input + end + end + subject { __fn__[input] } end shared_examples :transforming_data do include_context :call_transproc it '[returns the expected output]' do - expect(subject).to eql(output), <<-REPORT.gsub(/.+\|/, "") + expect(subject).to eql(output), <<-REPORT.gsub(%r{.+\|}, '') | |fn = #{described_class}#{Array[*arguments]} | |fn[#{input}] | @@ -31,11 +38,11 @@ it_behaves_like :transforming_data it '[keeps input unchanged]' do expect { subject } - .not_to change { input }, <<-REPORT.gsub(/.+\|/, "") + .not_to change { input }, <<-REPORT.gsub(%r{.+\|}, '') | |fn = #{described_class}#{Array[*arguments]} | |expected: not to change #{__initial__} | got: changed it to #{input} @@ -49,10 +56,10 @@ it_behaves_like :transforming_data it '[changes input]' do expect { subject } .to change { input } - .to(output), <<-REPORT.gsub(/.+\|/, "") + .to(output), <<-REPORT.gsub(%r{.+\|}, '') | |fn = #{described_class}#{Array[*arguments]} | |fn[#{input}] |