spork 0.5.5 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,7 +17,7 @@ Feature: Cucumber integration with rails
17
17
  # need to restart spork for it take effect.
18
18
 
19
19
  # Sets up the Rails environment for Cucumber
20
- ENV['RAILS_ENV'] = "cucumber"
20
+ ENV['RAILS_ENV'] = "features"
21
21
  require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
22
22
 
23
23
  require 'webrat'
@@ -59,22 +59,23 @@ Feature: Cucumber integration with rails
59
59
  """
60
60
  $loaded_stuff << 'features/support/cucumber_rails_helper.rb'
61
61
  """
62
- And a file named "config/environments/cucumber.rb" with:
62
+ And a file named "config/environments/features.rb" with:
63
63
  """
64
64
  # your cucumber env here
65
65
  """
66
66
  And a file named "config/database.yml" with:
67
67
  """
68
- cucumber:
68
+ features:
69
69
  adapter: sqlite3
70
- database: db/cucumber.sqlite3
70
+ database: db/features.sqlite3
71
71
  timeout: 5000
72
72
  """
73
73
  And a file named "features/step_definitions/cucumber_rails_steps.rb" with:
74
74
  """
75
75
  Then "it should work" do
76
76
  Spork.state.should == :using_spork
77
- RAILS_ENV.should == 'cucumber'
77
+ RAILS_ENV.should == 'features'
78
+ (Rails.respond_to?(:logger) ? Rails.logger : ActionController::Base.logger).info "hey there"
78
79
  $loaded_stuff.should include('ActiveRecord::Base.establish_connection')
79
80
  $loaded_stuff.should include('User')
80
81
  $loaded_stuff.should include('UserObserver')
@@ -101,3 +102,5 @@ Feature: Cucumber integration with rails
101
102
  When I fire up a spork instance with "spork cucumber"
102
103
  And I run cucumber --drb features/cucumber_rails.feature
103
104
  Then the output should contain "It worked!"
105
+ And the file "log/features.log" should include "hey there"
106
+
@@ -48,6 +48,7 @@ Feature: Rails Integration
48
48
  describe "Did it work?" do
49
49
  it "checks to see if all worked" do
50
50
  Spork.state.should == :using_spork
51
+ (Rails.respond_to?(:logger) ? Rails.logger : ActionController::Base.logger).info "hey there"
51
52
  $loaded_stuff.should include('ActiveRecord::Base.establish_connection')
52
53
  $loaded_stuff.should include('User')
53
54
  $loaded_stuff.should include('UserObserver')
@@ -62,3 +63,4 @@ Feature: Rails Integration
62
63
  When I fire up a spork instance with "spork rspec"
63
64
  And I run spec --drb spec/did_it_work_spec.rb
64
65
  Then the output should contain "Specs successfully run within spork, and all initialization files were loaded"
66
+ And the file "log/test.log" should include "hey there"
@@ -56,6 +56,12 @@ When /^I fire up a spork instance with "spork(.*)"$/ do |spork_opts|
56
56
  end
57
57
  end
58
58
 
59
+ Then /the file "([^\"]*)" should include "([^\"]*)"/ do |filename, content|
60
+ in_current_dir do
61
+ File.read(filename).should include(content)
62
+ end
63
+ end
64
+
59
65
  Then /^the (error output|output) should contain$/ do |which, text|
60
66
  (which == "error output" ? last_stderr : last_stdout).should include(text)
61
67
  end
@@ -1,6 +1,7 @@
1
1
  class Spork::AppFramework::Rails < Spork::AppFramework
2
2
 
3
3
  # TODO - subclass this out to handle different versions of rails
4
+ # Also... this is the nastiest duck punch ever. Clean this up.
4
5
  module NinjaPatcher
5
6
  def self.included(klass)
6
7
  klass.class_eval do
@@ -8,11 +9,25 @@ class Spork::AppFramework::Rails < Spork::AppFramework
8
9
  alias :load_environment_without_spork :load_environment
9
10
  alias :load_environment :load_environment_with_spork
10
11
  end
12
+
13
+ def self.run_with_spork(*args, &block) # it's all fun and games until someone gets an eye poked out
14
+ if ENV['RAILS_ENV']
15
+ Object.send(:remove_const, :RAILS_ENV)
16
+ Object.const_set(:RAILS_ENV, ENV['RAILS_ENV'].dup)
17
+ end
18
+ run_without_spork(*args, &block)
19
+ end
20
+
21
+ class << self
22
+ unless method_defined?(:run_without_spork)
23
+ alias :run_without_spork :run
24
+ alias :run :run_with_spork
25
+ end
26
+ end
11
27
  end
12
28
  end
13
29
 
14
30
  def load_environment_with_spork
15
- reset_rails_env
16
31
  result = load_environment_without_spork
17
32
  install_hooks
18
33
  result
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spork
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Harper