Skip to content

Instantly share code, notes, and snippets.

@ruprict
ruprict / refinerycms_blog_post.html.erb_spec.rb
Created June 30, 2011 10:46
RefineryCMS Blog partial view spec
require 'spec_helper'
describe "blog/shared/_post.html.erb" do
let (:post) do
stub_model(BlogPost,
:title => "Blog",
:published_at => Time.now
)
end
@ruprict
ruprict / gist:1117147
Created July 31, 2011 19:55
Rails 3.1 rails new output
create
create README
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
create app/assets/images/rails.png
create app/assets/javascripts/application.js
create app/assets/stylesheets/application.css
@ruprict
ruprict / gist:1142447
Created August 12, 2011 16:50
PhoneGap jquery Mobile issue
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<!-- iPad/iPhone specific css below, add after your main css >
<link rel="stylesheet" media="only screen and (max-device-width: 1024px)" href="ipad.css" type="text/css" />
<link rel="stylesheet" media="only screen and (max-device-width: 480px)" href="iphone.css" type="text/css" />
@ruprict
ruprict / pnunn_spec_helper.rb
Created September 8, 2011 12:23
Loccasions help
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
##Clean up the database
require 'database_cleaner'
require 'capybara/rspec'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
class OccasionsController < InheritedResources::Base
belongs_to :event
actions :all, :except => [:show, :index]
# Need to override this from inherited_resources
# to scope the association chain to the current_user
def begin_of_association_chain
current_user
end
end
@ruprict
ruprict / gist:1514903
Created December 23, 2011 17:50
Nothing to see here
We couldn’t find that file to show.
@ruprict
ruprict / gist:1572301
Created January 6, 2012 20:37
TK Errors
Error:
test: Given new Kyck by non-fan and kycker Tags a Team to Kyck and a second Kyck by non-fan with this team tagged to the Kyck should generate User-Tag score increment for non-fan kycker. (UserRelevanceCalculatorTest):
ArgumentError: wrong number of arguments (2 for 1)
/Users/ggoodrich/.rvm/gems/ruby-1.9.2-p290@kyck/gems/mocha-0.10.0/lib/mocha/object.rb:90:in `stubs'
/Users/ggoodrich/rb/rails_apps/kyck/Web/test/unit/top_kyck/user_relevance_calculator_test.rb:23:in `block (3 levels) in <class:UserRelevanceCalculatorTest>'
/Users/ggoodrich/.rvm/gems/ruby-1.9.2-p290@kyck/gems/shoulda-2.11.3/lib/shoulda/context.rb:400:in `call'
/Users/ggoodrich/.rvm/gems/ruby-1.9.2-p290@kyck/gems/shoulda-2.11.3/lib/shoulda/context.rb:400:in `block in run_current_setup_blocks'
/Users/ggoodrich/.rvm/gems/ruby-1.9.2-p290@kyck/gems/shoulda-2.11.3/lib/shoulda/context.rb:399:in `each'
/Users/ggoodrich/.rvm/gems/ruby-1.9.2-p290@kyck/gems/shoulda-2.11.3/lib/shoulda/context.rb:399:in `run_current_setup_blocks
@ruprict
ruprict / gist:1584127
Created January 9, 2012 17:57
Test errors
15) Error:
test: Given 3 days of Kycks when the scorer has never been run before should generate scores for Kycks within the past 2 days. (ScorerTest):
Mocha::ExpectationError: unexpected invocation: #<Object:0x104727d38>.publish('channel' => '/users/NcqqRNBRmUZwua1x68JS/notifications', 'message' => {'id' => 1, 'unread' => true, 'kind' => 'post_commented', 'text' => 'John Doe121 has commented on your KYCK', 'partialText' => 'has commented on your KYCK', 'objID' => 1, 'objType' => 'Post', 'objAlias' => nil, 'createdAt' => '2012-01-09T00:00:00Z', 'previewURL' => nil, 'previewRatio' => nil, 'initiator' => {'id' => 1, 'firstName' => 'John', 'lastName' => 'Doe121', 'avatarURL' => 'http://192.168.1.143:3000/assets/default_avatar.gif', 'alias' => nil, 'followedByCurrentUser' => false}})
unsatisfied expectations:
- expected exactly once, not yet invoked: Event(id: integer, name: string, starting_at: datetime, icon: string, icon_ratio: float, checkins_count: integer, posts_count: integer, created_at: datetime, update
@ruprict
ruprict / test.rb
Created January 15, 2012 18:27
SimpleAroundAware issue
require 'goliath'
class ApiValidationAroundware
include Goliath::Rack::SimpleAroundware
class InvalidApiKeyError < Goliath::Validation::BadRequestError; end
def pre_process
validate_api_key!
env.logger.info "past api_key validation" #<-- this is output, then an empty response header & body as if it is just hanging...
Goliath::Connection::AsyncResponse
@ruprict
ruprict / tag.js
Created January 19, 2012 15:38
Tag hack
var Tag = Model.subclass(function (data) {
//HACK
if (data.owner !== null){
this.mapping = {
owner: Model.mapping.object(data.ownerType)
}
if (data.owner.__ko_mapping__) {
data.owner = ko.mapping.toJS(data.owner);
}