Skip to content

Instantly share code, notes, and snippets.

View aakashd's full-sized avatar

aakash dharmadhikari aakashd

View GitHub Profile
GIT
remote: git://github.com/gregbell/active_admin.git
revision: 18438fcc82ef12f74d43f65766125eac466f79fc
ref: 18438fcc82ef12f74d43f65766125eac466f79fc
specs:
activeadmin (0.5.0)
arbre (>= 1.0.1)
bourbon (>= 1.0.0)
devise (>= 1.1.2)
fastercsv
@aakashd
aakashd / gist:7453860
Created November 13, 2013 18:26
BrowserStack IE 8 on Windows XP stack trace for http://demo.okendoken.com/index.html
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729)
Timestamp: Wed, 13 Nov 2013 18:25:07 UTC
Message: Object doesn't support this property or method
Line: 4
Char: 6105
Code: 0
@aakashd
aakashd / nutrition_data.rb
Created May 7, 2013 19:11
ActiveAdmin multi level has many configuration within Snacker
class NutritionData < ActiveRecord::Base
attr_accessible :calories, :calories_from_fat, :header, :item_id, :serving, :nutrition_items_attributes
validates :calories, :presence => true, :numericality => true
validates :calories_from_fat, :presence => true, :numericality => true
validates :header, :presence => true
validates :serving, :presence => true
belongs_to :item
@aakashd
aakashd / gist:2899980
Created June 9, 2012 07:30
output of stub_spec.rb
A method stub
ignores when expected message is received with no args
allows a stub and an expectation
instructs an instance to respond_to the message
calculates return value by executing block passed to #and_return
handles multiple stubbed methods
ignores when expected message is not received
instructs a class object to respond_to the message
overrides a pre-existing method
keeps returning last value in consecutive calls
#with rspec
payment.should be_cancelled
#bad example
assert_equal 4, payment.code
#good example
assert_equal Payment::Status::CANCELLED, payment.code
@aakashd
aakashd / my ideal test
Created May 17, 2012 11:43
An ideals test structure
context "context of a small business scenario"
should "exact business requirement" do
<on doing this>
<this happens>
end
end
@aakashd
aakashd / application_controller_spec.rb
Created April 11, 2012 11:39
Specs for application controller
require 'spec_helper'
class DummyApplicationController < ApplicationController
before_filter :require_authentication, :only => :authenticated_resource
before_filter :check_if_self, :only => :dummy_method_to_test_check_for_self
def get_action
render :nothing => true
end
def authenticated_resource
@aakashd
aakashd / app_auth_headers.rb
Created July 22, 2011 18:42
Custom auth header for ActiveResource requests
class AppAuthHeaders
cattr_accessor :remember_token
def self.headers
remember_token.blank? ? {"Authorization" => ""} : {"Authorization" => "RememberToken #{self.remember_token}"}
end
end
class BuildPostProcessor
def notify_on_failure(&block)
on_failure_notifier = BuildNotification.new
@build_statuses[:failure] << [block, on_failure_notifier]
end
def on_success_build_artifacts(artifacts_builder)
@build_statuses[:success] << artifacts_builder.new
yield(artifacts_builder.new)
end