Skip to content

Instantly share code, notes, and snippets.

Avatar

Corey Haines coreyhaines

View GitHub Profile
View gist:41758
class Rectangle
attr_accessor :width, :height
def initialize(width, height)
self.width = width
self.height = height
end
def area
width * height
@coreyhaines
coreyhaines / string_tokenizer.rb
Created Jan 24, 2009
String Tokenizer Kata for Code Retreat
View string_tokenizer.rb
module StringTokenizer
VERSION = '0.0.1'
def tokenize(context)
self.gsub(/\$[^ ]*/) {|match|
context[match[1..-1].to_sym]
}
end
end
View gist:54731
List<MyThing> things = new List<MyThing> {
new MyThing { DueDate = DateTime.Now.AddDays(1),
new MyThing { DueDate = DateTime.Now.AddDays(-14)}}
};
View gist:54735
List<MyThing> things = new List<MyThing> {
thing(DateTime.Now.AddDays(1)),
thing(DateTime.Now.AddDays(-14))
}
View gist:54737
public MyThing thing(DateTime duedate){
return new MyThing {DueDate = duedate};
}
View gist:54738
public static class ThingTestingUtilities {
public static Thing NewThing(this TestsThings tester, DateTime duedate) {
return new MyThing { DueDate = duedate};
}
}
View gist:54739
List<MyThing> things = new List<MyThing> {
this.NewThing(DateTime.Now.AddDays(1)),
this.NewThing(DateTime.Now.AddDays(-14))
}
View gist:54741
List<MyThing> things = new List<MyThing> {
this.NewThing().WithDueDate(DateTime.Now.AddDays(1)),
this.NewThing().WithDueDate(DateTime.Now.AddDays(-14))
}
View gist:54742
public static class ThingTestingUtilities {
public static Thing NewThing(this TestsThings tester) {
return new MyThing;
}
public static Thing WithDueDate(this MyThing thing, DateTime duedate) {
thing.DueDate = duedate;
return thing;
}
}
View gist:54744
List<MyThing> things = new List<MyThing> {
this.NewThing().WithAnOffsetDueDateInDays(1),
this.NewThing().WithAnOffsetDueDateInDays(-14)
}
You can’t perform that action at this time.