Permalink
Browse files

Use higher-level cucumber steps

  • Loading branch information...
1 parent 39fd463 commit f5902ae4fd32399498de31962ede1caa2a14a36d @gabebw gabebw committed Aug 12, 2011
@@ -7,22 +7,16 @@ Feature: Kumade executable
Background:
Given a directory named "executable"
And I cd to "executable"
- And I write to "Gemfile" with:
- """
- gem 'kumade', :path => '../../..'
- gem 'jammit'
- """
- And I run `bundle --gemfile=./Gemfile --local || bundle --gemfile=./Gemfile`
- When I successfully run `git init`
- And I successfully run `touch .gitkeep`
- And I successfully run `git add .`
- And I successfully run `git commit -am First`
+ And I set up the Gemfile with kumade
+ And I add "jammit" to the Gemfile
+ And I bundle
+ When I set up a git repo
And I create a Heroku remote for "pretend-staging-app" named "pretend-staging"
And I create a Heroku remote for "app-two" named "staging"
And I create a non-Heroku remote named "bad-remote"
Scenario: Pretend mode with a Heroku remote
- When I run `bundle exec kumade pretend-staging -p`
+ When I run kumade with "pretend-staging -p"
Then the output should contain "In Pretend Mode"
And the output should contain:
"""
@@ -39,21 +33,21 @@ Feature: Kumade executable
But the output should not contain "==> Packaged assets with More"
Scenario: Default environment is staging
- When I run `bundle exec kumade -p`
+ When I run kumade with "-p"
Then the output should contain "==> Deployed to: staging"
Scenario: Can deploy to arbitrary environment
- When I run `bundle exec kumade bamboo`
+ When I run kumade with "bamboo"
Then the output should contain "==> Deploying to: bamboo"
- Then the output should match /Cannot deploy: /
+ And the output should match /Cannot deploy: /
Scenario: Deploying to a non-Heroku remote fails
- When I run `bundle exec kumade bad-remote`
+ When I run kumade with "bad-remote"
Then the output should match /==> ! Cannot deploy: "bad-remote" remote does not point to Heroku/
Scenario: Deploy from another branch
When I run `git checkout -b new_branch`
- When I run `bundle exec kumade pretend-staging -p`
+ And I run kumade with "pretend-staging -p"
Then the output should contain:
"""
==> Git repo is clean
@@ -72,16 +66,15 @@ Feature: Kumade executable
"""
clean
"""
- When I run `bundle exec kumade pretend-staging`
+ When I run kumade with "pretend-staging"
Then the output from "bundle exec kumade pretend-staging" should not contain "==> ! Cannot deploy: repo is not clean"
Scenario: Git is not clean if a tracked file is modified
Given I write to "new-file" with:
"""
clean
"""
- And I successfully run `git add .`
- And I successfully run `git commit -am 'Add new file'`
+ And I commit everything in the current repo
When I append to "new-file" with "dirty it up"
- And I run `bundle exec kumade pretend-staging`
+ And I run kumade with "pretend-staging"
Then the output from "bundle exec kumade pretend-staging" should contain "==> ! Cannot deploy: repo is not clean"
@@ -0,0 +1,22 @@
+When /^I bundle$/ do
+ When %{I run `bundle --gemfile=./Gemfile --local || bundle --gemfile=./Gemfile`}
+end
+
+When /^I set up the Gemfile with kumade$/ do
+ steps %{
+ When I write to "Gemfile" with:
+ """
+ gem 'kumade', :path => '../../..'
+ """
+ }
+end
+
+When /^I add "([^"]+)" to the Gemfile$/ do |gem|
+ steps %{
+ When I append to "Gemfile" with:
+ """
+
+ gem '#{gem}'
+ """
+ }
+end
@@ -6,6 +6,22 @@
When %{I run `git remote add #{remote_name} git@github.com:gabebw/kumade.git`}
end
+When /^I set up a git repo$/ do
+ steps %{
+ When I successfully run `git init`
+ And I successfully run `touch .gitkeep`
+ And I successfully run `git add .`
+ And I successfully run `git commit -am First`
+ }
+end
+
+When /^I commit everything in the current repo$/ do
+ steps %{
+ When I successfully run `git add .`
+ And I successfully run `git commit -am MY_MESSAGE`
+ }
+end
+
After("@creates-remote") do
heroku_remotes = `git remote -v show | grep heroku | grep fetch | cut -f1`.strip.split
heroku_remotes.each { |remote| `git remote rm #{remote} 2> /dev/null` }
@@ -0,0 +1,3 @@
+When /^I run kumade with "([^"]+)"$/ do |args|
+ When %{I run `bundle exec kumade #{args}`}
+end

0 comments on commit f5902ae

Please sign in to comment.