Skip to content

Instantly share code, notes, and snippets.

View keeperofthenecklace's full-sized avatar

Albert McKeever keeperofthenecklace

  • New Jersey, U.S.A
View GitHub Profile
@keeperofthenecklace
keeperofthenecklace / spec_helper.rb
Created August 18, 2012 18:08
spec/spec_helper.rb
$:.unshift File.expand_path('..', __FILE__)
$:.unshift File.expand_path('../../lib', __FILE__)
require 'simplecov'
require 'simplecov-rcov'
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
SimpleCov.start
require 'rubygems'
require 'rspec'
@keeperofthenecklace
keeperofthenecklace / users_controller.rb
Created August 18, 2012 18:11
app/controllers/users_controller.rb
class UsersController < ApplicationController
# GET /users
# GET /users.json
def index
@users = User.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @users }
@keeperofthenecklace
keeperofthenecklace / sessions_helper.rb
Created August 18, 2012 18:15
app/helpers/sessions_helper.rb
module SessionsHelper
def sign_in(user)
cookies.permanent[:remember_token] = user.remember_token
self.current_user = user
end
def current_user=(user)
@current_user = user
end
@keeperofthenecklace
keeperofthenecklace / gist:3388820
Created August 18, 2012 18:19
app/views/application.html.erb
<!DOCTYPE html>
<html>
<head>
<title><%= full_title(yield(:title)) %> - Work In Progress</title>
<%= stylesheet_link_tag "application", media: "all" %>
<%= javascript_include_tag "application"%>
<%= csrf_meta_tags %>
<%= render 'layouts/shim' %>
</head>
@keeperofthenecklace
keeperofthenecklace / application.html.erb
Created August 18, 2012 18:22
app/views/layouts/application.html.erb
<% provide(:title, "Sign up") %>
<h1>Sign up</h1>
<div class="row">
<div class="span6 offset3">
<%= form_for(@user) do |f| %>
<%= render 'shared/error_messages' %>
<%= f.label :name %>
<%= f.text_field :name %>
@keeperofthenecklace
keeperofthenecklace / custom.cass.scss
Created August 18, 2012 18:27
app/assets/stylesheets/custom.css.scss
@import "bootstrap";
/* forms */
input, textarea, select, .uneditable-input {
border: 1px solid #bbb;
width: 100%;
padding: 10px;
height: auto;
margin-bottom: 15px;
@keeperofthenecklace
keeperofthenecklace / Testing REST APIs with Cucumber and Rack::Test
Created August 18, 2012 20:00
Testing REST APIs with Cucumber and Rack::Test
# First attempting to use Capybara directly, you will ran into issues when trying to set HTTP header.
# Using Basic HTTP Authentication requires that we needed to set the header.
# Also we need to set the Content-Type and Accept headers to ensure that Rails handles the input and output correctly.
# When using Rack, Capybara delegates request and response handling down to Rack::Test.
# So I used Rack::Test directly in my step definitions, and it works.
# Rack::Test has a module called Rack::Test::Methods that can be mixed into a class to provide it
# with methods for get, post, put, delete as well as last_request, last_response, header and more.
# I mixed Rack::Test::Methods into the Cucumber world at the top of our API steps file like so:
##############################
@keeperofthenecklace
keeperofthenecklace / routes.rb
Created August 18, 2012 20:21
config/routes.rb
resources :users
resources :sessions, only: [:new, :create, :destroy]
match '/signup', to: 'users#new'
match '/signin', to: 'sessions#new'
match '/signout', to: 'sessions#destroy', via: :delete
get "users/new"
@keeperofthenecklace
keeperofthenecklace / Github Cheat Sheet
Last active October 26, 2022 20:52
Github Cheat Sheet
Step B.) Creating a branch (and switching to the new branch in one line (Step 2)
**********
a.) git checkout -b [name of new branch]
eg. git checkout -b 2012Tryme
git fetch origin [remote-branch]:[new-local-branch] (Pulling a new branch from a remote repository)
b.) follow step 1
c.) git push origin 2012Tryme
** will add new branch to the repository on git hub
**********************
Step A.) Scheduling the addition of all files to the next commit (Step 1)
@keeperofthenecklace
keeperofthenecklace / Grep Command
Last active October 8, 2015 21:48
Grep Commands
cd ../..
grep -Rni 'albert' .
pwd - displays path
grep -ir acts_as_json - display acts_as_jason in which file
gem list | grep rspec - list all rspec associated files
gem list | grep friendly_id
grep rspec Gemfile.lock - displays all rpec gem in the gemfile.lock. You shud b in dir.
bundle - install gems from gemfile
rvm help