-
Notifications
You must be signed in to change notification settings - Fork 901
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Manually require framework helpers individually and refactor the RSpe…
- Loading branch information
Ben Atkins
committed
Oct 2, 2013
1 parent
379506a
commit 39decb3
Showing
5 changed files
with
88 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,29 @@ | ||
if defined? World | ||
# before hook for Cucumber | ||
before do | ||
::PaperTrail.enabled = false | ||
::PaperTrail.whodunnit = nil | ||
::PaperTrail.controller_info = {} if defined? ::Rails | ||
end | ||
# before hook for Cucumber | ||
before do | ||
::PaperTrail.enabled = false | ||
::PaperTrail.whodunnit = nil | ||
::PaperTrail.controller_info = {} if defined? ::Rails | ||
end | ||
|
||
module PaperTrail | ||
module Cucumber | ||
module Extensions | ||
# :call-seq: | ||
# with_versioning | ||
# | ||
# enable versioning for specific blocks | ||
module PaperTrail | ||
module Cucumber | ||
module Extensions | ||
# :call-seq: | ||
# with_versioning | ||
# | ||
# enable versioning for specific blocks | ||
|
||
def with_versioning | ||
was_enabled = ::PaperTrail.enabled? | ||
::PaperTrail.enabled = true | ||
begin | ||
yield | ||
ensure | ||
::PaperTrail.enabled = was_enabled | ||
end | ||
def with_versioning | ||
was_enabled = ::PaperTrail.enabled? | ||
::PaperTrail.enabled = true | ||
begin | ||
yield | ||
ensure | ||
::PaperTrail.enabled = was_enabled | ||
end | ||
end | ||
end | ||
end | ||
|
||
World PaperTrail::Cucumber::Extensions | ||
end | ||
|
||
World PaperTrail::Cucumber::Extensions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,22 @@ | ||
if defined? RSpec | ||
require 'rspec/core' | ||
require 'rspec/matchers' | ||
require File.expand_path('../rspec/extensions', __FILE__) | ||
require 'rspec/core' | ||
require 'rspec/matchers' | ||
require File.expand_path('../rspec/extensions', __FILE__) | ||
|
||
RSpec.configure do |config| | ||
config.include ::PaperTrail::RSpec::Extensions | ||
RSpec.configure do |config| | ||
config.include ::PaperTrail::RSpec::Extensions | ||
|
||
config.before(:each) do | ||
::PaperTrail.enabled = false | ||
::PaperTrail.whodunnit = nil | ||
::PaperTrail.controller_info = {} if defined?(::Rails) && defined?(::RSpec::Rails) | ||
end | ||
|
||
config.before(:each, :versioning => true) do | ||
::PaperTrail.enabled = true | ||
end | ||
config.before(:each) do | ||
::PaperTrail.enabled = false | ||
::PaperTrail.whodunnit = nil | ||
::PaperTrail.controller_info = {} if defined?(::Rails) && defined?(::RSpec::Rails) | ||
end | ||
|
||
RSpec::Matchers.define :be_versioned do | ||
# check to see if the model has `has_paper_trail` declared on it | ||
match { |actual| actual.kind_of?(::PaperTrail::Model::InstanceMethods) } | ||
config.before(:each, :versioning => true) do | ||
::PaperTrail.enabled = true | ||
end | ||
end | ||
|
||
RSpec::Matchers.define :be_versioned do | ||
# check to see if the model has `has_paper_trail` declared on it | ||
match { |actual| actual.kind_of?(::PaperTrail::Model::InstanceMethods) } | ||
end |