features/steps/common.rb in newgem-1.0.7 vs features/steps/common.rb in newgem-1.1.0
- old
+ new
@@ -1,14 +1,20 @@
def in_project_folder(&block)
- project_folder = @active_project_folder
+ project_folder = @active_project_folder || @tmp_root
FileUtils.chdir(project_folder, &block)
end
+def in_home_folder(&block)
+ FileUtils.chdir(@home_path, &block)
+end
+
Given %r{^a safe folder} do
FileUtils.rm_rf @tmp_root = File.dirname(__FILE__) + "/../../tmp"
FileUtils.mkdir_p @tmp_root
+ FileUtils.mkdir_p @home_path = File.expand_path(File.join(@tmp_root, "home"))
@lib_path = File.expand_path(File.dirname(__FILE__) + '/../../lib')
+ Given "env variable $HOME set to '#{@home_path}'"
end
Given %r{^this project is active project folder} do
Given "a safe folder"
@active_project_folder = File.expand_path(File.dirname(__FILE__) + "/../..")
@@ -110,9 +116,18 @@
Then %r{^output (does|does not) match \/(.*)\/} do |does, regex|
actual_output = File.read(@stdout)
(does == 'does') ?
actual_output.should(match(/#{regex}/)) :
actual_output.should_not(match(/#{regex}/))
+end
+
+Then %r{^contents of file '(.*)' (does|does not) match \/(.*)\/} do |file, does, regex|
+ in_project_folder do
+ actual_output = File.read(file)
+ (does == 'does') ?
+ actual_output.should(match(/#{regex}/)) :
+ actual_output.should_not(match(/#{regex}/))
+ end
end
Then %r{^all (\d+) tests pass} do |expected_test_count|
expected = %r{^#{expected_test_count} tests, \d+ assertions, 0 failures, 0 errors}
actual_output = File.read(@stdout)