Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Passing features using gitnesse-example-sinatra as guinea pig
- Loading branch information
Andrew Stewart
committed
Dec 17, 2012
1 parent
1120cb6
commit edb037a
Showing
5 changed files
with
108 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
|
@@ -15,4 +15,3 @@ spec/reports | ||
test/tmp | test/tmp | ||
test/version_tmp | test/version_tmp | ||
tmp | tmp | ||
/config/gitnesse.rb |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,31 +1,47 @@ | |||
Given /^there is a git wiki with cucumber features defined$/ do | Given /^there is a git wiki with cucumber features defined$/ do | ||
pending # express the regexp above with the code you wish you had | @features_dir = File.join(Dir.home, ".gitnesse_features") | ||
end | end | ||
|
|
||
Given /^there is a code repo without any cucumber features defined$/ do | Given /^there is a git wiki without any cucumber features defined$/ do | ||
pending # express the regexp above with the code you wish you had | @features_dir = File.join(Dir.home, ".gitnesse_features_no_features") | ||
end | |||
|
|||
When /^developer pulls feature stories from the wiki$/ do | |||
pending # express the regexp above with the code you wish you had | |||
end | end | ||
|
|
||
Then /^the feature stories within the code should match the wiki$/ do | Given /^there is a code repo with cucumber features defined$/ do | ||
pending # express the regexp above with the code you wish you had | @repo_dir = File.join(Dir.home, ".gitnesse_repo") | ||
end | end | ||
|
|
||
Given /^there is a git wiki without any cucumber features defined$/ do | Given /^there is a code repo without any cucumber features defined$/ do | ||
pending # express the regexp above with the code you wish you had | @repo_dir = File.join(Dir.home, ".gitnesse_repo_no_features") | ||
end | end | ||
|
|
||
Given /^there is a code repo with cucumber features defined$/ do | When /^developer pulls feature stories from the wiki$/ do | ||
pending # express the regexp above with the code you wish you had | Dir.chdir(@repo_dir) do | ||
`bundle exec rake gitnesse:pull &> /dev/null` | |||
assert_equal $?, 0 | |||
end | |||
end | end | ||
|
|
||
When /^developer pushes feature stories to the wiki$/ do | When /^developer pushes feature stories to the wiki$/ do | ||
pending # express the regexp above with the code you wish you had | Dir.chdir(@repo_dir) do | ||
`bundle exec rake gitnesse:push &> /dev/null` | |||
assert_equal $?, 0 | |||
end | |||
end | end | ||
|
|
||
Then /^the the feature stories within the code should match the wiki$/ do | Then /^the feature stories within the code should match the wiki$/ do | ||
pending # express the regexp above with the code you wish you had | assert_dir = File.join(Dir.home, ".gitnesse_features_for_assert") | ||
|
|||
Dir.mkdir(assert_dir) | |||
Dir.chdir(assert_dir) do | |||
system("git clone #{@features_dir} . &> /dev/null") | |||
end | |||
|
|||
repo_features = Dir.glob("#{@repo_dir}/features/*.feature").map { |file| File.basename(file, ".feature") } | |||
wiki_files = Dir.glob("#{assert_dir}/*.md").map { |file| File.basename(file, ".md") } | |||
|
|||
repo_features.each do |feature| | |||
assert(wiki_files.include?(feature) || wiki_files.include?("#{feature}.feature")) | |||
end | |||
|
|||
FileUtils.rm_rf(assert_dir) | |||
end | end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,73 @@ | |||
require 'test/unit/assertions' | |||
World(Test::Unit::Assertions) | |||
|
|||
puts " Setting up Gitnesse for testing..." | |||
|
|||
@features_dir = File.join(Dir.home, ".gitnesse_features") | |||
@features_dir_no_features = File.join(Dir.home, ".gitnesse_features_no_features") | |||
@repo_dir = File.join(Dir.home, ".gitnesse_repo") | |||
@repo_dir_no_features = File.join(Dir.home, ".gitnesse_repo_no_features") | |||
|
|||
Dir.mkdir @features_dir | |||
Dir.mkdir @repo_dir | |||
Dir.mkdir @features_dir_no_features | |||
Dir.mkdir @repo_dir_no_features | |||
|
|||
Dir.chdir(@features_dir) do | |||
system('git clone --bare https://github.com/hybridgroup/gitnesse-demo.wiki.git . &> /dev/null') | |||
if $? == 0 | |||
puts " Cloned demo features to #{@features_dir}." | |||
else | |||
abort " Failed to clone demo features to #{@features_dir}." | |||
end | |||
end | |||
|
|||
Dir.chdir(@features_dir_no_features) do | |||
system('git init --bare &> /dev/null') | |||
if $? == 0 | |||
puts " Created demo wiki without features in #{@features_dir_no_features}." | |||
else | |||
abort " Failed to create demo wiki without features in #{@features_dir_no_features}." | |||
end | |||
end | |||
|
|||
Dir.chdir(@repo_dir) do | |||
system('git clone https://github.com/hybridgroup/gitnesse-example-sinatra.git . &> /dev/null') | |||
if $? == 0 | |||
puts " Cloned demo repo to #{@repo_dir}." | |||
else | |||
abort " Failed to clone demo repo to #{@repo_dir}." | |||
end | |||
|
|||
system('bundle install --path vendor/bundle &> /dev/null') | |||
if $? == 0 | |||
puts " Installed gems for demo wiki." | |||
else | |||
abort " Failed to install gems for demo wiki." | |||
end | |||
end | |||
|
|||
config_file = File.join(@repo_dir, "gitnesse.rb") | |||
|
|||
config = File.read(config_file) | |||
config.gsub!(/config\.repository_url.*$/, "config.repository_url = '#{@features_dir}'") | |||
File.open(config_file, 'w') { |file| file.puts config } | |||
|
|||
puts " Updated demo repo configuration to use demo features." | |||
|
|||
Dir.chdir(@repo_dir_no_features) do | |||
FileUtils.cp_r("#{@repo_dir}/.", @repo_dir_no_features) | |||
Dir.glob("#{@repo_dir_no_features}/**/*.feature") do |file| | |||
File.unlink(file) | |||
end | |||
puts " Created demo repo without features." | |||
end | |||
|
|||
puts " Finished setting up Gitnesse for testing. Running features.", "" | |||
|
|||
at_exit do | |||
FileUtils.rm_rf(@features_dir) | |||
FileUtils.rm_rf(@repo_dir) | |||
FileUtils.rm_rf(@features_dir_no_features) | |||
FileUtils.rm_rf(@repo_dir_no_features) | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters