Last active
June 23, 2016 15:29
-
-
Save tiagopog/a841f2e47e2fdf9845dd04e781ff7e59 to your computer and use it in GitHub Desktop.
Ruby - Utils
This file contains hidden or 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
require 'irb' | |
class Foobar | |
def foo | |
:foo | |
end | |
end | |
Foobar.class_eval do | |
def bar | |
:bar | |
end | |
end | |
class Foobar | |
def foobar | |
:foobar | |
end | |
end | |
Foo.new.foo #=> :foo | |
Foo.new.bar #=> :bar | |
Foo.new.foobar #=> :foobar | |
Foo.new.methods.grep /(foo|bar)/ #=> [:foo, :bar, :foobar] | |
IRB.start |
This file contains hidden or 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
"44444401".reverse.scan(/\d{3}|\d{1,2}/).map(&:reverse).reverse.join '.' #=> "44.444.401" |
This file contains hidden or 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
shared_examples_for '#send_to_managers' do | |
it 'sends a notification to every Business\' manager' do | |
worker = Sidekiq::Extensions::DelayedMailer | |
options = { method: :summary_report, id: summary.create.id } | |
worker.clear | |
summary.send_to_managers | |
is_expected.to have_enqueued_job(worker, options) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment