Skip to content

Instantly share code, notes, and snippets.

@leikind
Created March 5, 2013 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leikind/5091456 to your computer and use it in GitHub Desktop.
Save leikind/5091456 to your computer and use it in GitHub Desktop.
#Standard library
File.open(path, "w") do |file|
file_data = file.read
end
Benchmark.bm do |x|
x.report { for i in 1..n; a = "1"; end }
x.report { n.times do ; a = "1"; end }
x.report { 1.upto(n) do ; a = "1"; end }
end
# Sinatra
get "/hello" do
Time.now.strftime("Current time: %I:%M%p")
end
#Rails routes:
resources :docs do
resources :version_uploads
resource :property_downgrade, :module => "doc"
collection do
get 'uploaded'
end
end
# testing library
describe 'upgrade_to_document!' do
let!(:document_file){FactoryGirl.create(:image_file)}
it "changes the type from DocumentFile to Document" do
expect {
document_file.upgrade_to_document!
}.to change(document_file, :type).from('DocumentFile').to('Document')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment