Skip to content

Instantly share code, notes, and snippets.

View TrumpClone's full-sized avatar

Optimus Advocate TrumpClone

View GitHub Profile
@TrumpClone
TrumpClone / alias_matchers.md
Created May 2, 2017 08:21 — forked from JunichiIto/alias_matchers.md
List of alias matchers in RSpec 3

This list is based on aliases_spec.rb.

You can see also Module: RSpec::Matchers API.

matcher aliased to description
a_truthy_value be_truthy a truthy value
a_falsey_value be_falsey a falsey value
be_falsy be_falsey be falsy
a_falsy_value be_falsey a falsy value
@TrumpClone
TrumpClone / test.rb
Created April 20, 2017 14:00
amon master
shared_context 'stub jobs', :stub_jobs do
around do |spec|
original_method = ActiveJob::Base.method(:perform_later)
begin
ActiveJob::Base.send(:define_singleton_method, :perform_later) do |*args|
RSpec::Matchers::StubJobs.state.push(class: self, args: args)
end
RSpec::Matchers::StubJobs.collect(&spec)
ensure
@TrumpClone
TrumpClone / asd
Created March 25, 2017 15:11
asd
[1] pry(main)> Distribution::Deliveries::Base.last
=> #<Distribution::Deliveries::Sendgrid @values={:id=>3, :template_id=>1, :title=>"pizda", :from=>"hyi@hui.hyi", :subject=>"poshko", :events=>["user_answered_ticket"], :method_name=>"sendgrid", :segment_type=>"eventless", :segment_name=>"allowed_for_payment_notification", :segment_params=>{}, :created_at=>2017-03-22 16:03:05 +0000, :updated_at=>nil}>
[2] pry(main)> Distribution::Deliveries::Base.last.json
NoMethodError: undefined method `json' for #<Distribution::Deliveries::Sendgrid:0x007fbdd7aec0a8>
from (pry):2:in `__pry__'
[3] pry(main)> Distribution::Deliveries::Base.last.as_json
=> {"id"=>3,
"template_id"=>1,
"title"=>"pizda",
"from"=>"hyi@hui.hyi",
def run_non_critical(fallback: nil, controller: nil, only_production: true)
if only_production && Rails.application.config.consider_all_requests_local
return yield
end
begin
if defined?(ActiveRecord::Base) && ActiveRecord::Base.connection.transaction_open?
Transaction.run(requires_new: true) { yield }
else
yield
module Events::EventDomain
class NewRegisteredUser < Base
end
end
module Synchronizable
DEFAULT_WAIT_TIME = 10.seconds
extend self
def synchronize(*args, &block)
Transaction.run { with_advisory_lock(*args, &block) }
end
private