Skip to content

Instantly share code, notes, and snippets.

View AhmedNadar's full-sized avatar
🌎
Ready to work remote with you 😀 💻 🤝 👏🏼

Ahmed Nadar AhmedNadar

🌎
Ready to work remote with you 😀 💻 🤝 👏🏼
View GitHub Profile
@AhmedNadar
AhmedNadar / rspec_model_testing_template.rb
Created December 26, 2016 08:43
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there.
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@AhmedNadar
AhmedNadar / rspec_cheatsheet_controller_spec.rb
Created December 26, 2016 08:42
RSpec Controller Test Cheatsheet
require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
context "GET index" do
#context "POST create" do
#context "GET show" do
#context "PATCH update" do (or PUT update)
#context "DELETE destroy" do
#context "GET new" do
@AhmedNadar
AhmedNadar / Get Launching
Created June 17, 2016 18:58
Get Launching Cheat Sheet provided by RubyThursday.com -- updated 5/21/16
1. Open terminal and check versions of Ruby and Rails against production server params or to make sure you are using the most recent stable versions.
$ ruby -v
$ rvm list
$ rvm list known
$ rvm install ruby 2.3.1
$ rvm list
$ ruby -v
$ gem install rails
$ rails -v
@AhmedNadar
AhmedNadar / spork_rspec.md
Last active October 7, 2015 09:48
Solution when Spork fails with Rspec

Spork and Rspec

Problem

Using spork4 and rspec 3, when run spork in terminal, it fails and show this following message:

Using RSpec, Rails
Preloading Rails environment
Loading Spork.prefork block...
---------------------------------------------------------------------------------------------------------
# app/helpers/application_helper.rb
---------------------------------------------------------------------------------------------------------
def horizontal_simple_form_for(record, options={}, &block)
options[:html] ||= {}
options[:html][:class] = "form-horizontal #{options[:html][:class]}".rstrip
options[:wrapper] = :bootstrap_horizontal
simple_form_for(record, options, &block)
end
---------------------------------------------------------------------------------------------------------
#!/usr/bin/ruby
--database=postgresql
--skip-bundle
--skip-keeps
--skip-test
template=/path-to-template.rb
@AhmedNadar
AhmedNadar / rails_template.rb
Last active August 29, 2015 14:15
Rails Template
module RailsTemplate
module Gem
extend self
def use(name, options={})
require_path = options[:require] || name
begin
require require_path
rescue LoadError
system "gem install #{name}"
@AhmedNadar
AhmedNadar / IRB_colors.md
Created February 18, 2015 06:21
Settings for IRB colors

Settings for IRB colors

To get some nice colors in your irb, you can install the gems awesome_print and interactive_editor. There should be a dot file (hidden file) in your home directory called .irbrc, if not just create it: sublime ~/.irbrc.

gem install awesome_print
gem install interactive_editor
sublime ~/.irbrc

Tam's settings

@AhmedNadar
AhmedNadar / admin_users-with_active_admin.rb
Last active August 29, 2015 14:04
Create Admin Users with Active Admin using email only!
# As admin you can create other Admin Users with thier email only where password link is sent via email
# 1- Gemfile
gem 'devise'
gem 'activeadmin', github: 'gregbell/active_admin'
# 2- Install Devise then Active Admin
rails g devise:install
rails g active_admin:install
# You might see other instructions inthe terminal, just follow them

Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

This guide enables you to install (ruby-build) and use (rbenv) multiple versions of ruby, isolate project gems (gemsets and/or bundler), and automatically use appropriate combinations of rubies and gems.

TL;DR Demo

# Ensure system is in ship-shape.

aptitude install git zsh libssl-dev zlib1g-dev libreadline-dev libyaml-dev