Skip to content

Instantly share code, notes, and snippets.

View Bartuz's full-sized avatar
⛑️

Filip Bartuzi Bartuz

⛑️
View GitHub Profile
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=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')
@terut
terut / spec_helper.rb
Created November 21, 2011 13:33
Clean up carrierwave's files for rspec.
RSpec.configure do |config|
# ...
config.after(:all) do
if Rails.env.test?
FileUtils.rm_rf(Dir["#{Rails.root}/spec/support/uploads"])
end
end
end
# put logic in this file or initalizer/carrierwave.rb
@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
@otaviomedeiros
otaviomedeiros / validate_with_matcher.rb
Created March 14, 2012 00:05
RSpec matcher for validates_with
# RSpec matcher for validates_with.
# https://gist.github.com/2032846
# Usage:
#
# describe User do
# it { should validate_with CustomValidator }
# end
RSpec::Matchers.define :validate_with do |validator|
match do |subject|
@them0nk
them0nk / haml_cheatsheet.haml
Created March 25, 2012 08:39
haml cheatsheet
!!! strict
!!! XML
%html
-# Self closing tags
%img{:src => "happy.jpg"}/
%div.myclass
.myclass1
@bentonporter
bentonporter / gist:2891463
Created June 7, 2012 20:51
Ruby - HMAC-SHA256 example
require 'openssl'
require 'Base64'
key = "secret-key"
data = "some data to be signed"
Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha256'), key, data)).strip()
@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) {
@caniszczyk
caniszczyk / clone-all-twitter-github-repos.sh
Created October 9, 2012 04:25
Clone all repos from a GitHub organization
curl -s https://api.github.com/orgs/twitter/repos?per_page=200 | ruby -rubygems -e 'require "json"; JSON.load(STDIN.read).each { |repo| %x[git clone #{repo["ssh_url"]} ]}'
@jandudulski
jandudulski / .vimrc
Last active August 10, 2020 10:31
How to configure your editor to automatically strip trailing whitespaces and keep new line at the end of file?
if has("autocmd")
" remove trailing white spaces
autocmd BufWritePre * :%s/\s\+$//e
endif
@myronmarston
myronmarston / explanation.md
Last active October 22, 2020 18:16
Explanation for why `its` will be removed from rspec-3

its isn't core to RSpec. One the of the focuses of RSpec is on the documentation aspects of tests. Unfortunately, its often leads to documentation output that is essentially lies. Consider this spec:

User = Struct.new(:name, :email)

describe User do
  subject { User.new("bob") }
  its(:name) { should == "bob" }
end