Skip to content

Instantly share code, notes, and snippets.

View searls's full-sized avatar
💚

Justin Searls searls

💚
View GitHub Profile
public class ShardsOGlassSalesman {
private BoxOfGlassPops boxOfGlassPops;
...
@Autowired
public void setBoxOfGlassPops(BoxOfGlassPops boxOfGlassPops) {
this.boxOfGlassPops = boxOfGlassPops;
}
}
if(squirrel.getId() == otherSquirrel.getId()) {
squirrel.goFindSomeNutsOrSomething();
}
public class ActionSupport implements TextProvider, ... {
private final transient TextProvider textProvider =
new TextProviderFactory().createInstance(getClass(), this);
...
public String getText(String aTextName) {
return textProvider.getText(aTextName);
}
@Before
public void feelDirty() {
target = new MyActionSupportSubclass() {
@Override public String getText(String aTextName) {
return aTextName;
}
@Override public String getText(String key, String[] args) {
return key + ":" + StringUtils.join(args, ',');
}
};
(function($){
$.jasmine = {
isReady:false,
rootId: 'specContainer',
inject:function(html,overwriteAll) {
if($.cil.jasmine.isReady === false) $.cil.jasmine.init();
if(overwriteAll === true) {
$('#'+$.cil.jasmine.rootId).html(html);
} else {
$('#'+$.cil.jasmine.rootId).append(html);
@searls
searls / ValidationMatcher.java
Created November 30, 2010 16:51
A handy matcher allowing you to assert that a bean is JSR-303 compliant. Usage might look like: `assertThat(beanUnderTest,is(valid));`
package com.pillartechnology.matchers;
import java.util.HashSet;
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import org.hamcrest.Description;
@searls
searls / HtmlUnitPageFromString.java
Created December 17, 2010 14:26
HtmlUnit's documentation doesn't make it abundantly clear how to run assertions against an HTML string snippet (i.e. the easiest way to run tests when you don't care about URLs, network connections, etc.)
private HtmlPage getPage(String html) {
MockWebConnection webConnection = new MockWebConnection();
webConnection.setDefaultResponse(html);
WebClient webClient = new WebClient();
webClient.setWebConnection(webConnection);
try {
return webClient.getPage("http://blah");
} catch (Exception e) {
throw new RuntimeException(e);
}
@interface ... {
UITextField *someField;
}
- (IBAction)dismissKeyboard:(id)sender;
{
[someField becomeFirstResponder];
[someField resignFirstResponder];
}
module TabulaRasa
class BlankSlate
instance_methods.each { |m| undef_method m unless m =~ /^__/ }
end
class Stub < BlankSlate
attr_accessor :stubbings
attr_reader :invocations
def initialize(cls)
@searls
searls / gist:796211
Created January 26, 2011 04:09
fun with underscore templates!
<script id="someTemplate" type="text/html">
<span class="warning-image"></span><p>{{ error }}</p></span>
</script>
------
(function($){
$.fn.renderTemplate = function(name,context) {
$(this).html(_($('#'+name).html()).template(context));