Skip to content

Instantly share code, notes, and snippets.

View millisami's full-sized avatar
🎯
Focusing on landing a Web3 Job

Sachin Sagar Rai millisami

🎯
Focusing on landing a Web3 Job
View GitHub Profile
# Mongoid association matchers for RSpec 2.x and 1.x
#
# Save this file to your spec/support directory
#
# Usage:
#
# describe User do
# it { should reference_one :profile }
# end
#
(posted at http://groups.google.com/group/cukes/browse_thread/thread/4e01cc6e1a7071d4)
Hi Guys,
I'm the author of pickle, and despite this I broadly agree with Jonas' point of view.
The power of capybara is best realised when you do away with web_steps.rb, and start writing your own steps using capybara's dsl.
In my opinion, pickle is likewise. pickle_steps.rb is a general set of steps to both introduce the dev to the dsl, and enable rapid cuke writing in the early stages of a project.
I agree with Nick - the main point of pickle is to provide a general way of storing models for the lifetime of a scenario, and also to provide a general way of referring to them, so that you don't have to have step defs littered with variable names
@cmilfont
cmilfont / ruby_install.sh
Created October 20, 2010 14:14
ruby_install.sh
#!/usr/bin/env bash
sudo apt-get install sed grep tar curl
sudo apt-get install zlibc zlib1g zlib1g-dev zlib-bin ssh perl openssl subversion libcurl3 expat
sudo apt-get install git libxml2 libxml2-dev ruby-dev libxslt1-dev
sudo apt-get install mysql-server libmysqlclient-dev imagemagick librmagick-ruby libmagick++3 libgraphicsmagick3 libgraphicsmagick1-dev libmagick++-3 libpng3
sudo apt-get install libopenssl-ruby libssl-dev libssl0.9.8
sudo apt-get install libreadline5-dev
@visnup
visnup / Screen shot 2011-02-07 at 4.37.04 PM.png
Created February 8, 2011 00:37
# trippy mongodb colorized logging by statement type
Screen shot 2011-02-07 at 4.37.04 PM.png
@leshill
leshill / gist:870866
Created March 15, 2011 15:17
Cucumber/Capybara JS alert handling
# Add this to more_web_steps.rb
# Selenium docs: http://code.google.com/p/selenium/wiki/RubyBindings#Javascript_Alert/Confirm today!
When /^I (accept|dismiss) the "([^"]*)" alert$/ do |action, text|
alert = page.driver.browser.switch_to.alert
alert.text.should eq(text)
alert.send(action)
end
@minhajuddin
minhajuddin / gist:1043322
Created June 23, 2011 19:03 — forked from dhh/gist:1014971
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
class Foo < ActiveRecord::Base
include Models::Scopes::Order
default_scope recently_updated # didn't realize you could do this
end
@justinko
justinko / callback_disabler.rb
Created September 2, 2011 00:20
Disable raw filter callbacks in RSpec
# In spec/support/callback_disabler.rb
module CallbackDisabler
def self.store_callbacks(model, filters)
model = constantize(model)
filters.each do |filter|
model.send("_#{filter}_callbacks").each do |callback|
stored_callbacks[model] << {
filter: filter, kind: callback.kind, raw_filter: callback.raw_filter
}
@adambair
adambair / gist:1299611
Created October 19, 2011 20:46
pry is awesome.
# use instead of rails console
pry -r ./config/environment.rb
# for debugging in code put this anywhere:
binding.pry
# then check your console (rails server window) and type:
help
# win
@millisami
millisami / application.rb
Created April 7, 2012 15:31 — forked from finack/application.rb
Example Chef Deploy Revision for Rails 3+
app = node[:rails][:app]
rails_base app[:name] do
ruby_ver app[:ruby_ver]
gemset app[:gemset]
end
%w{config log pids cached-copy bundle system}.each do |dir|
directory "#{app[:app_root]}/shared/#{dir}" do
owner app[:deploy_user]