Skip to content

Instantly share code, notes, and snippets.

View jeffdeville's full-sized avatar

Jeff Deville jeffdeville

View GitHub Profile

Continuous CoffeeScript testing with Guard and Jasmine

This Gist shows how to set up a Rails project to practice BDD with CoffeeScript, Guard and Jasmine. You can see this setup in action on Vimeo

  • Install Gems with Bundler with bundle install
  • Define your guards with mate Guardfile
  • Initialize Jasmine with bundle exec jasmine init
  • Configure Jasmine with mate spec/support/yasmine.ym
  • Start Guard with bundle exec guard
@jeffdeville
jeffdeville / rvm_output
Created January 18, 2011 03:22
rvm trace for wayne
> rvm use ree; rvm --trace rubygems 1.3.7
Using /Volumes/files/jeffdeville/.rvm/gems/ree-1.8.7-2010.02
+__rvm_parse_args:440> [[ -z 4.3.9 ]]
+__rvm_parse_args:597> [[ -z '' && -n '' ]]
+__rvm_parse_args:599> [[ 0 -eq 1 || -n '' ]]
+__rvm_parse_args:15> [[ -n rubygems ]]
+__rvm_parse_args:17> rvm_token=rubygems
+__rvm_parse_args:19> [[ 1 -gt 0 ]]
+__rvm_parse_args:19> next_token=1.3.7
+__rvm_parse_args:19> shift
-------------------
> rvm rubygems 1.3.7
-------------------
Removing old Rubygems files...
Installing rubygems dedicated to system...
Installing rubygems for /bin/ruby
Error running 'GEM_PATH="/Volumes/files/jeffdeville/.rvm/gems/ree-1.8.7-2010.02....." GEM_HOME="/Volumes/files/jeffdeville/.rvm/gems/ree-1.8.7-2010.02" "/bin/ruby" "/Volumes/files/jeffdeville/.rvm/src/rubygems-1.3.7/setup.rb"'
ln: /lib/ruby/gems/: No such file or directory
@jeffdeville
jeffdeville / mock_login_user.js
Created January 14, 2011 02:04
mocking the logging in of a user using the facebook javascript sdk.
describe('user is not logged in', function(){
it('should log in the user', function(){
var response = {
session: null
};
spyOn(FB, 'init');
spyOn(FB, 'getLoginStatus');
spyOn(FB, 'login');
context "user was someones friend before" do
before do
@user = User.new(:facebook_id => 502884401, :is_user => false)
mock_load_existing_user(@user, @access_token)
mock_delay_update_user
Action.stubs(:user_create).with(502884401)
end
it "should audit the user creation" do
Action.expects(:user_create).with(502884401)
@jeffdeville
jeffdeville / rspec_mocha_stub_problem.rb
Created November 12, 2010 18:13
Showing a problem with overridding class methods in mocha
before do
mock_load_request
mock_audit_gift_create
mock_save_request
end
it "should load the request" do
mock_load_request("expects")
act
end
<li>
<a class='prodImage' href='#' target='_blank'>
<img alt='' src='/images/wg_noProdImage.png'>
</a>
<a class='prodTitle' href='#'>
From here, i can just recommend whatever I want.
</a>
<a class='rate_button' href="javascript:">Select</a>
<input id='gi_4cd9dafc404aaa17ca000062_selected' name='gi[4cd9dafc404aaa17ca000062][selected]' type='hidden' value='false'>
<br class='clear'>
@jeffdeville
jeffdeville / bundle-update-error
Created November 5, 2010 03:08
errors received after last bundle update
/Volumes/files/jeffdeville/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/package/tar_input.rb:49:in `initialize': not in gzip format (Zlib::GzipFile::Error)
from /Volumes/files/jeffdeville/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/package/tar_input.rb:49:in `new'
from /Volumes/files/jeffdeville/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/package/tar_input.rb:49:in `initialize'
from /Volumes/files/jeffdeville/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/package/tar_reader.rb:64:in `each'
from /Volumes/files/jeffdeville/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/package/tar_reader.rb:55:in `loop'
from /Volumes/files/jeffdeville/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/package/tar_reader.rb:55:in `each'
from /Volumes/files/jeffdeville/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/package/tar_input.rb:32:in `initialize'
from /Volumes/files/jeffdeville/.rvm/rubies/ree-1.8.7-2010.02/
def self.get_potentials(interest_ids)
return {} if interest_ids.nil? ||interest_ids.empty?
map = <<-eos
function() {
for(var i in this.value.users) {
emit(this.value.users[i], 1);
}
};
eos
reduce = <<-eos