Permalink
Browse files

Passing features using gitnesse-example-sinatra as guinea pig

  • Loading branch information...
1 parent 1120cb6 commit edb037a509b829bfc9ad26e2acbf491334aa88aa @stewart stewart committed Dec 17, 2012
View
@@ -15,4 +15,3 @@ spec/reports
test/tmp
test/version_tmp
tmp
-/config/gitnesse.rb
@@ -1,5 +0,0 @@
-Gitnesse.configure do |config|
- config.repository_url = "git@github.com:hybridgroup/gitnesse.wiki.git"
- config.annotate_results = true
- config.info = "Bob Martin's development laptop"
-end
@@ -1,31 +1,47 @@
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
-Given /^there is a code repo without any cucumber features defined$/ do
- pending # express the regexp above with the code you wish you had
-end
-
-When /^developer pulls feature stories from the wiki$/ do
- pending # express the regexp above with the code you wish you had
+Given /^there is a git wiki without any cucumber features defined$/ do
+ @features_dir = File.join(Dir.home, ".gitnesse_features_no_features")
end
-Then /^the feature stories within the code should match the wiki$/ do
- pending # express the regexp above with the code you wish you had
+Given /^there is a code repo with cucumber features defined$/ do
+ @repo_dir = File.join(Dir.home, ".gitnesse_repo")
end
-Given /^there is a git wiki without any cucumber features defined$/ do
- pending # express the regexp above with the code you wish you had
+Given /^there is a code repo without any cucumber features defined$/ do
+ @repo_dir = File.join(Dir.home, ".gitnesse_repo_no_features")
end
-Given /^there is a code repo with cucumber features defined$/ do
- pending # express the regexp above with the code you wish you had
+When /^developer pulls feature stories from the wiki$/ do
+ Dir.chdir(@repo_dir) do
+ `bundle exec rake gitnesse:pull &> /dev/null`
+ assert_equal $?, 0
+ end
end
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
-Then /^the the feature stories within the code should match the wiki$/ do
- pending # express the regexp above with the code you wish you had
+Then /^the feature stories within the code should match the wiki$/ do
+ 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
View
@@ -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
@@ -14,12 +14,12 @@ Feature:
Scenario: Features already exist in code but not in wiki
When developer pushes feature stories to the wiki
- Then the the feature stories within the code should match the wiki
+ Then the feature stories within the code should match the wiki
Scenario: Features pushes features from code to existing wiki
When developer pushes feature stories to the wiki
- Then the the feature stories within the code should match the wiki
+ Then the feature stories within the code should match the wiki
Scenario: Features pulls features from wiki to existing code
When developer pulls feature stories from the wiki
- Then the the feature stories within the code should match the wiki
+ Then the feature stories within the code should match the wiki

0 comments on commit edb037a

Please sign in to comment.