Skip to content

Instantly share code, notes, and snippets.

View virolea's full-sized avatar

Vincent Rolea virolea

View GitHub Profile
@virolea
virolea / capybara_cheat_sheet.rb
Last active March 8, 2017 11:26
Capybara Cheat Sheet
# Navigating
visit('/projects')
visit(post_comments_path(post))
expect(page).to have_current_path(post_comments_path(post))
# Clicking links and buttons
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click_on('Link Text') # clicks on either links or buttons
@virolea
virolea / customer.rb
Created April 28, 2016 16:21
Invite people from 100km of headquarters - from text file
class Customer
include Math
EARTH_RADIUS = 6371 # Earth Radius in km
attr_accessor :id, :name, :latitude, :longitude
def initialize(params)
@id = params["user_id"]
@name = params["name"]
@virolea
virolea / flatten.rb
Created April 28, 2016 16:19
Flatten an array of nest arrays
def flatten(array)
return "Input must be an array" if !array.kind_of?(Array)
array.reduce([]) do |res, el|
Array === el ? res + flatten(el) : res << el
end
end