penchant/features/ruby_gemfile.feature

384 lines
12 KiB
Gherkin

@fakefs
Feature: Gemfiles
Scenario: Process a pure Ruby gemfile
Given I have the file "Gemfile.penchant" with the content:
"""
source :rubygems
gemspec
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
gemspec
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
gemspec
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"
"""
Scenario: Single gem gets processed like a gems list
Given I have the file "Gemfile.penchant" with the content:
"""
gem 'one', '1.2.3', :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", "1.2.3", {:path=>"../one"}
"""
@mocha
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
"""
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 |
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"}
"""
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"}
"""
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}
gem "two", {:require=>nil}
"""
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"}
"""
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"}
"""
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"
"""