- Use describe blocks for objects and methods ("given" scenarios)
- Use context blocks for "when" scenarios
- Avoid spec descriptions longer than 40 characters. Split into contexts if longer.
- Prefer expect syntax
- Use before blocks at the lowest scope necessary
- e.g. start within it blocks, then move into describe, then only if necessary for all tests put outside of those.
- Use validation tests and place them at the top of the describe block
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var input = [[2,6],[3,5],[7,21],[20,21]]; | |
var expectedOutput = [[2,6],[7,21]]; | |
var rangesOverlap = function(range1, range2) { | |
return ( | |
(range1[1] >= range2[0] && range1[1] <=range2[1]) || | |
(range1[0] <= range2[0] && range1[1] >= range2[0]) | |
); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var params = { t: 123, type: 'mytype', channelId: 'mychan', badge:'thebadge' }; | |
var allowedPersonParams = ["type", "channelId", "badge", "since", "until"]; | |
// ES5 | |
var result = {}; | |
allowedPersonParams.forEach(function (paramName) { | |
if (currentParams[paramName]) { | |
result[paramName] = currentParams[paramName]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>console test</title> | |
<link rel="shortcut icon" type="image/png" href="lib/jasmine-2.2.0/jasmine_favicon.png"> | |
<link rel="stylesheet" href="lib/jasmine-2.2.0/jasmine.css"> | |
<script src="lib/jasmine-2.2.0/jasmine.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:%s/\/\*\{-1}\_.\{-}\*\///g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Gmail Client (ideas) | |
Usage: | |
var gmailClient = newGmailClient(myAccessToken); | |
var response = gmailClient.execute({ | |
url: "users/me/messages", | |
headers: {}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Zwei Dinge hat das Denken zu leisten: uns aus der naiven zur vertiefen Welt- | |
und Lebensbejahung zu füren und uns von ethischen Regungen zu einer | |
denknotwendigen Ethic gelangen zu lassen. | |
Vertiefe Welt- und Lebensbejahung besteht darin, dass wir den Willen haben, | |
unser Leben und alles durch uns irgendwie beeinflussbare Sein zu erhalten und | |
auf seinen höchsten Wert zu bringen. Sie verlangt von uns, dass wir alle | |
Ideale der materiellen und geistigen Vervollkommnung des Menschen, der | |
Gesellschaft und der Menschheit denken und uns durch sie zu stetem Wirken und | |
stetem Hoffen bestimmen lassen. Sie erlaubt uns nicht, uns auf uns selber |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Wrap given block with link if.. | |
def link_wrap_if(apply_link, url, opts={}, &block) | |
if apply_link | |
link_to capture(&block), url, opts | |
else | |
capture(&block) | |
end | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
require 'socket' | |
ENV["RAILS_ENV"] = "test" | |
# Add test folder to load path | |
$: << './test' | |
puts Benchmark.measure{ | |
# Assuming test_helper requires config/environment |