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
module Support | |
module WithEveryCombination | |
# Takes an hash of variable names to all possible values, and creates RSpec contexts for | |
# every possible combination of values | |
# | |
# For example: | |
# with_every_combination( | |
# assignment: [Assignments::Models::Assignment.new, nil], | |
# start_date: [Date.current - rand(1..10).months, nil], | |
# end_date: [Date.current + rand(1..10).months, nil] |
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
module Support | |
module Services | |
class HaveBeenCalledMatcher | |
include RSpec::Mocks::Matchers::Matcher | |
NotCalledYet = Class.new(StandardError) | |
def initialize(&block) | |
@matcher = RSpec::Mocks::Matchers::HaveReceived.new(:call, &block) | |
end |
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
# spec/support/matchers/decorations.rb | |
module Support | |
module Matchers | |
module Decorations | |
extend RSpec::Matchers::DSL | |
def decorated_object_attributes(model, klass: nil, user: nil, context: nil) | |
context ||= {} | |
attrs = { object: model } |
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
class Dev | |
attr_accessor :level, :money, :tickets | |
def initialize | |
@level = (1..3).to_a.sample | |
@money = 0 | |
@tickets = [] | |
end | |
def take_ticket(ticket) |
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
# frozen_string_literal: true | |
desc "example task" | |
task :example_task, [:for_real] => [:environment] do |task, args| | |
ActiveRecord::Base.transaction do | |
# This is the way, do your thing here | |
unless args[:for_real] == "for_real" | |
raise "Discarded all changes. To do a real run invoke this task as follows: | |
bundle exec rake \"#{task.name}[for_real]\"\n" | |
end |
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
class BaseService | |
attr_reader :result, :errors | |
def self.call(**args) | |
new(**args).tap(&:call) | |
end | |
def success? | |
errors.blank? | |
end | |
end |
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
document.querySelectorAll('[data-tooltip-content^="Łukasz Żarski"]').forEach(gownoWartaWiadomosc => {gownoWartaWiadomosc.parentNode.parentNode.parentNode.style.display = "none";}) |
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
INSERT INTO | |
empty_new_table | |
SELECT | |
* | |
FROM | |
(WITH old_table_data AS ( | |
SELECT | |
data1, | |
data2, | |
data3 |
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
WITH my_first_with AS (SELECT foo, c FROM bar) , my_second_with AS ( SELECT foo, c FROM my_first_with) | |
SELECT * FROM my_second_with |
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
WITH my_subquery AS (SELECT * FROM table_name WHERE column_name_1 = value_1) | |
SELECT column_name_2 FROM my_subquery | |
WHERE coulumn_date > '2018-12-08' |