From 1b97fa6078aec16e22d0aa9e63424a93fbaecc92 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Fri, 8 Jun 2012 15:25:04 -0400 Subject: [PATCH] fix erb processing for good --- features/gemfile.feature | 3 +++ features/ruby_gemfile.feature | 1 - ..._file_gemfile_should_have_the_following_stripped_content.rb | 2 ++ lib/penchant/gemfile.rb | 1 + lib/penchant/version.rb | 2 +- 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/features/gemfile.feature b/features/gemfile.feature index ac6d788..35a43eb 100644 --- a/features/gemfile.feature +++ b/features/gemfile.feature @@ -35,6 +35,7 @@ Feature: Gemfiles Scenario: Simple env Given I have the file "Gemfile.erb" with the content: """ + gem 'test' <% env :local do %> gem 'test' <% end %> @@ -44,7 +45,9 @@ Feature: Gemfiles """ # generated by penchant, environment: local gem 'test' + gem 'test' """ + Scenario: Use placeholder expansion Given I have the file "Gemfile.erb" with the content: """ diff --git a/features/ruby_gemfile.feature b/features/ruby_gemfile.feature index 5234470..9d449b9 100644 --- a/features/ruby_gemfile.feature +++ b/features/ruby_gemfile.feature @@ -1,6 +1,5 @@ @fakefs Feature: Gemfiles - @wip Scenario: Process a pure Ruby gemfile Given I have the file "Gemfile.penchant" with the content: """ diff --git a/features/step_definitions/then/the_file_gemfile_should_have_the_following_stripped_content.rb b/features/step_definitions/then/the_file_gemfile_should_have_the_following_stripped_content.rb index 8bee548..9a3c500 100644 --- a/features/step_definitions/then/the_file_gemfile_should_have_the_following_stripped_content.rb +++ b/features/step_definitions/then/the_file_gemfile_should_have_the_following_stripped_content.rb @@ -2,6 +2,8 @@ Then /^the file "(.*?)" should have the following stripped content:$/ do |file, test_lines = string.lines.to_a File.read(file).lines.collect(&:strip).reject(&:empty?).to_a.each do |line| + raise StandardError.new if test_lines.empty? + line.strip.should == test_lines.shift.strip end end diff --git a/lib/penchant/gemfile.rb b/lib/penchant/gemfile.rb index 8fe9d35..c6cfc93 100644 --- a/lib/penchant/gemfile.rb +++ b/lib/penchant/gemfile.rb @@ -183,6 +183,7 @@ module Penchant def env(check, template = {}, &block) if check.to_s == @environment.to_s original_erbout = @_erbout.dup + @_erbout = '' output = instance_eval(&block).lines.to_a diff --git a/lib/penchant/version.rb b/lib/penchant/version.rb index 0254e7d..b1da38c 100644 --- a/lib/penchant/version.rb +++ b/lib/penchant/version.rb @@ -1,3 +1,3 @@ module Penchant - VERSION = "0.2.3" + VERSION = "0.2.4" end