Skip to content

Instantly share code, notes, and snippets.

View zpieslak's full-sized avatar

Zbigniew Pieślak zpieslak

View GitHub Profile
#!/usr/bin/env ruby
#
# Convert VCR cassettes that use basic auth to work with Webmock 2. Takes the folder where the VCR
#cassettes are stored as an argument.
require 'yaml'
require 'base64'
FOLDER = File.expand_path(ARGV[0])
FILES = Dir["#{File.join(FOLDER, '**', '*.yml')}"]
@zpieslak
zpieslak / alias_matchers.md
Created May 30, 2016 07:59 — 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
@zpieslak
zpieslak / .rb
Created July 23, 2015 13:27
DataStructure
class DataStructure
def initialize
@data = {}
@default = nil
end
def set(index, value)
@data[index] = value
end
@zpieslak
zpieslak / gem-reset
Last active August 29, 2015 14:15 — forked from nixpulvis/gem-reset
#!/usr/bin/env ruby
# Remove all gems EXCEPT defaults :)
`gem list -d`.split(/\n\n^(?=\w)/).each do |data|
match = data.match(/(?<name>([^\s]+)) \((?<versions>.*)\)/)
name = match[:name]
versions = match[:versions].split(', ')
if match = data.match(/^.*\(([\d\.]*),? ?default\): .*$/)
next if match[1].empty? # it's the only version if this match is empty

Capybara

save_and_open_page

Matchers

have_button(locator)
@zpieslak
zpieslak / uri.js
Created December 11, 2013 13:55 — forked from jlong/uri.js
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
=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')