fix tests
This commit is contained in:
parent
47d8d3c52c
commit
033ba8a54c
@ -40,12 +40,10 @@ Feature: Gemfiles
|
|||||||
<% end %>
|
<% end %>
|
||||||
"""
|
"""
|
||||||
When I rebuild the Gemfile for "local" mode
|
When I rebuild the Gemfile for "local" mode
|
||||||
Then the file "Gemfile" should have the following content:
|
Then the file "Gemfile" should have the following stripped content:
|
||||||
"""
|
"""
|
||||||
# generated by penchant, environment: local
|
# generated by penchant, environment: local
|
||||||
|
|
||||||
gem 'test', :path => %{../test}
|
gem 'test', :path => %{../test}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
Scenario: Use a gem list for an operation
|
Scenario: Use a gem list for an operation
|
||||||
@ -58,15 +56,10 @@ Feature: Gemfiles
|
|||||||
<% end %>
|
<% end %>
|
||||||
"""
|
"""
|
||||||
When I rebuild the Gemfile for "local" mode
|
When I rebuild the Gemfile for "local" mode
|
||||||
Then the file "Gemfile" should have the following content:
|
Then the file "Gemfile" should have the following stripped content:
|
||||||
"""
|
"""
|
||||||
# generated by penchant, environment: local
|
# generated by penchant, environment: local
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
gem 'test', :path => %{../test}
|
gem 'test', :path => %{../test}
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
Scenario: Let gem get additional info
|
Scenario: Let gem get additional info
|
||||||
@ -81,6 +74,7 @@ Feature: Gemfiles
|
|||||||
"""
|
"""
|
||||||
# generated by penchant, environment: local
|
# generated by penchant, environment: local
|
||||||
|
|
||||||
|
|
||||||
gem 'test', :path => %{../test}
|
gem 'test', :path => %{../test}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -49,6 +49,7 @@ Feature: Gemfiles
|
|||||||
gem "three", {:path=>"../three"}
|
gem "three", {:path=>"../three"}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@wip
|
||||||
Scenario: Use an env block
|
Scenario: Use an env block
|
||||||
Given I have the file "Gemfile.penchant" with the content:
|
Given I have the file "Gemfile.penchant" with the content:
|
||||||
"""
|
"""
|
||||||
@ -105,7 +106,6 @@ Feature: Gemfiles
|
|||||||
gem "one", {:path=>"../one", :require=>nil}
|
gem "one", {:path=>"../one", :require=>nil}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@wip
|
|
||||||
Scenario: Don't add an empty hash
|
Scenario: Don't add an empty hash
|
||||||
Given I have the file "Gemfile.penchant" with the content:
|
Given I have the file "Gemfile.penchant" with the content:
|
||||||
"""
|
"""
|
||||||
@ -118,3 +118,15 @@ Feature: Gemfiles
|
|||||||
gem "one"
|
gem "one"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
Scenario: Single gem gets processed like a gems list
|
||||||
|
Given I have the file "Gemfile.penchant" with the content:
|
||||||
|
"""
|
||||||
|
gem 'one', :path => '../%s'
|
||||||
|
"""
|
||||||
|
When I rebuild the Gemfile for "local" mode
|
||||||
|
Then the file "Gemfile" should have the following content:
|
||||||
|
"""
|
||||||
|
# generated by penchant, environment: local
|
||||||
|
gem "one", {:path=>"../one"}
|
||||||
|
"""
|
||||||
|
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
Then /^the file "(.*?)" should have the following stripped content:$/ do |file, string|
|
||||||
|
test_lines = string.lines.to_a
|
||||||
|
|
||||||
|
File.read(file).lines.collect(&:strip).reject(&:empty?).to_a.each do |line|
|
||||||
|
line.strip.should == test_lines.shift.strip
|
||||||
|
end
|
||||||
|
end
|
@ -6,6 +6,7 @@ Before('@fakefs') do
|
|||||||
end
|
end
|
||||||
|
|
||||||
After do
|
After do
|
||||||
|
FakeFS::FileSystem.clear
|
||||||
FakeFS.deactivate!
|
FakeFS.deactivate!
|
||||||
|
|
||||||
FileUtils.rm_rf 'tmp'
|
FileUtils.rm_rf 'tmp'
|
||||||
|
@ -100,24 +100,21 @@ module Penchant
|
|||||||
end
|
end
|
||||||
|
|
||||||
def gem(*args)
|
def gem(*args)
|
||||||
|
gem_name, template = split_args(args)
|
||||||
|
|
||||||
|
options = process_options(gem_name, template)
|
||||||
|
|
||||||
|
args = [ gem_name.first ]
|
||||||
|
args << options if !options.empty?
|
||||||
|
|
||||||
@output << %{gem #{args_to_string(args)}}
|
@output << %{gem #{args_to_string(args)}}
|
||||||
end
|
end
|
||||||
|
|
||||||
def gems(*gems)
|
def gems(*args)
|
||||||
template = {}
|
gems, template = split_args(args)
|
||||||
|
|
||||||
while gems.last.instance_of?(Hash)
|
|
||||||
template.merge!(gems.pop)
|
|
||||||
end
|
|
||||||
|
|
||||||
gems.flatten.each do |gem_name|
|
gems.flatten.each do |gem_name|
|
||||||
options = Hash[
|
options = process_options(gem_name, template)
|
||||||
template.collect { |key, value|
|
|
||||||
value = value % gem_name if value.respond_to?(:%)
|
|
||||||
|
|
||||||
[ key, value ]
|
|
||||||
}.sort
|
|
||||||
]
|
|
||||||
|
|
||||||
args = [ gem_name ]
|
args = [ gem_name ]
|
||||||
args << options if !options.empty?
|
args << options if !options.empty?
|
||||||
@ -152,6 +149,16 @@ module Penchant
|
|||||||
args.inspect[1..-2]
|
args.inspect[1..-2]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def split_args(args)
|
||||||
|
template = {}
|
||||||
|
|
||||||
|
while args.last.instance_of?(Hash)
|
||||||
|
template.merge!(args.pop)
|
||||||
|
end
|
||||||
|
|
||||||
|
[ args, template ]
|
||||||
|
end
|
||||||
|
|
||||||
def call_and_indent_output(block)
|
def call_and_indent_output(block)
|
||||||
index = @output.length
|
index = @output.length
|
||||||
block.call
|
block.call
|
||||||
@ -159,6 +166,16 @@ module Penchant
|
|||||||
@output[i] = " " + @output[i]
|
@output[i] = " " + @output[i]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def process_options(gem_name, template = {})
|
||||||
|
Hash[
|
||||||
|
template.collect { |key, value|
|
||||||
|
value = value % gem_name if value.respond_to?(:%)
|
||||||
|
|
||||||
|
[ key, value ]
|
||||||
|
}.sort
|
||||||
|
]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def switch_to!(gemfile_env = nil, deployment = false)
|
def switch_to!(gemfile_env = nil, deployment = false)
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
module Penchant
|
module Penchant
|
||||||
VERSION = "0.1.2.1"
|
VERSION = "0.2.0"
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user