Skip to content

Instantly share code, notes, and snippets.

View dchelimsky's full-sized avatar

David Chelimsky dchelimsky

  • Retired
  • Chicago, IL, USA
View GitHub Profile
/Applications/TextMate.app/Contents/SharedSupport/Support/lib/builder.rb:86:in `blank_slate_method_added': stack level too deep (SystemStackError) from
/Applications/TextMate.app/Contents/SharedSupport/Support/lib/builder.rb:86:in `blank_slate_method_added'
from /Users/david/.rvm/gems/ruby-1.8.7-p302@rspec-all/gems/builder-2.1.2/lib/blankslate.rb:84:in `method_added'
from /Users/david/.rvm/gems/ruby-1.8.7-p302@rspec-all/gems/builder-2.1.2/lib/blankslate.rb:104
from /Users/david/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /Users/david/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /Users/david/.rvm/gems/ruby-1.8.7-p302@rspec-all/gems/activesupport-2.3.10/lib/active_support/basic_object.rb:21
from /Users/david/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /Users/david/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/site_ruby/1.8/ru
@dchelimsky
dchelimsky / gist:642878
Created October 24, 2010 00:18
hash_with_indifferent_access_double_equals.sh
ruby-1.8.7-p302 > initialized_with_symbol_keys = {:a => 1}.with_indifferent_access
=> {"a"=>1}
ruby-1.8.7-p302 > initialized_with_symbol_keys == {"a" => 1}
=> true
ruby-1.8.7-p302 > initialized_with_symbol_keys[:a] == 1
=> true
ruby-1.8.7-p302 > initialized_with_symbol_keys["a"] == 1
=> true
ruby-1.8.7-p302 > {"a" => 1} == initialized_with_symbol_keys
=> true
require 'rspec/core'
RSpec.configure do |c|
c.color_enabled = true
c.filter_run_including :focused => true
c.run_all_when_everything_filtered = true
end
@dchelimsky
dchelimsky / gist:669112
Created November 9, 2010 14:07
swinger_without_rspec_monkey_patch.rb
RSpec.configure do |c|
c.around do |example|
Capybara.using_driver(example.metadata[:driver], &example)
end
end
module Capybara
def self.using_driver(driver)
Capybara.current_driver = driver
yield
#RSpec Mocks...
it "does something with a collaborator" do
#Given
collab = mock(:collab)
it.collaborator = collab
#Then
collab.should_receive(:call).with(3)
#When
#RSpec Mocks...
it "does something with a collaborator" do
#Given
collab = mock(:collab)
it.collaborator = collab
#Then
collab.should_receive(:call).with(3)
#When
@dchelimsky
dchelimsky / convert_shared_groups.rb
Created November 28, 2010 15:54
converting_shared_groups_from_rspec_1_to_rspec_2.rb
# using shared example groups for common setup. This is not really the intent of
# shared groups, but if you used them this way, here's what you need to do when
# upgrading to rspec-2
shared_examples_for "foo" do
before do
# do some setup
end
end
describe Controller do
context "create" do
it "saves the model" do
model = Model.new
Model.stub(:new).and_return(model)
model.should_receive(:save)
post :create
end
end
end
@dchelimsky
dchelimsky / shared_example_group_rspec_2_workaround.rb
Created December 3, 2010 15:46
shared_example_group_rspec_2_workaround
# shared example groups in rspec-1 are evaluated in the example group that
# has it_should_behave_like.
#
# This behavior changed in rspec-2, in which it_should_behave_like generates a
# nested group. This means that a structure like this won't work as you expect
# in rspec-2
#
# shared_examples_for "logged in as admin" do
# before { login_as :admin }
# end
@dchelimsky
dchelimsky / groups.rb
Created December 7, 2010 00:03
groups.rb
describe "outer" do
describe "a" do
it "b" do
end
it "c" do
end
end
describe "d" do