Skip to content

Instantly share code, notes, and snippets.

View Bartuz's full-sized avatar
⛑️

Filip Bartuzi Bartuz

⛑️
View GitHub Profile
@proapi
proapi / gitconfig
Last active August 29, 2015 14:05
Git pre-push hook to check against debug functions in code #git #bash
[init]
templatedir = ~/.git-templates
[color]
ui = always
[grep]
extendRegexp = true
lineNumber = true
fullName = true
[color "grep"]
filename = green
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@Bartuz
Bartuz / application_controller_spec.rb
Created October 23, 2015 16:37
before/after filters/actions rspec testing. Credits to: http://stackoverflow.com/a/20776916/2047418
# spec/controllers/application_controller_spec.rb
require 'spec_helper'
describe ApplicationController do
describe 'class' do
it { has_before_filters(:authenticate_user) }
end
end
@vsavkin
vsavkin / ddd_example2_2.rb
Created March 4, 2012 22:01
Refactored sell_book
def sell_book
@book = Book.find(params[:id])
BookSellingService.sell_book(@book)
end
@Bartuz
Bartuz / alias_matchers.md
Created November 9, 2015 11:29 — 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
@midwire
midwire / Guardfile
Last active December 31, 2015 07:09
DRY Guardfile with defined groups for running in focused mode or default mode. Switch at the Guard prompt using scope focus, or scope default.
# Run Guard normally. This Guardfile defines 2 groups:
# 1) default: This is the default group and will run all appropriate specs when anything changes.
# 2) focus: This is the group you want when you are focusing on a specific spec or context of specs. When in this
# scope Guard will only run specs tagged with :focus.
#
# Example:
# context "GET on :index, /", focus: true do
# ...
# end
#
@da4nik
da4nik / rails_confirm.js.coffee
Last active February 2, 2016 16:50
Change standart rails confirm dialog to custom
Call:
Set custom options:
= link_to talk, method: :delete, class: 'icon-close', data: {confirm: "Вы действительно хотите удалить всю переписку с данным пользователем?", confirm_options: {title: 'Удалить все сообщения', yes: 'Да', no: 'Нифига'}}, remote: true
or standart rails way
= link_to talk, method: :delete, class: 'icon-close', data: {confirm: "Вы действительно хотите удалить всю переписку с данным пользователем?"}, remote: true
@paneq
paneq / bench.rb
Last active December 11, 2016 13:00
cost of using exceptions for control flow compared to one SQL statement (ruby 2.1.4, rails 4.1.7, sqlite) for rails-refactoring.com . Development mode executed in rails console.
require 'benchmark'
ActiveRecord::Base.logger = nil
Benchmark.bmbm do |bench|
bench.report("SQL query") do
1000.times { Whatever.count }
end
bench.report("exception hit") do
@sineed
sineed / nested_attributes_for_strategy.rb
Created February 28, 2014 08:29
FactoryGirl.nested_attributes_for(your_ar_factory_with_nested_attributes)
class NestedAttributesForStrategy
def association(runner)
runner.run
end
def result(evaluation)
evaluation.object.tap do |instance|
evaluation.notify(:after_build, instance)
return attributes(instance)
end
@RedWolves
RedWolves / gist:3824059
Created October 2, 2012 23:50
Arduino Blink LED to SOS Morse code
int LED = 13;
int s = 300;
int o = 800;
void setup() {
// put your setup code here, to run once:
pinMode(LED, OUTPUT);
}
void character(int speed) {