Skip to content

Instantly share code, notes, and snippets.

@davidrichards
Created September 9, 2011 20:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidrichards/1207298 to your computer and use it in GitHub Desktop.
Save davidrichards/1207298 to your computer and use it in GitHub Desktop.
Takeaways from Jasmine Class
group :development, :test do
gem "growl_notify"
gem "guard-jasmine-headless-webkit"
# Can bring this back in when we're ready to go with 3.1
# gem "jasmine-rails"
gem "jasmine-headless-webkit"
gem "rb-fsevent"
gem "guard-jammit", :git => "git://github.com/johnbintz/guard-jammit.git"
end
// This was a generic class that Justin gave us, when we can avoid constructors
(function(){
window.Game = function(){
var self = {};
//public methods
self.play = function(){}
//private methods
var score = function() {};
return self;
};
var game = Game();
game.play()
//game.score => error
})();
# ==========
# = Idioms =
# ==========
# Nested spies
graphSpy =
pokeDataInto: jasmine.createSpy 'pokeDataInto'
updateSummary: jasmine.createSpy 'updateSummary'
# Test Generator
for val in [45..90]
((val) -> it "...", ->
...
expect(...)toEqual(val)
)(val)
# DOM Fixtures
$dz = $.jasmine.inject("<div class='danger-zone' />")
# DOM Ready
spyOn($.fn, 'ready')
domready = $.fn.ready.mostRecentCall.args[0]
# or
domready = $.fn.ready.calls[0].args[0]
# Constructors
class window.App.Collections.FooBars
constructor: (attrs) ->
@attrs = attrs
# Conditional spy: ensure the double gets a particular value
# Removes more than 1 expectation in the spec
getter = spyOn(patient, 'get').andCallFake (attrName) ->
'some existing foobars' if attrName == 'fooBars'
# Custom Matchers
# expect(8).toHavePrimeFactors(2,2,2)
beforeEach ->
@addMatchers:
toHavePrimeFactors: ->
result = primeFactors(@actual)
@env.equals_(result, arguments)
# In case the above is buggy, here's the tested original:
# beforeEach(function () {
# this.addMatchers({
# toHavePrimeFactors: function() {
# var result = primeFactors(this.actual);
# return this.env.equals_(result, arguments);
# }
# });
# });
#
# Deep equals
@env.equals_(result, arguments)
# function arguments
@env.equals_(result, arguments)

Libraries

Setting up Jenkins

  1. wget http://mirrors.jenkins-ci.org/war/latest/jenkins.war

  2. Invoke the .war file (in OS X, double click)

  3. Visit Jenkins at http://localhost:8080

  4. Add some plugins: AnsiColor Git Github Authentication plugin Github plugin

  5. Setup a build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment