Brent wejrowski

View rspec-guides.markdown

General guides

  • Use describe blocks for objects and methods ("given" scenarios)
  • Use context blocks for "when" scenarios
  • Avoid spec descriptions longer than 40 characters. Split into contexts if longer.
  • Prefer expect syntax
  • Use before blocks at the lowest scope necessary
    • e.g. start within it blocks, then move into describe, then only if necessary for all tests put outside of those.
  • Use validation tests and place them at the top of the describe block
View remote-working.markdown

Remote working

Germany Time difference

Germany is 9 hours ahead---12am AZ = 9am Germany. I would be available for chat until 10am AZ time, or 1:30pm latest.

  • Work 75% of time in morning/afternoon
  • Work/save 5-6pm (9-10am here) for general standup and catch up at our normal time
    • Other weekly wednesday meetings block out more time wednesday
View gist:6499960
1 2 3 4 5 6 7 8
# Wrap given block with link if..
def link_wrap_if(apply_link, url, opts={}, &block)
if apply_link
link_to capture(&block), url, opts
else
capture(&block)
end
end
View rails_tests_in_isolation.rb
1 2 3 4 5 6 7 8 9 10
require 'benchmark'
require 'socket'
 
ENV["RAILS_ENV"] = "test"
 
# Add test folder to load path
$: << './test'
 
puts Benchmark.measure{
# Assuming test_helper requires config/environment
View css_urlstrip.rb
1 2 3 4 5 6 7 8 9 10
urls = ""
DATA.each do |l|
img = l[/url\([^)]*\)/]
urls << "<img src=#{img.gsub(/url\(([^)]*)\)/, '\1')} /><hr />\n" if img
end
 
f = File.open("urltest.html", "w") {|file| file.truncate(0) } # Clear file contents
f = File.open("urltest.html", "w")
f.write urls
f.close
View block-to-partial
1 2 3 4 5 6 7 8 9
<%
#
# I originally needed to create a sidebar partial that had a div area where I could place custom links into. Finally found it.
# When I was trying to figure this out before and realized I needed to pass the view into :layout, rather than just using render 'layout'. Not sure why the block can't be passed otherwise but nonetheless...
#
# For explanation of options see
# http://guides.rubyonrails.org/layouts_and_rendering.html#options-for-render
#
%>
Something went wrong with that request. Please try again.