Skip to content

Instantly share code, notes, and snippets.

View application_merge_tag_recipe_spec.rb
# frozen_string_literal: true
require 'rails_helper'
require 'app/services/doc_gen/application_merge_tag_recipe'
describe DocGen::ApplicationMergeTagRecipe do
describe '#call' do
let(:account) { Fabricate.create(:account) }
let(:loan) { FactoryBot.create(:loan, account: account, team: account.team, liability: liability) }
View rake_task.rb
namespace :foo do
desc "Removes all bars for a given foo"\
" Example: bundle exec rake foo:remove_bars[2]"
task :remove_bars, [:foo_id] => [:environment] do |t, args|
foo_id = args[:foo_id].to_i
Bar.where(foo_id: foo_id).delete_all
end
@jilucev
jilucev / bad_state.rb
Created Aug 24, 2018
Enema of the state
View bad_state.rb
# frozen_string_literal: true
module Hodor
class MainService
attr_accessor :foo_klass,
:foo,
:foo_id
:foo_status,
:bar_service,
:baz_service,
View composition_example.rb
module Foo
class Bar
attr_accessor :qux_service,
:param1,
:param2
#initialize the class and dependencies
def initialize(foo_klass = Foo)
@foo_klass = foo_klass
View gist:9404782
# In this file we define the methods to help filter out candidates
# This way, we keep these methods separated from other potential parts of the program
def experienced?(candidate)
amount_of_experience = candidate[:years_of_experience]
if amount_of_experience > 2
return true
else
return false
View gist:9382912
states = {
OR: 'Oregon',
FL: 'Florida',
CA: 'California',
NY: 'New York',
MI: 'Michigan'
}
states[:AR] = "Arkansas"
states[:HA] = "Hawaii"
@jilucev
jilucev / gist:9381660
Last active Aug 29, 2015
Here is a less messed up code w1d3
View gist:9381660
states = {
OR: 'Oregon',
FL: 'Florida',
CA: 'California',
NY: 'New York',
MI: 'Michigan'
}
states[:AR] = "Arkansas"
states[:HA] = "Hawaii"