Skip to content

Instantly share code, notes, and snippets.

View hectorperez's full-sized avatar

Hector Perez hectorperez

View GitHub Profile
@hectorperez
hectorperez / capybara.md
Created November 12, 2015 12:34 — forked from steveclarke/capybara.md
RSpec Matchers

Capybara

save_and_open_page

Matchers

have_button(locator)
@hectorperez
hectorperez / Running Specs from Vim - Sent to tmux via Tslime
Created November 6, 2015 13:18
Running Specs from Vim, Sent to tmux via Tslime
<leader>t RunCurrentSpecFile
<leader>s RunNearestSpec
<leader>l RunLastSpec
<leader>a RunAllSpecs
# Install Vim plugins: vim-rspec and tslime.vim
# Add the following to .vimrc:
let g:rspec_command = 'call Send_to_Tmux("rspec {spec}\n")'
" vim-rspec mappings
@hectorperez
hectorperez / Capybara screenshot
Last active November 6, 2015 10:26
Capybara screenshot
Add to Gemfile:
gem 'capybara-screenshot'
Add to spec or rails helper:
require 'capybara-screenshot/rspec'
screenshot_and_save_page # similar to save_and_open_page but image instead of html page
@hectorperez
hectorperez / click an alert box - capybara
Created November 3, 2015 12:04
click an alert box - capybara
For WebKit:
page.accept_confirm { click_button "Upgrade" }
For Selenium:
page.driver.browser.switch_to.alert.accept
@hectorperez
hectorperez / tmux-cheatsheet.markdown
Created October 28, 2015 11:09 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@hectorperez
hectorperez / git prompt
Created October 27, 2015 10:54
git prompt
https://github.com/jimeh/git-aware-prompt
# in my bash_profile:
export GITAWAREPROMPT=~/.bash/git-aware-prompt
source "${GITAWAREPROMPT}/main.sh"
export PS1="\u@\h \w \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$ "
@hectorperez
hectorperez / insert a comment on the top of all files with an extension in a directory
Last active October 21, 2015 11:14
insert a comment on the top of all files with an extension in a directory
# If you want to add a comment to all files with an extension (e.g. ".rb"):
find . -maxdepth 1 -type f -name "*.rb" -exec sed -i '1i #comment' {} \;
# And recursive:
find . -type f -name "*.rb" -exec sed -i '1i #comment' {} \;
@hectorperez
hectorperez / Show git branch name and status in Tmux
Created October 20, 2015 16:03
Show git branch name and status in Tmux
https://github.com/jimeh/git-aware-prompt
@hectorperez
hectorperez / Can not run rails inside Tmux session
Last active November 5, 2015 14:59
Can't run rails/rspec/etc. inside Tmux session
# I had to add the following to ~/.tmux.conf:
set-option -g default-command "/bin/bash -i"
# http://superuser.com/questions/592610/cant-run-rails-inside-tmux-session-in-terminal
@hectorperez
hectorperez / disable arrow keys in Vim
Created October 2, 2015 15:29
disable arrow keys in Vim
Add to .vimrc:
nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>