I am working on an application called Apphakker. In this application, users are able to complete assignments. When they complete […]
Category: Ruby
RSpec + Carrierwave Controller test example
before do post :create, params: { produto: product.attributes.except(:id).merge( product_image: Rack::Test::UploadedFile.new(Rails.root.join(“spec/fixtures/logo.png”)) ) } end
Speedup rvm ruby on mac
If you are using rvm you may have encountered some performance issue with ruby. For some detailed information of the […]
DRY Conventional API Provider Host Setting by Environment Fallback and Alias Mapping
For my content management system gem http://Home-Page.Software I wanted to support different APIs and use the right host for the […]
Find the cheapest AZ to request your spot instance
Sometimes you need to run an instance on AWS and don’t care about where this one lives. Here is a […]
Clearing RSpec hooks inside a spec
There aren’t a lot of use cases where you want to clear the global RSpec before/after hooks, but I needed […]
From has_scope to virtus form objects
I was usually using has_scope gem for exposing model scopes to application’s controllers. While it’s pretty convenient for building simple […]
Writing HTML easily on decorator / helper
Writing HTML code inside decorator/helper is sucks, right?. For example: class UserDecorator < ApplicationDecorator def foo f = h.content_tag :ul, […]
Conditional method call pattern
In Ruby, and other languages, we often do this def perform perform_action end def perform_action if should_perfom_action? action.perform end end […]
Chef problem with REALLY_GEM_UPDATE_SYSTEM
Today I found following error while bootstrapping a new chef client machine: 72.2.xxx.yyy ERROR: While executing gem … (RuntimeError) 72.2.xxx.yyy […]
Using gs for lean rbenv gemsets
I’ve recently been using https://github.com/soveran/gs as an alternative to rbenv-gemset. It works great to create gem isolation for legacy projects, […]
Enhance your terminal prompt to show current Ruby version
I’ve you’ve ever found yourself at a terminal thinking What version of Ruby is currently active? then perhaps this tip […]
Convert old ruby hash syntax to the new one
find . -type f -iname ‘*.rb’ | xargs ruby -i -pe ‘gsub(/(?<!:):(w+)s*=>s*/, “\1: “)’ Keep in mind it won’t work […]
Stop installing ri and rdoc for every gem you install
I never use ri or rdoc. To prevent ri and rdoc for EVERY gem, just run: touch ~/.gemrc echo “gem: […]
Rendering rails partials as their HTML source
Sometimes we’ll want to do things like display code snippets in our rails views. Traditionally, we’d do this by escaping […]
Monitor directories sizes and take an action if one of them exceeded
this is a simple script for system administrators to monitor directories sizes and report to them if one of them […]
Ruby web server one-liner
It is possible to launch a web server from command line in current directory not only with python one-liner, but […]
Error: No such file found …/hstore.control in postgreSQL
ERROR: could not open extension control file “usr/share/postgreesql/9.2/extension/hstore.control”: No such file or directory There is one file missing in Ubuntu […]
RSpec: compare rendered text like HTML or XML in view specs
I created some helper methods for RSpec which help you compare rendered text without checking each DOM element by xpath […]
Silence VCR Macro Deprecation Warning
Hopefully this one will save someone 10mins of digging around. We use the VCR gem on every project at Hooroo […]