Skip to content

Instantly share code, notes, and snippets.

View JonKernPA's full-sized avatar

Jon Kern JonKernPA

View GitHub Profile
@JonKernPA
JonKernPA / registration_management.feature
Created November 9, 2010 19:28
Simple Cucumber Example
# under features
Feature: Registration Management
Once an organizer creates a season, they can open it up for registrants to sign up.
Scenario: Add a Registration Setup
Given the "My Season" season for "Malvern YMCA"
When I add a setup for "My Season"
Then I should be able to signup under "My Season"
@JonKernPA
JonKernPA / embedded_delete_sample.rb
Created July 5, 2012 02:09
Deleting an embedded document
class Period
include MongoMapper::EmbeddedDocument
key :text, String
embedded_in :schedule
def to_s
text
end
@JonKernPA
JonKernPA / admin_smoke_test.feature
Created March 18, 2012 16:56
Cucumber UI Smoke Tests
Feature: Quickly exercise the primary ADMIN UIs just to make sure nothing blows up
Background: We need to pre-populate the database with the simulator results, and be logged in as admin
Given I login as "admin"
And we have the following Patients:
| Johnson |
| Henry |
| Walters |
| Glanzmann |
| Franklin |
@JonKernPA
JonKernPA / extending_user.rb
Created March 2, 2012 03:03
Demonstrating opening a mongomapper class and extending
# Run this in mmconsole
class User
include MongoMapper::Document
key :name
key :role
def admin?
role.index(/admin/i)
end
@JonKernPA
JonKernPA / Node.rb
Created February 16, 2012 03:10
Tree example in MongoMapper
class Node
include MongoMapper::Document
key :name
belongs_to :parent, :class_name => 'Node'
many :children, :class_name => 'Node'
def root?
parent.nil?
end
@JonKernPA
JonKernPA / resource_log_spec.rb
Created December 28, 2011 23:57
Sample RSpec for MongoMapper showing data cleanup
require File.dirname(__FILE__) + '/../spec_helper'
describe "ResourceLog" do
@@debug = false
before :all do
puts "--------------------"
ResourceLog.destroy_all
ResourceLog.count().should == 0
@JonKernPA
JonKernPA / sample_index.log
Created November 26, 2011 23:57
Examining Effect of MongoDB index using explain
without a compound index
> db.accounts.find({state: "active"}).limit(15).sort({email: 1}).explain();
{
"cursor" : "BasicCursor",
"nscanned" : 11002,
"nscannedObjects" : 11002,
"n" : 15,
"scanAndOrder" : true,
"millis" : 44,
"nYields" : 0,
@JonKernPA
JonKernPA / show_model_keys.rb
Created May 18, 2011 12:23
Model keys with MongoMapper
MongoMapper.database.collection('users').drop
class User
include MongoMapper::Document
key :name, String, :required => true
end
User.destroy_all
text = []
text << "After model with key :name, String"
text << User.keys.keys.inspect
@JonKernPA
JonKernPA / some_cynical.rb
Created April 29, 2011 02:54
Silliness for SomeSheep
=begin
Without making any comments on the cynical nature...
Instead of ::
1. list = ("brother","father","family","tribe","neighbouring tribe","regional community","fellow citizens","foreigners")
2.
3.def politics.of.dark.ages
4.n=1
5.while n<length[list]
6.PRINT "I hate my $list[n]!"
7.PRINT "But I stand with my $list[n] against my $list[n+1]"
@JonKernPA
JonKernPA / company.rb
Created January 9, 2011 17:42
Company - Job example
class Company
include MongoMapper::Document
key :name, String
many :jobs
def to_s
name
end