Skip to content

Instantly share code, notes, and snippets.

View balinterdi's full-sized avatar
👌
Enjoying life, including work.

Balint Erdi balinterdi

👌
Enjoying life, including work.
View GitHub Profile
describe "Sinatra::MyHelpers" do
describe "sessions" do
before do
mock_app {
set(:sessions => true)
include Sinatra::MyHelpers
get '/login' do
session[:ok] = "Ok."
end
def shared_to?(object, by_user=nil)
shareable = ActiveRecord::Base.send(:class_name_of_active_record_descendant, self.class).to_s
to = ActiveRecord::Base.send(:class_name_of_active_record_descendant, object.class).to_s
if by_user
s = Share.find(:first, :conditions=>["shareable_type = ? and shareable_id = ? and shared_to_type = ? and shared_to_id = ? and user_id=?",
shareable, id, to, object.id, by_user.id])
else
s = Share.find(:first, :conditions=>["shareable_type = ? and shareable_id = ? and shared_to_type = ? and shared_to_id = ?",
shareable, id, to, object.id])
end
require "yaml"
require "forwardable"
require "pp"
require "ruby-debug"
class Hash
def has_nested_key?(key)
h = self
key.to_s.split('.').each do |segment|
return false unless h.key?(segment)
Scenario: Create album
Given I am logged in as "pepito"
When I go to my profile page
...
Given /^the user (.*) exists$/ do |login_name|
User.find_by_login(login_name) || Factory(:user_with_password, :login => login_name)
end
Given /^I log in as (.*)$/ do |login_name|
#
# cucumber.yml
#
# Filter which features are run with each profile by the file extension
webrat: --require features/steps/common --require features/support/webrat_env.rb --exclude selenium.feature --format progress
selenium: --require features/steps/common --require features/support/selenium_env.rb --exclude webrat.feature --format progress
#
# features/support/env.rb
default: -r features/support/env.rb -r features/support/plain.rb -r features/step_definitions features/plain
selenium: -r features/support/env.rb -r features/support/enhanced.rb -r features/step_definitions features/enhanced
-rw-r--r-- 1 deploy deploy 10011 Mar 30 19:46 README
-rw-r--r-- 1 deploy deploy 307 Mar 30 19:46 Rakefile
drwxr-xr-x 6 deploy deploy 4096 Mar 27 12:45 app
drwxr-xr-x 5 deploy deploy 4096 Apr 1 12:23 config
drwxr-xr-x 2 deploy deploy 4096 Mar 30 19:46 db
drwxr-xr-x 2 deploy deploy 4096 Mar 30 19:46 doc
drwxr-xr-x 3 deploy deploy 4096 Mar 30 19:46 lib
drwxrwxr-x 2 mongrel deploy 4096 Apr 1 11:28 log
drwxr-xr-x 5 deploy deploy 4096 Mar 27 12:52 public
drwxr-xr-x 3 deploy deploy 4096 Mar 30 19:46 script
@balinterdi
balinterdi / gist:107361
Created May 6, 2009 05:13
Rails app template for the acts_as_trivia gem
# App template for generating acts_as_trivia enable applications
# See http://github.com/balinterdi/acts_as_trivia/tree/master
def ask_with_default(question, default='')
user_answer = ask(question).strip
user_answer.empty? ? default : user_answer
end
# generate a model class
model_name_and_attributes = ask_with_default("Define the model in Rails resource generate style. (e.g country name:string population:integer)", "country name:string population:integer")
class ControllerHelper
include Singleton
include ActionView::Helpers
end
def url_helpers
ControllerHelper.instance
end
#
@wip @users
Feature:
...