Skip to content

Instantly share code, notes, and snippets.

View skamithi's full-sized avatar

Stanley Karunditu skamithi

  • Raleigh, North Carolina
View GitHub Profile
@skamithi
skamithi / tapaction.coffee
Created July 19, 2013 12:50
notifies user that they tapped on a button.... Work in progress..
# Requires jquery.hammer.js
# Requires wiselinks
# Add class 'tapit' to any clickable element on the page
tapAction = (element) ->
$(element).hammer().on 'tap', ->
$(this).fadeOut {
duration: 200
}
$(this).fadeIn {
@skamithi
skamithi / expect4r.gemspec
Created June 28, 2013 15:14
Most basic GemSpec. Call it <name_of_folder>.gemspec
Gem::Specification.new do |s|
s.name = "expect4r"
s.version = '0.1.0'
s.files = Dir["{lib,spec}/**/*", "[A-Z]*", "init.rb"] - ["Gemfile.lock"]
s.require_path = "lib"
s.summary = 'Expect functionality for network equipment'
s.author = ''
end
@skamithi
skamithi / function_defaults.rb
Created June 24, 2013 05:58
create a ruby function with defaults
# Default value for :user_id is generated in this function
def create_project(options = {})
options.reverse_merge!(
:user_id => @user.id
)
FactoryGirl.create(:new_project, options)
end
@skamithi
skamithi / capybara-element-not-visible-spec.rb
Last active December 18, 2015 12:59
capybara 2.0 test for element not visible for either cucumber or rspec feature tests.
context 'my element' do
before do
a =<< EOF
jQuery ->
$('body').append('<div id=empty_or_hidden_element></div>')
EOF
page.execute_script CoffeeScript.compile(a)
end
it 'should not be displayed' do
@skamithi
skamithi / capybara.rb
Created June 4, 2013 12:14
Capybara 2.0 / Rspec. Ability to launch browser when testing view specs. Not integration test..just regular view specs
#spec/support/capybara.rb
require 'capybara/rspec'
# Using chrome as browser to test in capybara.
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
end
@skamithi
skamithi / login_helper_cucumber.rb
Last active February 25, 2017 01:27
bypassing sorcery authentication for rspec feature and cucumber tests for my external authentication setup.
# feature/support/login_helper.rb
require 'spec/support/login_helper'
Before do
extend LoginHelper
@user = FactoryGirl.create(:user)
login_as @user
end
@skamithi
skamithi / .gitignore
Last active December 17, 2015 15:19
Setting up Chef-Solo
*/.gitkeep
tmp/
@skamithi
skamithi / search_field_steps.rb
Created January 1, 2013 18:21
Cucumber steps to check if search field is cleared but is still focused after the clear.
When /^I click the clear search button$/ do
find('#search_icon').click
end
Then /^the search field should be focused$/ do
page.execute_script <<-JS
if (jQuery('#search_form input[type=search]').is(':focus')) {
jQuery('#search_form').append("<div id='search_form_is_focused' />");
}
JS
@skamithi
skamithi / mock_geo.rb
Created May 20, 2012 03:16
mocking geocode in my rails3 project
## /spec/support/mock_geo.rb
## MockGeo takes an address in the following format and can produce
## fake google geocode output
## All country and state information resolves to North Carolina, USA
## Include "gem jbuilder in :test and :development group" if not already in the project.
## Example
## Output for address string *MUST* be in this format
## a = '102 My Street, My Town, , NC, 99903' OR
# a = '102 my street, my town, nc'
## b = MockGeo.new(:addr => a)
@skamithi
skamithi / .vimrc
Last active October 4, 2015 05:27
my rails related vimrc
runtime bundle/pathogen/autoload/pathogen.vim
call pathogen#infect()
call pathogen#helptags()
syntax on
filetype plugin indent on
set number
set tabstop=2
set shiftwidth=2
set expandtab
set textwidth=80