As others have pointed out, it's not intuitive what
the order of arguments is for assert_equal(foo, bar)
. Which is
expected? Which is actual? I had to look it up.
Compare that to expect(bar).to eq(foo)
-- which is expected
and which is actual is immediately obvious. assert_equal
is one of the simplest assertions. It gets worse when you start
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source_files = Rake::FileList.new("**/*.md", "**/*.markdown") do |fl| | |
fl.exclude("~*") | |
fl.exclude(/^scratch\//) | |
fl.exclude do |f| | |
`git ls-files #{f}`.empty? | |
end | |
end | |
task :default => :html | |
task :html => source_files.ext(".html") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'librato/metrics' | |
require 'vcr' | |
VCR.configure do |vcr| | |
vcr.hook_into :faraday | |
vcr.cassette_library_dir = Dir.pwd | |
end | |
puts "Running on ruby version: #{RUBY_DESCRIPTION}" | |
puts "Using librato-metrics version: #{Librato::Metrics::VERSION}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
def long_string | |
"a" * 170 | |
end | |
def long_string_with_space | |
long_string = long_string + " " | |
long_string | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is totally untested, but something like this should work... | |
module MultipleMockFrameworksAdapters | |
extend Forwardable | |
def_delegators :mock_framework_for_current_example, | |
# these are the 3 methods your adapter needs | |
:setup_mocks_for_rspec, | |
:verify_mocks_for_rspec, | |
:teardown_mocks_for_rspec | |
def mock_framework_for_current_example |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
➜ irb | |
1.9.3p327 :001 > Object.define_method | |
NoMethodError: private method `define_method' called for Object:Class | |
from (irb):1 | |
from /Users/myron/.rvm/rubies/ruby-1.9.3-p327/bin/irb:16:in `<main>' | |
1.9.3p327 :002 > m = Module.new do | |
1.9.3p327 :003 > public_class_method :define_method | |
1.9.3p327 :004?> end | |
=> #<Module:0x007fd4c493d8e8> | |
1.9.3p327 :005 > Object.define_method |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
max_stack_frames = 500 | |
TooManyStackFrames = Class.new(StandardError) | |
set_trace_func proc { |event, file, line, id, binding, classname| | |
if event == "call" && caller.size >= max_stack_frames | |
raise TooManyStackFrames, "Stack has exceeded #{max_stack_frames} frames" | |
end | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe MyClass do | |
it 'does something', :wip do | |
end | |
it 'does something else' do | |
end | |
end |
I've discovered a crazy bug that's really confusing me. I'm curious to hear if anyone can explain it.
Here's some code in foo.rb
:
class Superclass
unless ENV['NORMAL_METHOD_DEF']
define_method :regex do
/^(\d)$/
end