Doofenshmirtz
Usage
Let your Rails code self destruct in tests.
Set an expiration date and leave a message anywhere:
Doofenshmirtz::SelfDestruct.on("2015-05-09", "This is deprecated and needs to be removed")
and in your test environment, if it is before that date, it will display a warning and let you know how much time you have until the self destruct mechanism is activated. If it is after that date, it wil throw an exception causing your tests to fail. In any other environment, it will just be ignored.
Installation
Add this line to your application's Gemfile:
gem 'doofenshmirtz'
And then execute:
$ bundle
Or install it yourself as:
$ gem install doofenshmirtz
Reporting
You can put the following in an after_suite
callback (or anywhere really)
and output what self destruct mechanisms are currently enabled. For example in
rspec, you would put the following in your spec helper.
config.after(:suite) do
Doofenshmirtz::SelfDestruct.report
end
You can also pass a custom reporter class to customize the output.
All you need to implement is the #report
method.
Doofenshmirtz::SelfDestruct.report(MyCustomerReporter)
Here is an example of a simple one that prints to stdout:
class MyCustomerReporter
attr_accessor :mechanisms
def initialize(mechanisms)
self.mechanisms = mechanisms
end
def report
mechanisms.each do |m|
puts m.location
puts m.time
puts m.reason
end
end
end
Disabling Doofenshmirtz
To temporarily disable Doofenshmirtz set DISABLE_DOOFENSHMIRTZ environment variable to true.
Contributing
- Fork it ( https://github.com/alphasights/doofenshmirtz/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request