Skip to content

Instantly share code, notes, and snippets.

View hugomaiavieira's full-sized avatar

Hugo Maia Vieira hugomaiavieira

View GitHub Profile
@hugomaiavieira
hugomaiavieira / rspec_rails_set_session.md
Created March 10, 2021 20:18 — forked from dteoh/rspec_rails_set_session.md
Setting session variables in an RSpec Rails request spec

Setting session variables in an RSpec Rails request spec

You are writing a spec with type: :request, i.e. an integration spec instead of a controller spec. Integration specs are wrappers around Rails' ActionDispatch::IntegrationTest class. I usually write controller tests using this instead of type: :controller, mainly because it exercises more of the request and response handling stack. So instead of writing something like get :index to start the request, you would write get books_path or similar.

One of the issues with using type: :request is that you lose the ability to

@hugomaiavieira
hugomaiavieira / upl.sh
Last active August 29, 2015 14:08 — forked from passalini/upload_to_upl_io.sh
Upload files to upl.io through command line
# This command receives a file as param, upload it to upl.io and copy the url to
# the clipboard
#
# Dependencies: curl and xclip
#
# Install: copy this code to your .bashrc or .zshrc
#
# Example:
#
# $ upload_file ~/Images/algorich-logo.png
@hugomaiavieira
hugomaiavieira / ohmygems.sh
Created November 3, 2012 14:49
Oh My Gems! Gemsets made easy and error free (http://blog.zenspider.com/blog/2012/09/ohmygems.html)
# This is basically the same Ryan Davis's script
# (http://blog.zenspider.com/blog/2012/09/ohmygems.html) with a bug fix and some
# modifications.
#
# This should be added after rbenv config lines on your .profile or .bashrc file.
#
export ORIG_GEM_PATH=${GEM_PATH:-}
export ORIG_GEM_HOME=${GEM_HOME:-}
export ORIG_PATH=${PATH}