View watchr.rb
require 'growl' | |
require 'open3' | |
ENV["WATCHR"] = "1" | |
$spec_cmd = "rspec --tty --drb --colour --format nested" | |
$cuke_cmd = "cucumber --color --drb --require features/step_definitions --require features/support" | |
$pass = File.join(File.expand_path(File.dirname(__FILE__)), '.watchr_images', 'pass.png') | |
$fail = File.join(File.expand_path(File.dirname(__FILE__)), '.watchr_images', 'fail.png') | |
$pending = File.join(File.expand_path(File.dirname(__FILE__)), '.watchr_images', 'pending.png') |
View spec.rb
scenario "have ability to edit profile", :js => true do | |
@ability.should be_able_to(:edit, @profile) | |
end |
View example.feature
@javascript | |
Scenario: confiming when saving inactive | |
Given I expect to click "OK" on a confirmation box saying "Are you sure?" | |
When I press "Save" | |
Then the confirmation box should have been displayed | |
And I should see "TV" in the "Campaign Keywords" section | |
Scenario: alert when form is not valid | |
Given I expect to click on an alert box saying "Please complete all fields in this form" | |
When I press "Save" |
View Gemfile
gem 'spork', '~> 0.9.0.rc' |
View qunit_test.js
module("Calculator"); | |
test('calculator can perform basic operations', 2, function() { | |
var calc = new Calculator(); | |
equals (calc.sum(5,10), 15, 'Simple addition'); | |
equals (calc.multiple(5,5), 25, 'Simple multiplication'); | |
}); | |
test('AJAX addition operation', 2, function() { | |
stop(5000); // wait for up to 5 seconds |
View gist:1037984
(function() { | |
Backbone.Model.prototype._save = Backbone.Model.prototype.save; | |
Backbone.Model.prototype.save = function(attrs, options) { | |
var that = this; | |
if (!options) { options = {}; } | |
if (this.savingNewRecord) { | |
// store or replace last PUT request with the latest version, we can safely replace old PUT requests with new ones | |
// but if there are callbacks from a previous PUT request, we need to make sure they are all called as well | |
_(['success','error']).each(function(event) { | |
// convert all callbacks to a single array of callbacks) |
View drag.js
var circle = Titanium.UI.createView({ | |
height:200, | |
width:200, | |
borderRadius:50, | |
backgroundColor:'#336699', | |
top:10, | |
left:50 | |
}); | |
currentWindow.add(circle); |
View rate_limit.js
/* Extend the Underscore object with the following methods */ | |
// Rate limit ensures a function is never called more than every [rate]ms | |
// Unlike underscore's _.throttle function, function calls are queued so that | |
// requests are never lost and simply deferred until some other time | |
// | |
// Parameters | |
// * func - function to rate limit | |
// * rate - minimum time to wait between function calls | |
// * async - if async is true, we won't wait (rate) for the function to complete before queueing the next request |
View swipe_detection_example.js
var movementHistory = { | |
pointAndTimeHistory: [], | |
set: function(point) { | |
// add this point into the point and time history for velocity calculations based on time & distance | |
this.pointAndTimeHistory.push({ | |
time: new Date().getTime(), | |
x: point.x, | |
y: point.y | |
}); |
View value_for_undefined_key.js
var win = Titanium.UI.createWindow({ | |
fullscreen: true, | |
backgroundColor: '#666', | |
url: 'value_for_undefined_key_subwindow.js' | |
}); | |
win.addEventListener('ready', function() { | |
// win.close causes an error only if called immediately after window is created | |
win.close(); | |
}); |
OlderNewer