summaryrefslogtreecommitdiff
path: root/features/step_definitions
diff options
context:
space:
mode:
authorLuis Lavena <luislavena@gmail.com>2008-11-03 23:21:56 -0300
committerLuis Lavena <luislavena@gmail.com>2008-11-03 23:21:56 -0300
commit4fcf40073fe878e7d53dc7ae18cfe10c157462b9 (patch)
treee5365ff42cb2c0347c6433cd547e01cf7ef9009f /features/step_definitions
parent835b0d32735b3b0bc0c3f8ef83d8efb6bc4a0c3d (diff)
downloadrake-compiler-4fcf40073fe878e7d53dc7ae18cfe10c157462b9.tar.gz
Updated compile feature to match and cover required acceptance.
Thanks to David Chelimsky for the suggestions on irc.
Diffstat (limited to 'features/step_definitions')
-rw-r--r--features/step_definitions/compilation.rb24
-rw-r--r--features/step_definitions/execution.rb27
-rw-r--r--features/step_definitions/folders.rb2
3 files changed, 25 insertions, 28 deletions
diff --git a/features/step_definitions/compilation.rb b/features/step_definitions/compilation.rb
index 020a3d8..015cac8 100644
--- a/features/step_definitions/compilation.rb
+++ b/features/step_definitions/compilation.rb
@@ -4,21 +4,18 @@ Given /^scaffold code for extension '(.*)'$/ do |extension_name|
setup_source_for extension_name
end
-Given /^binary extension '(.*)' do exist in '(.*)'$/ do |extension_name, folder|
- setup_binaries_for extension_name, folder
-end
-
-Given /^intermediate files for extension '(.*)' do exist in '(.*)'$/ do |extension_name, folder|
- setup_intermediate_files_for extension_name, folder
+Given /^not changed any file since$/ do
+ # don't do anything, that's the purpose of this step!
end
When /^touching '(.*)' file of extension '(.*)'$/ do |file, extension_name|
+ Kernel.sleep 1
FileUtils.touch "ext/#{extension_name}/#{file}"
end
-Then /^binary extension '(.*)' (must|must not) exist in '(.*)'$/ do |extension_name, condition, folder|
+Then /^binary extension '(.*)' (do|do not) exist in '(.*)'$/ do |extension_name, condition, folder|
ext_for_platform = File.join(folder, "#{extension_name}.#{RbConfig::CONFIG['DLEXT']}")
- if condition == 'must'
+ if condition == 'do'
File.exist?(ext_for_platform).should be_true
else
File.exist?(ext_for_platform).should be_false
@@ -63,14 +60,3 @@ def setup_source_for(extension_name)
ext.puts template_extconf(extension_name)
end
end
-
-def setup_binaries_for(extension_name, folder)
- ext_for_platform = File.join(folder, "#{extension_name}.#{RbConfig::CONFIG['DLEXT']}")
- FileUtils.touch ext_for_platform
-end
-
-def setup_intermediate_files_for(extension_name, folder)
- setup_binaries_for(extension_name, folder)
- FileUtils.touch "#{folder}/Makefile"
- FileUtils.touch "#{folder}/source.#{RbConfig::CONFIG['OBJEXT']}"
-end
diff --git a/features/step_definitions/execution.rb b/features/step_definitions/execution.rb
index 74c25ef..186e654 100644
--- a/features/step_definitions/execution.rb
+++ b/features/step_definitions/execution.rb
@@ -1,13 +1,19 @@
+Given %r{^I've already successfully executed rake task '(.*)'$} do |task_name|
+ emptyness = `rake #{task_name} 2>&1`
+ puts emptyness
+ raise "rake failed with #{$?.exitstatus}" unless $?.success?
+ puts File.mtime("lib/extension_one.so")
+ puts File.mtime("tmp/extension_one/extension_one.so")
+end
+
When /^rake task '(.*)' is invoked$/ do |task_name|
@output ||= {}
@result ||= {}
- FileUtils.chdir @safe_dir do
- @output[task_name] = `rake #{task_name} 2>&1`
- @result[task_name] = $?.success?
- end
+ @output[task_name] = `rake #{task_name} 2>&1`
+ @result[task_name] = $?.success?
end
-When /^rake task '(.*)' succeeded$/ do |task_name|
+Then /^rake task '(.*)' succeeded$/ do |task_name|
if @result.nil? || !@result.include?(task_name) then
raise "The task #{task_name} should be invoked first."
else
@@ -15,8 +21,11 @@ When /^rake task '(.*)' succeeded$/ do |task_name|
end
end
-Then /^output of rake task '(.*)' (does|does not) match \/(.*)\/$/ do |task_name, condition, regexp|
- (condition == 'does') ?
- @output[task_name].should(match(%r[#{regexp}])) :
- @output[task_name].should_not(match(%r[#{regexp}]))
+Then /^output of rake task '(.*)' (contains|do not contain) \/(.*)\/$/ do |task_name, condition, regex|
+ puts @output[task_name]
+ if condition == 'contains' then
+ @output[task_name].should match(%r(#{regex}))
+ else
+ @output[task_name].should_not match(%r(#{regex}))
+ end
end
diff --git a/features/step_definitions/folders.rb b/features/step_definitions/folders.rb
index cab1e3b..7a430a8 100644
--- a/features/step_definitions/folders.rb
+++ b/features/step_definitions/folders.rb
@@ -1,4 +1,6 @@
Given /^a safe project directory$/ do
+ # step back to ROOT
+ Dir.chdir ROOT_PATH
tmp_name = "project.#{Process.pid}"
@safe_dir = File.join(ROOT_PATH, 'tmp', tmp_name)
FileUtils.rm_rf @safe_dir