penchant/features/ruby_gemfile.feature

442 lines
14 KiB
Gherkin
Raw Normal View History

2012-06-05 11:50:33 +00:00
@fakefs
Feature: Gemfiles
Scenario: Process a pure Ruby gemfile
Given I have the file "Gemfile.penchant" with the content:
"""
source :rubygems
2012-06-06 17:22:28 +00:00
gemspec
2012-06-05 11:50:33 +00:00
group :cats, :dogs do
case environment
when :local
gem 'test', :path => '../test'
when :remote
gem 'test', :git => 'git://github.com/johnbintz/test.git'
end
end
"""
When I rebuild the Gemfile for "local" mode
Then the file "Gemfile" should have the following content:
"""
# generated by penchant, environment: local
source :rubygems
2012-06-06 17:22:28 +00:00
gemspec
2012-06-05 11:50:33 +00:00
group :cats, :dogs do
gem "test", {:path=>"../test"}
end
"""
When I rebuild the Gemfile for "remote" mode
Then the file "Gemfile" should have the following content:
"""
# generated by penchant, environment: remote
source :rubygems
2012-06-06 17:22:28 +00:00
gemspec
2012-06-05 11:50:33 +00:00
group :cats, :dogs do
gem "test", {:git=>"git://github.com/johnbintz/test.git"}
end
"""
Scenario: Use a gemlist
Given I have the file "Gemfile.penchant" with the content:
"""
gems 'one', 'two', 'three', :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"}
gem "two", {:path=>"../two"}
gem "three", {:path=>"../three"}
"""
Scenario: Use an env block
Given I have the file "Gemfile.penchant" with the content:
"""
env :local do
gems 'one', 'two', 'three', :path => '../%s'
end
"""
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"}
gem "two", {:path=>"../two"}
gem "three", {:path=>"../three"}
"""
When I rebuild the Gemfile for "remote" mode
Then the file "Gemfile" should have the following content:
"""
# generated by penchant, environment: remote
"""
Scenario: Skip deployment blocks
Given I have the file "Gemfile.penchant" with the content:
"""
no_deployment do
gem 'one'
end
"""
When I rebuild the Gemfile for "local" mode
Then the file "Gemfile" should have the following content:
"""
# generated by penchant, environment: local
gem "one"
"""
When I rebuild the Gemfile for "local" mode with deployment
Then the file "Gemfile" should have the following content:
"""
# generated by penchant, environment: local, deployment mode (was local)
"""
Scenario: Peel multiple hashes off a gemlist
Given I have the file "Gemfile.penchant" with the content:
"""
gems 'one', { :path => '../%s' }, { :require => nil }
"""
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", :require=>nil}
"""
Scenario: Don't add an empty hash
Given I have the file "Gemfile.penchant" with the content:
"""
gems 'one'
"""
When I rebuild the Gemfile for "local" mode
Then the file "Gemfile" should have the following content:
"""
# generated by penchant, environment: local
gem "one"
"""
2012-06-05 12:20:48 +00:00
Scenario: Single gem gets processed like a gems list
Given I have the file "Gemfile.penchant" with the content:
"""
2012-06-11 20:46:34 +00:00
gem 'one', '1.2.3', :path => '../%s'
2012-06-05 12:20:48 +00:00
"""
When I rebuild the Gemfile for "local" mode
Then the file "Gemfile" should have the following content:
"""
# generated by penchant, environment: local
2012-06-11 20:46:34 +00:00
gem "one", "1.2.3", {:path=>"../one"}
2012-06-05 12:20:48 +00:00
"""
2012-06-06 17:22:28 +00:00
@mocha
2012-06-06 15:20:02 +00:00
Scenario: OS-specific blocks
Given I have the file "Gemfile.penchant" with the content:
"""
os :darwin do
gem 'one', :path => '../%s'
end
"""
And I am on the "darwin" platform
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"}
"""
Given I am on the "linux" platform
When I rebuild the Gemfile for "local" mode
Then the file "Gemfile" should have the following content:
"""
# generated by penchant, environment: local
"""
2012-06-07 14:48:27 +00:00
Scenario: Get the list of environments defined
Given I have the file "Gemfile.penchant" with the content:
"""
env :cat do
gem 'one', :path => '../%s'
end
env :dog do
gem 'two', :path => '../%s'
end
"""
When I request the list of environments available
Then I should get the following environments:
| cat |
| dog |
Scenario: Get the list of git repos defined
Given I have the file "Gemfile.penchant" with the content:
"""
gem 'one', :path => '../%s'
gem 'two', :git => 'git://github.cats/%s.git'
"""
When I request the list of git repositories
Then I should get the following repositories:
| git://github.cats/two.git |
Scenario: Get the list of git repos defined, regardless of environment
Given I have the file "Gemfile.penchant" with the content:
"""
gem 'one', :path => '../%s'
env :remote do
gem 'two', :git => 'git://github.cats/%s.git'
end
"""
When I request the list of git repositories
Then I should get the following repositories:
| git://github.cats/two.git |
2012-06-20 13:34:47 +00:00
Scenario: Propose defaults for a gem
Given I have the file "Gemfile.penchant" with the content:
"""
defaults_for 'one', :path => '../%s'
gem 'one', '1.2.3'
"""
When I rebuild the Gemfile for "local" mode
Then the file "Gemfile" should have the following content:
"""
# generated by penchant, environment: local
gem "one", "1.2.3", {:path=>"../one"}
"""
Scenario: Propose defaults for an array of gems
Given I have the file "Gemfile.penchant" with the content:
"""
defaults_for ['one'], :path => '../%s'
gem 'one', '1.2.3'
"""
When I rebuild the Gemfile for "local" mode
Then the file "Gemfile" should have the following content:
"""
# generated by penchant, environment: local
gem "one", "1.2.3", {:path=>"../one"}
"""
2012-06-20 17:25:43 +00:00
Scenario: Propose defaults for an environment
Given I have the file "Gemfile.penchant" with the content:
"""
defaults_for env(:local), :path => '../%s'
env :local do
gem 'one', '1.2.3'
end
"""
When I rebuild the Gemfile for "local" mode
Then the file "Gemfile" should have the following content:
"""
# generated by penchant, environment: local
gem "one", "1.2.3", {:path=>"../one"}
"""
2012-07-03 15:14:43 +00:00
Scenario: Create opposite environment gem assumptions to cut down on repetition
Given I have the file "Gemfile.penchant" with the content:
"""
defaults_for env(:local), :path => '../%s'
property(:github) { |name| { :git => "git://github.com/#{name}/%s.git" } }
env :remote, :opposite => :local do
gem 'one', :github => 'johnbintz', :require => nil
end
env :local, :opposite => :remote do
gem 'two', :path => '../%s', :require => nil
end
"""
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", :require=>nil}
gem "two", {:path=>"../two", :require=>nil}
"""
When I rebuild the Gemfile for "remote" mode
Then the file "Gemfile" should have the following content:
"""
# generated by penchant, environment: remote
gem "one", {:git=>"git://github.com/johnbintz/one.git", :require=>nil}
gem "two", {:require=>nil}
"""
Scenario: Set the opposite environment in the environment defaults
Given I have the file "Gemfile.penchant" with the content:
"""
defaults_for env(:local), :path => '../%s', :opposite => :remote
defaults_for env(:remote), :opposite => :local
property(:github) { |name| { :git => "git://github.com/#{name}/%s.git" } }
env :remote do
gem 'one', :github => 'johnbintz', :require => nil
end
env :local do
gem 'two', :path => '../%s', :require => nil
end
"""
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", :require=>nil}
gem "two", {:path=>"../two", :require=>nil}
"""
When I rebuild the Gemfile for "remote" mode
Then the file "Gemfile" should have the following content:
"""
# generated by penchant, environment: remote
gem "one", {:git=>"git://github.com/johnbintz/one.git", :require=>nil}
gem "two", {:require=>nil}
"""
Scenario: Define a pair of opposites
Given I have the file "Gemfile.penchant" with the content:
"""
defaults_for env(:local), :path => '../%s'
opposites :local, :remote
property(:github) { |name| { :git => "git://github.com/#{name}/%s.git" } }
env :remote do
gem 'one', :github => 'johnbintz', :require => nil
end
env :local do
gem 'two', :path => '../%s', :require => nil
end
"""
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", :require=>nil}
gem "two", {:path=>"../two", :require=>nil}
"""
When I rebuild the Gemfile for "remote" mode
Then the file "Gemfile" should have the following content:
"""
# generated by penchant, environment: remote
gem "one", {:git=>"git://github.com/johnbintz/one.git", :require=>nil}
2012-10-04 14:43:38 +00:00
gem "two", {:require=>nil}
"""
Scenario: Define a pair of opposites in the other order
Given I have the file "Gemfile.penchant" with the content:
"""
opposites :local, :remote
defaults_for env(:local), :path => '../%s'
property(:github) { |name| { :git => "git://github.com/#{name}/%s.git" } }
env :remote do
gem 'one', :github => 'johnbintz', :require => nil
end
env :local do
gem 'two', :path => '../%s', :require => nil
end
"""
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", :require=>nil}
gem "two", {:path=>"../two", :require=>nil}
"""
When I rebuild the Gemfile for "remote" mode
Then the file "Gemfile" should have the following content:
"""
# generated by penchant, environment: remote
gem "one", {:git=>"git://github.com/johnbintz/one.git", :require=>nil}
gem "two", {:require=>nil}
"""
2012-07-03 15:14:43 +00:00
Scenario: Override defaults for an environment
Given I have the file "Gemfile.penchant" with the content:
"""
defaults_for env(:local), :path => '../%s'
env :local do
gem 'one', '1.2.3', :path => '../cats'
end
"""
When I rebuild the Gemfile for "local" mode
Then the file "Gemfile" should have the following content:
"""
# generated by penchant, environment: local
gem "one", "1.2.3", {:path=>"../cats"}
"""
2012-07-05 22:27:59 +00:00
Scenario: Define special expansions for properties
Given I have the file "Gemfile.penchant" with the content:
"""
defaults_for env(:local), :path => '../%s'
property(:github) { |name| { :git => "git://github.com/#{name}/%s.git" } }
gem 'one', :github => 'john'
"""
When I rebuild the Gemfile for "local" mode
Then the file "Gemfile" should have the following content:
"""
# generated by penchant, environment: local
gem "one", {:git=>"git://github.com/john/one.git"}
"""
2012-07-10 10:38:02 +00:00
Scenario: Define special expansions for properties as a hash
Given I have the file "Gemfile.penchant" with the content:
"""
defaults_for env(:local), :path => '../%s'
property :github, :git => "git://github.com/$1/%s.git"
gem 'one', :github => 'john'
"""
When I rebuild the Gemfile for "local" mode
Then the file "Gemfile" should have the following content:
"""
# generated by penchant, environment: local
gem "one", {:git=>"git://github.com/john/one.git"}
"""
@mocha
Scenario: Force installing of git hooks if the gemfile asks for it
Given I expect git hooks to be installed
Given I have the file "Gemfile.penchant" with the content:
"""
ensure_git_hooks!
gem 'one'
"""
When I rebuild the Gemfile for "local" mode
Then the file "Gemfile" should have the following content:
"""
# generated by penchant, environment: local
gem "one"
"""
2012-10-06 20:42:51 +00:00
Scenario: Pass through the Ruby version
Given I have the file "Gemfile.penchant" with the content:
"""
ruby '1.9.3'
"""
When I rebuild the Gemfile for "local" mode
Then the file "Gemfile" should have the following content:
"""
# generated by penchant, environment: local
ruby "1.9.3"
"""
2013-07-25 19:26:00 +00:00
Scenario: Ask for the Gemfile encoding fix
Given I have the file "Gemfile.penchant" with the content:
"""
bundler_encoding_fix!
"""
When I rebuild the Gemfile for "local" mode
Then the file "Gemfile" should have the following content:
"""
# generated by penchant, environment: local
if RUBY_VERSION =~ /1.9/
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
end
"""