Skip to content

Instantly share code, notes, and snippets.

@cupakromer
cupakromer / gist:9980762
Last active August 29, 2015 13:58
RSpec asserting on ActiveSupport deprecations

It seems that assert_deprecated is only part of ActiveSupport. So it is not part of rspec-expectations. It would probably only be added to rspec-rails but a quick google search did not turn up many uses of assert_deprecated.

I saw no past issues logged for RSpec regarding assert_deprecated so you are welcome to log it and argue your case for it. Though I see it being only part of ActiveSupport providing some barriers to adding it into rspec-expectations.

Now it should be fairly easy to roll your own matcher as well. There are two general approaches you could take:

#!/bin/bash
for path in `rbenv root`"/versions/"*; do
if [ -d "$path" ] && [ ! -h "$path" ]; then
export RBENV_VERSION="${path##*/}"
echo "=== Running 'rake spec' for $RBENV_VERSION ==="
rm -f Gemfile.lock
rbenv exec bundle install --local
rbenv exec rake spec
echo && echo
RSpec.configure do |config|
config.around(:each) do |example|
# disabled by design
# example.call
end
end
__END__
if i have the above rspec config in `spec_helper.rb` and i run a test
require 'spec_helper'
describe SimplySettings do
before do
Rails.cache.clear
end
subject(:settings) { SimplySettings }
ruby-2.0.0-p353
@cupakromer
cupakromer / bool_only_predicates.rb
Created May 22, 2014 23:15
Hack to force bool only predicates
# Original: http://media.pragprog.com/titles/ruby4/code/metaprogramming/trace_calls.rb
#
# Modified to enforce opinionated predicate responses.
# Go buy and read the book!
# Note: This is **not** thread safe.
module BoolOnlyPredicates
def self.included(klass)
klass.instance_methods(false).each do |existing_method|
wrap(klass, existing_method)
end
@cupakromer
cupakromer / gist:023278290dddebd785a6
Last active August 29, 2015 14:02
"class" methods in Ruby
class Book
# This is a "class" method
def Book.catch_em_all
"I'm sorry, you can't do that Dave"
end
# This is also a "class" method, since "self" right now is the
# Class object instance for this "class"
def self.bind_it(spell)
"We're still working on binding books with spell."
gem 'jekyll', '~> 2.0.0.alpha'
gem 'nokogiri'
gem 'redcarpet'
gem 'rouge'
@cupakromer
cupakromer / gist:5037f32312e75413e645
Last active August 29, 2015 14:03
Command Line Tricks

Command Line Tricks

  • !! Repeat Previous Command
  • !-1 Repeat Previous Command
  • !-2 Repeat 2nd Previous Command
  • !ps Execute Previous Command STARTING WITH ps
  • !^ First Argument From Previous Command
  • !:2 2nd Argument From Previous Command
  • !$ Last Argument From Previous Command
  • !!:$ Last Argument From Previous Command