Skip to content

Commit

Permalink
Only deactivate fake execution if we have already been activated
Browse files Browse the repository at this point in the history
  • Loading branch information
josephwilk committed Aug 29, 2012
1 parent 426af77 commit 448093f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
15 changes: 9 additions & 6 deletions lib/fake_execution/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ def self.activate!

def self.deactivate!
Kernel.class_eval do
alias_method :fake_backtick, :`
alias_method :`, :real_backtick
# Have we been activated?
if method_defined?(:real_backtick)
alias_method :fake_backtick, :`
alias_method :`, :real_backtick

alias_method :fake_system, :system
alias_method :system, :real_system
alias_method :fake_system, :system
alias_method :system, :real_system

alias_method :fake_exec, :exec
alias_method :exec, :real_exec
alias_method :fake_exec, :exec
alias_method :exec, :real_exec
end
end
true
end
Expand Down
3 changes: 2 additions & 1 deletion spec/fake_execution/spec_helpers_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'fake_execution/spec_helpers'

describe "require fake_execution/spec_helpers" do
require 'fake_execution/spec_helpers'
include FakeExecution::SpecHelpers

before(:each) do
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
require 'fake_execution/spec_helpers'

RSpec.configure do |config|
config.extend(FakeExecution::SpecHelpers)
config.include FakeExecution::SpecHelpers
end

0 comments on commit 448093f

Please sign in to comment.