Skip to content
This repository has been archived by the owner on Jun 8, 2019. It is now read-only.

Commit

Permalink
Many fewer nested Cucumber steps.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabe Berke-Williams committed Oct 22, 2011
1 parent 13469e2 commit 7ca5108
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 34 deletions.
25 changes: 6 additions & 19 deletions features/step_definitions/bundler_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,18 @@
end

When /^I rebundle$/ do
steps %{
When I bundle
And I commit everything in the current repo
}
run_bundler
commit_everything_in_repo
end

Given /^an empty Gemfile$/ do
When %{I write to "Gemfile" with:}, ""
write_file('Gemfile', '')
end

When /^I set up the Gemfile with kumade$/ do
steps %{
When I write to "Gemfile" with:
"""
gem 'kumade', :path => '../../..'
"""
}
add_kumade_to_gemfile
end

When /^I add "([^"]+)" to the Gemfile$/ do |gem|
steps %{
When I append to "Gemfile" with:
"""
gem '#{gem}'
"""
}
When /^I add "jammit" to the Gemfile$/ do
add_jammit_to_gemfile
end
19 changes: 5 additions & 14 deletions features/step_definitions/git_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,19 @@
end

When /^I set up a git repo$/ do
["git init", "touch .gitkeep", "git add .", "git commit -am First"].each do |git_command|
run_simple(git_command)
end
set_up_git_repo
end

When /^I commit everything in the current repo$/ do
['git add .', 'git commit -am MY_MESSAGE'].each do |git_command|
run_simple(git_command)
end
commit_everything_in_repo
end

When /^I create an untracked file$/ do
write_file("untracked-file", "anything")
end

When /^I modify a tracked file$/ do
steps %{
Given I write to "new-file" with:
"""
clean
"""
And I commit everything in the current repo
When I append to "new-file" with "dirty it up"
}
write_file('tracked-file', 'clean')
commit_everything_in_repo
append_to_file('tracked-file', 'dirty it up')
end
10 changes: 9 additions & 1 deletion features/step_definitions/rails_steps.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Given /^a new Rails application with Kumade$/ do
run_simple("rails new rake-tasks")
run_simple("rails new rake-tasks -T")
cd('rake-tasks')
append_to_file('Gemfile', "gem 'kumade', :path => '#{PROJECT_PATH}'")
run_bundler
set_up_git_repo
end

Given /^a new Rails application with Kumade and Jammit$/ do
Given "a new Rails application with Kumade"
add_jammit_to_gemfile
run_bundler
set_up_git_repo
end
12 changes: 12 additions & 0 deletions features/step_definitions/rake_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,15 @@
Then the output from "bundle exec rake -T" should not contain "#{task_name}"
}
end

When /^I add a pre-compilation rake task that prints "Hi!"$/ do
append_to_file("Rakefile", <<-CUSTOM_TASK)
namespace :kumade do
task :before_asset_compilation do
puts 'Hi!'
end
end
CUSTOM_TASK

When "I commit everything in the current repo"
end
8 changes: 8 additions & 0 deletions features/support/bundler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ module BundlerHelpers
def run_bundler
run_simple('bundle --gemfile=./Gemfile --local || bundle --gemfile=./Gemfile')
end

def add_jammit_to_gemfile
append_to_file('Gemfile', "\ngem 'jammit'")
end

def add_kumade_to_gemfile
append_to_file('Gemfile', "\ngem 'kumade', :path => '../../..'")
end
end

World(BundlerHelpers)
15 changes: 15 additions & 0 deletions features/support/git.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module GitHelpers
def set_up_git_repo
["git init", "touch .gitkeep", "git add .", "git commit -am First"].each do |git_command|
run_simple(git_command)
end
end

def commit_everything_in_repo
['git add .', 'git commit -am MY_MESSAGE'].each do |git_command|
run_simple(git_command)
end
end
end

World(GitHelpers)

0 comments on commit 7ca5108

Please sign in to comment.