Skip to content

Instantly share code, notes, and snippets.

View keeran's full-sized avatar
💭
bug fixes and performance improvements

Keeran Raj Hawoldar keeran

💭
bug fixes and performance improvements
View GitHub Profile
# /features/authentication/homepage.feature
Feature: Homepage
Scenario Outline: Popular Activity
Given I am a new visitor
When I go to /notes
Then I should see an error message
# /features/steps/authentication/homepage_steps.rb
# (copied from login example)
class Item
include DataMapper::Resource
has n, :cat_as, :through => Resource
has n, :cat_bs, :through => Resource
end
class CatA
include DataMapper::Resource
has n, :items, :through => Resource
# in spec_helper.rb
def mock_warden(scope)
warden = mock('warden')
warden.stub!("authenticate_#{scope}!").and_return(true)
warden.stub!(:authenticate!).and_return(true)
return warden
end
module ControllerExampleGroupBehaviour
Given /^I will confirm on next step$/ do
begin
evaluate_script("window.alert = function(msg) { return true; }")
evaluate_script("window.confirm = function(msg) { return true; }")
rescue Capybara::NotSupportedByDriverError
end
end
$("#SearchForm #name").autocomplete("/customers/search.json",{
minChars: 2,
highlight: false,
delay: 100,
width: 310,
parse: function(data){
var array = new Array();
for (var i=0; i < data.length; i++)
{
array[i] = {data:data[i], value: data[i].first_name, result: data[i].last_name + ", " + data[i].first_name}
scope :has_all_items_in_state, lambda {|item_states|
{
:joins => :order_items, :conditions => { :order_items => { :state => item_states}},
:select => "orders.*, COUNT(order_items.id) as item_count",
:group => "orders.id",
:having => "item_count = (select count(*) from order_items where order_id = orders.id)"
}
}
SELECT hour(created_at) as hour, count(hour(created_at)) as total FROM audit_logs group by hour(created_at) order by total DESC
class Posts < ActiveRecord::Base
belongs_to :user
scope :extra, where(:extra => true)
def self.optional_scope(param = false)
if param
scope = where(:something => 'else')
else
scope = self
end
group :test, :cucumber do
gem 'capybara', :git => 'git://github.com/keeran/capybara.git'
gem 'selenium-webdriver', '0.0.27'
gem 'database_cleaner'
gem 'cucumber-rails'
gem 'cucumber'
gem 'rspec'
gem 'rspec-rails', ">= 2.0.0.beta.17"
gem 'spork'
gem 'launchy'
[2010-10-17 02:33:15] ERROR Errno::ECONNRESET: Connection reset by peer
/home/keeran/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/webrick/httpserver.rb:56:in `eof?'
/home/keeran/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/webrick/httpserver.rb:56:in `run'
/home/keeran/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'