Skip to content

Instantly share code, notes, and snippets.

View RobertFischer's full-sized avatar

Robert Fischer RobertFischer

View GitHub Profile
@RobertFischer
RobertFischer / Rakefile.rb
Created July 16, 2014 13:28
Addition to Rakefile to enable database name
# I don't think these database names are wrong, but you should be able to get the idea
class ActiveRecord::Migration
def self.whSalesDbName
return "DevSalesDb" if(ENV['NODE_ENV'] != "production")
return "SalesDb"
end
end
@RobertFischer
RobertFischer / ModelTestBase.java
Created July 24, 2014 15:33
Example of a base class for models.
/**
* The base class for models.
*
* @param <T> The type of the model under test.
*/
public abstract class ModelTestBase<T extends Serializable> {
/**
* Responsible for generating a test instance.
*
@RobertFischer
RobertFischer / geb_boilerplate.groovy
Created August 6, 2014 18:44
Geb Boilerplate Script
// The first time you run this, it will take a very long, annoyingly silent pause while it loads libraries
@Grapes([
@Grab("org.gebish:geb-core:0.9.3"),
@Grab("org.seleniumhq.selenium:selenium-firefox-driver:2.41.0"),
@Grab("org.seleniumhq.selenium:selenium-support:2.41.0")
])
import geb.Browser
Browser.drive {
@RobertFischer
RobertFischer / Namespaced CSS
Created August 11, 2014 18:59
Namespsaced CSS
<!--
In your SCSS file:
.bootstrap {
// All your bootstrap specific SCSS here
}
-->
<body class="bootstrap">
<!--
Widgets here will get "bootstrap"-namespaced styling
@RobertFischer
RobertFischer / gist:7e4f072910770823ba03
Last active February 22, 2017 07:48
Lazybones Can't Use Cached Versions
tmp$ lazybones list --cached
Cached templates
ext-geb 1.0.0
lazybones-project 1.0.1
tmp$ lazybones create ext-geb folder1
Creating project from template ext-geb (latest) in 'folder1'
Cannot find a template named 'ext-geb'. Project has not been created.
@RobertFischer
RobertFischer / gist:e42fb29b76bbad4a903f
Created August 12, 2014 16:07
Lazybones: Attempting to do something without authorization
lazybones$ gradle -i --stacktrace publishAllTemplates
Starting Build
Settings evaluated using empty settings script.
Projects loaded. Root project using build file '/Users/RCFischer/webonise/lazybones/build.gradle'.
Included projects: [root project 'lazybones']
Evaluating root project 'lazybones' using build file '/Users/RCFischer/webonise/lazybones/build.gradle'.
All projects evaluated.
Selected primary task 'DefaultTaskParameter{taskName='publishAllTemplates',projectPath='null'}'
Tasks to be executed: [task ':packageTemplateExtGeb', task ':publishTemplateExtGeb', task ':publishAllTemplates']
:packageTemplateExtGeb (Thread[main,5,main]) started.
@RobertFischer
RobertFischer / signIn.groovy
Created August 12, 2014 20:57
signIn method
String signUp(Map namedArgs = [:], String firstName = 'Test', String lastName = 'User') {
namedArgs = namedArgs ?: [:] // In case they passed null to be a stinker
email = '[email protected]'
bothPasswords = "password"
setFullName(firstName, lastName)
organisation = namedArgs.remove('organisation') ?: "Webonise Farm"
phoneNumber = namedArgs.remove('phoneNumber') ?: "8001234567"
optionalTextingNumber = namedArgs.remove('optionalTextingNumber') ?: null
address = namedArgs.remove('address') ?: "9001 Glenwood Ave"
apartment = namedArgs.remove('apartment') ?: "100"
@RobertFischer
RobertFischer / errors.js
Last active August 29, 2015 14:05
Error Examples
/*
Three functions:
One if the message is hard-coded.
One if the message is provided entirely by the user.
One if the message needs a suffix provided by the user.
You could also create a function that used JavaScript's sprintf
and the arguments object (cast to an object by _.toArray()) for
truly flexible error messaging. That is left as an exercise for
the team.
@RobertFischer
RobertFischer / SamplePage.groovy
Created August 25, 2014 16:50
Example of content implementation — Geb
class SamplePage {
static theResultDivImpl = { /* Your impl here */ }
static at = { /* Your basic test here */ && waitFor(theResultDivImpl) }
static content = {
theResultDiv(wait:true, theResultDivImpl)
}
@RobertFischer
RobertFischer / option_or_not.scala
Created September 30, 2014 15:47
When Option.get() isn't...
scala> var opt = Some("Foo")
opt: Some[String] = Some(Foo)
So far, so good. I want to get the value from my Some. Checking the API for Option, and there's a .get() to retrieve the value — http://www.scala-lang.org/api/current/index.html#scala.Option
scala> opt.get()
<console>:9: error: not enough arguments for method apply: (index: Int)Char in class StringOps.
Unspecified value parameter index.
opt.get()
^