Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

WIP

  • Loading branch information...
commit 3f5cd823dfd2880d27eb19d37076b8ccd59ea739 1 parent 4266350
authored November 23, 2011 deadlyicon committed November 23, 2011
1  .gitignore
... ...
@@ -0,0 +1 @@
  1
+log/*
2  features/step_definitions/sleep_steps.rb
... ...
@@ -1,3 +1,3 @@
1 1
 Then /^this scenario should take (\d+) seconds? to run$/ do |n|
2  
-  sleep n.to_f
  2
+  ExampleHobsonProject.sleep_and_log_for n
3 3
 end
25  lib/example_hobson_project.rb
... ...
@@ -0,0 +1,25 @@
  1
+require 'logger'
  2
+
  3
+module ExampleHobsonProject
  4
+
  5
+  extend self
  6
+
  7
+  def root
  8
+    @root ||= Pathname.new File.expand_path('../..', __FILE__)
  9
+  end
  10
+
  11
+  def logger
  12
+    @logger ||= begin
  13
+      root.join('log').mkpath
  14
+      Logger.new(root.join('log/app.log'))
  15
+    end
  16
+  end
  17
+
  18
+  def sleep_and_log_for n
  19
+    n.to_i.times do
  20
+      logger.info "sleeping for 1 second"
  21
+      sleep 1
  22
+    end
  23
+  end
  24
+
  25
+end
2  spec/a_spec.rb
@@ -3,7 +3,7 @@
3 3
 describe 'a' do
4 4
 
5 5
   it "should take 1 second to run this spec" do
6  
-    sleep 1
  6
+    ExampleHobsonProject.sleep_and_log_for 1
7 7
   end
8 8
 
9 9
 end
2  spec/b_spec.rb
@@ -3,7 +3,7 @@
3 3
 describe 'b' do
4 4
 
5 5
   it "should take 2 seconds to run this spec" do
6  
-    sleep 2
  6
+    ExampleHobsonProject.sleep_and_log_for 2
7 7
   end
8 8
 
9 9
 end
2  spec/c_spec.rb
@@ -3,7 +3,7 @@
3 3
 describe 'c' do
4 4
 
5 5
   it "should take 3 seconds to run this spec" do
6  
-    sleep 3
  6
+    ExampleHobsonProject.sleep_and_log_for 3
7 7
   end
8 8
 
9 9
 end
2  spec/d_spec.rb
@@ -3,7 +3,7 @@
3 3
 describe 'd' do
4 4
 
5 5
   it "should take 4 seconds to run this spec" do
6  
-    sleep 4
  6
+    ExampleHobsonProject.sleep_and_log_for 4
7 7
   end
8 8
 
9 9
 end

0 notes on commit 3f5cd82

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