Skip to content

Instantly share code, notes, and snippets.

@dreamr
dreamr / auth_spec_helper.pb
Created June 1, 2011 21:29
Basic Auth helpers
module AuthenticationSpecHelper
def current_user(user=nil)
@current_user ||= Factory(:user)
end
def user_session(stubs = {}, user=nil)
@current_user_session ||= mock_model(UserSession, {:user => current_user(user)})
end
def login(session_stubs = {}, user=nil)
# mine
@user_questions = UserQuestion.by_clinic_id(@clinic.id).by_user_id(current_user.id).
ordered
# yours
@user_questions = UserQuestion.where("question_id IN (?)", question_ids)
rake spec:models
(in /Users/james/development/clients/blanee)
./spec/models/../../config/../vendor/rails/railties/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010. Use #requirement
WARNING: Nokogiri was built against LibXML version 2.7.7, but has dynamically loaded 2.7.3
loading categories and citis
load finished
Mocha deprecation warning: Mocha::Standalone has been renamed to Mocha::API
......................................Ftrue
true
@dreamr
dreamr / gist:735545
Created December 10, 2010 00:01
Failing specs
1)
'AccountController AccountController should be able to upload avatar' FAILED
expected: 1,
got: 0 (using ==)
./spec/controllers/account_controller_spec.rb:144:
2)
'Pic pic should be valid when files are png or gif' FAILED
expected valid_on_create? to return true, got false
./spec/models/pic_spec.rb:18:
@dreamr
dreamr / gist:735541
Created December 9, 2010 23:57
Spec Failures
WorkOrder
adding cost codes
should not have a cost code (FAILED - 1)
should allow you to add a cost code (FAILED - 2)
should have one field cost code (FAILED - 3)
should have one engineering cost code (FAILED - 4)
has 100 hours of Field labor (FAILED - 5)
has 100 hours of Engineering labor (FAILED - 6)
will update the total field labor on save (FAILED - 7)
will update the total engineering labor on save (FAILED - 8)
@dreamr
dreamr / gist:722201
Created November 30, 2010 19:14
array.rb
class Array
def to_hash
begin
raise ArgumentError if self.collect {|x| x.flatten.size > 2}.reject {|x| x == false}.size > 0
Hash[*self.flatten]
rescue NoMethodError
raise ArgumentError
end
end
end
@dreamr
dreamr / gist:719629
Created November 29, 2010 05:53
enki_ticket_8.diff
From cfbcb70ab0a17ed97355166b4cfcab3a9f323d67 Mon Sep 17 00:00:00 2001
From: James OKelly <[email protected]>
Date: Sun, 28 Nov 2010 21:51:59 -0800
Subject: [PATCH] fixed two failing json specs in admin/posts and admin/comments
---
app/controllers/admin/pages_controller.rb | 10 ++++++----
app/controllers/admin/posts_controller.rb | 10 ++++++----
2 files changed, 12 insertions(+), 8 deletions(-)
@dreamr
dreamr / gist:719608
Created November 29, 2010 05:20
JSON specs (DESTROY) failing for comment and post
1) Admin::CommentsController handling DELETE to destroy, JSON request renders comment as json
Failure/Error: response.should contain(/#{Regexp.escape(@comment.to_json)}/)
expected the following element's content to match /\{"comment":\{"body_html":null,"created_at":null,"author":"xavier","body":null,"updated_at":null,"post_id":null,"author_email":null,"author_url":null\}\}/:
{"comment":{"comment":{"created_at":null,"body_html":null,"body":null,"author":"xavier","updated_at":null,"post_id":null,"author_email":null,"author_url":null}},"undo_path":"/admin/undo_items/%23%5BRSpec::Mocks::Mock:0x82b32e8c%20@name=%22undo_item%22%5D/undo","undo_message":"hello"}
# ./spec/controllers/admin/comments_controller_spec.rb:129
2) Admin::PostsController handling DELETE to destroy, JSON request renders post as json
Failure/Error: response.should contain(/#{Regexp.escape(@post.to_json)}/)
expected the following element's content to match /\{"post":\{"cached_tag_list":null,"slug":null,"body_html
@dreamr
dreamr / gist:719605
Created November 29, 2010 05:12
enki_ticket_6_patch.diff
From 9fbf4ca64382f48bc2df3397fbfe267172581149 Mon Sep 17 00:00:00 2001
From: James OKelly <[email protected]>
Date: Sun, 28 Nov 2010 21:10:07 -0800
Subject: [PATCH] removed pending spec on /pages route, works as intended
---
spec/controllers/pages_routing_spec.rb | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/spec/controllers/pages_routing_spec.rb b/spec/controllers/pages_routing_spec.rb
describe "pulling" do
it "should pull items from picoticker and create items" do
user = Factory.create(:user)
picoticker_block = Factory.create(:picoticker_block)
picoticker_block.user = user
picoticker_block.pull!
picoticker_block.picoticker_items.should_not be_empty
end
end