Skip to content
This repository
Browse code

cucumber support files use modules instead of polluting root namespace

  • Loading branch information...
commit efe250e4d397a84b3ae04ce52b47d8a604241ee0 1 parent d119542
Dr Nic Williams authored March 17, 2009
2  features/step_definitions/cli_steps.rb
... ...
@@ -1,5 +1,3 @@
1  
-# force_local_lib_override
2  
-
3 1
 When /^I execute rbiphonetest for project '(.*)' with options '(.*)'/ do |project_name, arguments|
4 2
   setup_active_project_folder project_name
5 3
   in_tmp_folder do
9  features/support/cli.rb
... ...
@@ -1,3 +1,8 @@
1  
-def rbiphonetest_cmd
2  
-  @rbiphonetest_cmd ||= File.expand_path(File.dirname(__FILE__) + "/../../../bin/rbiphonetest")
  1
+module CliHelpers
  2
+  def rbiphonetest_cmd
  3
+    @rbiphonetest_cmd ||= File.expand_path(File.dirname(__FILE__) + "/../../../bin/rbiphonetest")
  4
+  end
3 5
 end
  6
+
  7
+World { |world| world.extend CliHelpers }
  8
+
42  features/support/common.rb
... ...
@@ -1,25 +1,29 @@
1  
-def in_tmp_folder(&block)
2  
-  FileUtils.chdir(@tmp_root, &block)
3  
-end
  1
+module CommonHelpers
  2
+  def in_tmp_folder(&block)
  3
+    FileUtils.chdir(@tmp_root, &block)
  4
+  end
4 5
 
5  
-def in_project_folder(&block)
6  
-  project_folder = @active_project_folder || @tmp_root
7  
-  FileUtils.chdir(project_folder, &block)
8  
-end
  6
+  def in_project_folder(&block)
  7
+    project_folder = @active_project_folder || @tmp_root
  8
+    FileUtils.chdir(project_folder, &block)
  9
+  end
9 10
 
10  
-def in_home_folder(&block)
11  
-  FileUtils.chdir(@home_path, &block)
12  
-end
  11
+  def in_home_folder(&block)
  12
+    FileUtils.chdir(@home_path, &block)
  13
+  end
13 14
 
14  
-def force_local_lib_override(project_name = @project_name)
15  
-  rakefile = File.read(File.join(project_name, 'Rakefile'))
16  
-  File.open(File.join(project_name, 'Rakefile'), "w+") do |f|
17  
-    f << "$:.unshift('#{@lib_path}')\n"
18  
-    f << rakefile
  15
+  def force_local_lib_override(project_name = @project_name)
  16
+    rakefile = File.read(File.join(project_name, 'Rakefile'))
  17
+    File.open(File.join(project_name, 'Rakefile'), "w+") do |f|
  18
+      f << "$:.unshift('#{@lib_path}')\n"
  19
+      f << rakefile
  20
+    end
19 21
   end
20  
-end
21 22
 
22  
-def setup_active_project_folder project_name
23  
-  @active_project_folder = File.join(@tmp_root, project_name)
24  
-  @project_name = project_name
  23
+  def setup_active_project_folder project_name
  24
+    @active_project_folder = File.join(@tmp_root, project_name)
  25
+    @project_name = project_name
  26
+  end
25 27
 end
  28
+
  29
+World { |world| world.extend CommonHelpers }

0 notes on commit efe250e

Please sign in to comment.
Something went wrong with that request. Please try again.