Skip to content

Instantly share code, notes, and snippets.

View renaehodgkins's full-sized avatar

Renae Hodgkins renaehodgkins

View GitHub Profile

Unit tests should pass when run in random order. But for an existing legacy project certain tests might depend on the execution order. One test might run perfectly fine by itself, but fail miserably when run after another test. Rather than running different combinations manually, RSpec 2.8 has the option to run specs in random order with the --order random flag. But even with this it can be hard to determine which specific test is causing the dependency. For example:

rspec spec/controllers  # succeeds

rspec spec/lib/my_lib_spec.rb # succeeds

@renaehodgkins
renaehodgkins / gist:1602614
Created January 12, 2012 19:40
intrdea-stg
renaebair@siren ~/workspace/intridea/newsite (railsupgrade)
→ git push intridea-stg railsupgrade:master
Counting objects: 7, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 354 bytes, done.
Total 4 (delta 3), reused 0 (delta 0)
-----> Heroku receiving push
-----> Removing .DS_Store files
@renaehodgkins
renaehodgkins / gist:1601509
Created January 12, 2012 16:40
suuuuckkkk
renaebair@siren ~/workspace/intridea/newsite (railsupgrade)
→ heroku logs --tail --app intridea-stg
2012-01-12T16:37:13+00:00 app[web.1]: => Rails 3.1.0 application starting in production on http://0.0.0.0:29146
2012-01-12T16:37:13+00:00 app[web.1]: => Booting WEBrick
2012-01-12T16:37:13+00:00 app[web.1]: => Call with -d to detach
2012-01-12T16:37:13+00:00 app[web.1]: => Ctrl-C to shutdown server
2012-01-12T16:37:13+00:00 app[web.1]:
2012-01-12T16:37:13+00:00 app[web.1]:
2012-01-12T16:37:13+00:00 app[web.1]: Started GET "/" for 72.44.60.192 at 2012-01-12 11:37:13 -0500
2012-01-12T16:37:14+00:00 app[web.1]: ** [Airbrake] Success: Net::HTTPOK
Betterfly connects talented individuals directly with people who want their skills. Their community is comprised of people who believe in the power of "better" and are redefining the ways in which people better themselves.
Betterfly came to us for direction on updating their existing design to further engage and serve the members of their community. Our Design team helped them rethink everything about their site from content and layout to strategies for products and custom profiles. We designed a fresh user interface, an intuitive layout, and bright, modern visuals.
@renaehodgkins
renaehodgkins / blogs_helper.rb
Created January 10, 2012 19:44
_top_footer.html.erb
def post_link(post, blog = nil, html_options = {})
method = (html_options.delete(:url) == true ? "url" : "path")
# send "blog_post_#{method}", post.published_on.year, post.published_on.month, post.published_on.day, post.slug
blog_post_path(post.published_on.year, post.published_on.month, post.published_on.day, post.slug)
end
@renaehodgkins
renaehodgkins / test
Created November 17, 2011 17:14
test
renaebair@siren ~/workspace/intridea/passport (master)
→ rails server
/Users/renaebair/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require': no such file to load -- RMagick2.so (LoadError)
from /Users/renaebair/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `block in require'
from /Users/renaebair/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `block in load_dependency'
from /Users/renaebair/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:640:in `new_constants_in'
from /Users/renaebair/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `load_dependency'
from /Users/renaebair/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
from /Users/renaebair/.rvm/gems/ruby-1.9.2-p180/gems/rmagick-2.13.1/lib/rmagick.rb:11:in `<top (required)>'
f
@renaehodgkins
renaehodgkins / admin post
Created November 15, 2011 18:56
admin post
<div class='post<%= " post-#{post.blog.name}" rescue nil %>'>
<p class='title'><%= @preview ? post.title : link_to(post.title, post_link(post, blog)) %></p>
<div class='meta'>
<span class='author'><%= post.user.name || post.user.login %></span> <span class='date_wrap'>on <span class='publish_date'><%= post.published_on.strftime("%b. %d") %></span></span>
<div class='clearfix'></div>
</div>
<% if current_user && @preview %>
<div class="admin_links">
<%= link_to 'Edit this post', edit_admin_post_path(post), :class => 'edit_post' %>
<%= link_to 'Delete this post', admin_post_path(post), :method => :delete,
@renaehodgkins
renaehodgkins / halp
Created November 15, 2011 18:54
halp
NoMethodError in Admin/posts#show
Showing app/views/shared/_post.html.erb where line #24 raised:
Attempt to call private method
Extracted source (around line #24):
21:
22: <div class='body'>
23: <%= link_to image_tag(post.image(:large), :class => "post_image_large"), post.image(:large) if post.image? %>
#!/usr/bin/env ruby -wKU
require 'yaml'
class TimeTrack
attr_accessor :projects
FILENAME = 'timelog.yml'
def initialize
prepare_data_file
read_data
#!/usr/bin/env ruby -wKU
require 'yaml'
class TimeTrack
def initialize(project_name)
@project_name = project_name
@time_list = project_filename