Skip to content

Instantly share code, notes, and snippets.

View justinko's full-sized avatar

Justin Ko justinko

  • Colorado, USA
  • 12:32 (UTC -07:00)
  • LinkedIn in/jko170
View GitHub Profile
diff --git features/command_line/exit_status.feature features/command_line/exit_status.feature
index b0c23f8..070831f 100644
--- features/command_line/exit_status.feature
+++ features/command_line/exit_status.feature
@@ -47,3 +47,13 @@ Feature: exit status
"""
1 example, 1 failure
"""
+
+ Scenario: exit with 0 when no examples are run
# Instead of this:
name = 'Justin'
Person.where('name = ? OR display_name = ? OR cool_name = ? OR alias = ?', name, name, name, name)
# You can do
name = 'Justin'
Person.where('name = ? OR display_name = ? OR cool_name = ? OR alias = ?', *[name]*4)
class Raise
def self.raiser
1.join
end
def self.the_caller
raiser
rescue => exception
raise RuntimeError, "My custom message: #{exception.message}", exception.backtrace
end
- bar
- dog
- foo
- c:
- rat
- cat
- dog
- a
- b
@justinko
justinko / gist:743458
Created December 16, 2010 14:37
Common gem configuration implementations
class MyGem
class << self
attr_accessor :color
end
def self.configure(&block)
instance_eval(&block)
end
end
@justinko
justinko / gist:773325
Created January 10, 2011 19:42
Subclassing a Ruby core class
class Storage
attr_reader :elements
def initialize
@elements = {}.tap do |elements|
elements[:people] = []
elements[:places] = []
end
end
@justinko
justinko / gist:773952
Created January 11, 2011 03:05
Create an HTML table in Ruby
html = "".tap do |str|
str << '<table>'
str << '<tr>'
str << '<td>'
str << 'a'
str << '</td>'
str << '<td>'
str << 'b'
str << '</td>'
str << '</tr>'
RSpec.configure do |config|
config.filter_run_excluding :remote => true
config.before :each, :remote => true do
# Configure code to hit the Braintree service
end
end
# Include your remote specs within your "normal" specs
describe Sweeper do
# Replaces `for_groups_matching`
RSpec.configure do |config|
config.shared :type => :model do
let(:foo) { 'only in models' }
end
end
# I'm actually against being able to call `shared`
# on the configuration instance. It's just not needed.
# You could achieve the same by doing this:
expect(true) == true
expect(true).to be_true
expect { true }.to eq(true)
expect { true }.to be_true