Really Cheap Command-Line Option Parsing in Ruby

As the author of Trollop, I cannot BELIEVE the stuff that people think is reasonable in an option parser. Seriously. It boggles the mind. Why should I have to make a module that extends some other module to parse options? Why should I have to subclass anything? Why should I have to subscribe to some … Read more

How do I compare two hashes?

You can compare hashes directly for equality: hash1 = {‘a’ => 1, ‘b’ => 2} hash2 = {‘a’ => 1, ‘b’ => 2} hash3 = {‘a’ => 1, ‘b’ => 2, ‘c’ => 3} hash1 == hash2 # => true hash1 == hash3 # => false hash1.to_a == hash2.to_a # => true hash1.to_a == hash3.to_a … Read more

ERROR: While executing gem … (Errno::EPERM) Operation not permitted [duplicate]

I found the answer on SASS issues: https://github.com/sass/sass/issues/1768 Since OSX el Capitan there is a new security function that prevents you from modifying system files called Rootless. So you have 2 options: If you install gems on /usr/local/bin there will be no problem because rootless doesn’t affect this path. sudo gem install -n /usr/local/bin GEM_NAME_HERE

Ruby : How to write a gem? [closed]

Rubygems.org’s Guides is one of the best resources for writing your own gem. If you’re using Bundler in your app, you might want to look at Ryan Bigg’s guide to Developing a RubyGem using Bundler and the Railscast on creating gems with Bundler. If you’re interested in tools to help you write gems: Jeweler – … Read more

Testing modules in RSpec

The rad way => let(:dummy_class) { Class.new { include ModuleToBeTested } } Alternatively you can extend the test class with your module: let(:dummy_class) { Class.new { extend ModuleToBeTested } } Using ‘let’ is better than using an instance variable to define the dummy class in the before(:each) When to use RSpec let()?