a new way to manage lists of gems with commoon things
This commit is contained in:
parent
9e0bfa722e
commit
c858dcdd69
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@
|
|||||||
.bundle
|
.bundle
|
||||||
Gemfile.lock
|
Gemfile.lock
|
||||||
pkg/*
|
pkg/*
|
||||||
|
.DS_Store
|
||||||
|
1
Gemfile
1
Gemfile
@ -13,3 +13,4 @@ gem 'rspec', '~> 2.6.0'
|
|||||||
gem 'rake'
|
gem 'rake'
|
||||||
|
|
||||||
gem 'cucumber'
|
gem 'cucumber'
|
||||||
|
gem 'cuke-pack', :path => '../cuke-pack'
|
||||||
|
11
Guardfile
11
Guardfile
@ -9,10 +9,13 @@ group :rspec do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
group :cucumber do
|
# added by cuke-pack
|
||||||
guard 'cucumber' do
|
|
||||||
watch(%r{^features/.+\.feature$})
|
group :wip do
|
||||||
|
guard 'cucumber', :env => :cucumber, :cli => '-p wip' do
|
||||||
|
watch(%r{^features/.+.feature$})
|
||||||
|
watch(%r{^(app|lib).*}) { 'features' }
|
||||||
watch(%r{^features/support/.+$}) { 'features' }
|
watch(%r{^features/support/.+$}) { 'features' }
|
||||||
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
|
watch(%r{^features/step_definitions/(.+).rb$}) { 'features' }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
8
config/cucumber.yml
Normal file
8
config/cucumber.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<%
|
||||||
|
std_opts = "-r features --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} -f Cucumber::StepWriter --out features/step_definitions --strict"
|
||||||
|
%>
|
||||||
|
default: <%= std_opts %> features
|
||||||
|
wip: <%= std_opts %> --tags @wip features
|
||||||
|
precommit: FAILFAST=true <%= std_opts %> --tags ~@wip:0 features
|
||||||
|
cleanup: <%= std_opts %> -f Cucumber::CleanupFormatter --out unused.txt features
|
||||||
|
|
@ -31,3 +31,41 @@ Feature: Gemfiles
|
|||||||
# generated by penchant, environment: local
|
# generated by penchant, environment: local
|
||||||
this is content
|
this is content
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
Scenario: Use placeholder expansion
|
||||||
|
Given I have the file "Gemfile.erb" with the content:
|
||||||
|
"""
|
||||||
|
<% env :local, :path => '../%s' do %>
|
||||||
|
gem 'test'
|
||||||
|
<% end %>
|
||||||
|
"""
|
||||||
|
When I rebuild the Gemfile for "local" mode
|
||||||
|
Then the file "Gemfile" should have the following content:
|
||||||
|
"""
|
||||||
|
# generated by penchant, environment: local
|
||||||
|
|
||||||
|
gem 'test', :path => %{../test}
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
Scenario: Use a gem list for an operation
|
||||||
|
Given I have the file "Gemfile.erb" with the content:
|
||||||
|
"""
|
||||||
|
<% with_gem_list 'test' do %>
|
||||||
|
<% env :local, :path => '../%s' do %>
|
||||||
|
<%= gem %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
"""
|
||||||
|
When I rebuild the Gemfile for "local" mode
|
||||||
|
Then the file "Gemfile" should have the following content:
|
||||||
|
"""
|
||||||
|
# generated by penchant, environment: local
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
gem 'test', :path => %{../test}
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
When /^I rebuild the Gemfile for "(.*?)" mode$/ do |env|
|
||||||
|
Penchant::Gemfile.do_full_env_switch!(env)
|
||||||
|
end
|
||||||
|
|
20
features/support/cuke-pack.rb
Normal file
20
features/support/cuke-pack.rb
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
require 'cuke-pack/support/pause'
|
||||||
|
require 'cuke-pack/support/pending'
|
||||||
|
|
||||||
|
Before do
|
||||||
|
# if you want pending steps to pause before marking the step as pending,
|
||||||
|
# set @pause_ok to true
|
||||||
|
|
||||||
|
@pause_ok = false
|
||||||
|
end
|
||||||
|
|
||||||
|
require 'cuke-pack/support/step_writer'
|
||||||
|
require 'cuke-pack/support/wait_for'
|
||||||
|
require 'cuke-pack/support/failfast'
|
||||||
|
|
||||||
|
# set the level of flaying on the step definitions
|
||||||
|
# set it to false to skip flaying
|
||||||
|
flay_level = 32
|
||||||
|
|
||||||
|
require 'cuke-pack/support/flay'
|
||||||
|
|
@ -61,7 +61,7 @@ module Penchant
|
|||||||
def switch_to!(gemfile_env = nil, deployment = false)
|
def switch_to!(gemfile_env = nil, deployment = false)
|
||||||
@env, @is_deployment = gemfile_env, deployment
|
@env, @is_deployment = gemfile_env, deployment
|
||||||
|
|
||||||
output = [ header, ERB.new(template).result(binding) ]
|
output = [ header, ERB.new(template, nil, nil, '@_erbout').result(binding) ]
|
||||||
|
|
||||||
File.open(gemfile_path, 'wb') { |fh| fh.print output.join("\n") }
|
File.open(gemfile_path, 'wb') { |fh| fh.print output.join("\n") }
|
||||||
end
|
end
|
||||||
@ -97,8 +97,36 @@ module Penchant
|
|||||||
File.read(gemfile_erb_path)
|
File.read(gemfile_erb_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def env(check, &block)
|
def env(check, template = {}, &block)
|
||||||
instance_eval(&block) if check.to_s == @env.to_s
|
if check.to_s == @env.to_s
|
||||||
|
original_erbout = @_erbout.dup
|
||||||
|
|
||||||
|
output = instance_eval(&block).lines.to_a
|
||||||
|
|
||||||
|
output.each do |line|
|
||||||
|
if gem_name = line[%r{gem ['"]([^'"]+)['"]}, 1]
|
||||||
|
new_line = line.rstrip
|
||||||
|
template.each do |key, value|
|
||||||
|
new_line += ", #{key.inspect} => %{#{value % gem_name}}"
|
||||||
|
end
|
||||||
|
new_line += "\n"
|
||||||
|
line.replace(new_line)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@_erbout = original_erbout + output.join
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def with_gem_list(*gems)
|
||||||
|
gems.each do |gem|
|
||||||
|
@_current_gem = gem
|
||||||
|
yield
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def gem
|
||||||
|
"gem '#{@_current_gem}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
def no_deployment(&block)
|
def no_deployment(&block)
|
||||||
|
Loading…
Reference in New Issue
Block a user