Skip to content

Instantly share code, notes, and snippets.

@iain
iain / spork.rb
Created April 17, 2011 15:27
just a quick hack
#!/usr/bin/env ruby
CUCUMBER_PORT = 8990
RSPEC_PORT = 8989
def running?(port)
`netstat -an` =~ /\b#{port}\b/m
end
START_CUCUMBER = "spork cuc -p #{CUCUMBER_PORT}"
@iain
iain / gist:912682
Created April 10, 2011 20:08
trying to get partial collections with layout working
activesupport (3.0.6) lib/active_support/whiny_nil.rb:48:in `method_missing'
actionpack (3.0.6) lib/action_view/render/rendering.rb:25:in `render'
haml (3.0.25) lib/haml/helpers/action_view_mods.rb:11:in `block in render_with_haml'
haml (3.0.25) lib/haml/helpers.rb:90:in `non_haml'
haml (3.0.25) lib/haml/helpers/action_view_mods.rb:11:in `render_with_haml'
app/views/users/index.html.haml:3:in `_app_views_users_index_html_haml___3430179667211235058_2156490900_627369316816662806'
actionpack (3.0.6) lib/action_view/template.rb:135:in `block in render'
activesupport (3.0.6) lib/active_support/notifications.rb:54:in `instrument'
actionpack (3.0.6) lib/action_view/template.rb:127:in `render'
actionpack (3.0.6) lib/action_view/render/rendering.rb:59:in `block in _render_template'
Feature: Widgets
Scenario: More than one page of widgets
* there are 25 widgets
* go to the widgets page
* only the latest 20 widgets should be visible
* go to the next page
* only the first 5 widgets should be visible
# vs.
@iain
iain / deploy.rb
Created March 10, 2011 22:17
Sunspot helpers
# Tasks for capistrano
def bundler_rake(task_name)
task task_name, :roles => [:app] do
run "cd #{current_path} && bundle exec rake RAILS_ENV=#{rails_env} #{task_name}", :env => {'RAILS_ENV' => rails_env}
end
end
desc "Start Solr"
bundler_rake "solr:start"
God.watch do |w|
DEFAULT.call(w)
w.name = "delayed_job"
w.start = "bundle exec #{RAILS_ROOT}/script/delayed_job -e #{RAILS_ENV} run"
w.pid_file = "#{RAILS_ROOT}/tmp/pids/delayed_job.pid"
end
ruby-1.9.2@fuubar fuubar develop / $ rspec spec
FFFFFFFFFFFFFFFFFFF
Failures:
1) Fuubar start should create a new ProgressBar
Failure/Error: @output = StringIO.new
uninitialized constant RSpec::Core::ExampleGroup::Nested_1::Nested_1::StringIO
# ./spec/fuubar_spec.rb:6:in `block (2 levels) in <top (required)>'
2) Fuubar start should set the title
@iain
iain / validation_matcher.rb
Created October 31, 2010 20:09
Experimenting with a validation matcher for RSpec 2
module ValidationMatcher
class Validate
include RSpec::Matchers::Pretty
attr_accessor :attribute, :values, :target, :results, :value_description
def initialize(attribute)
self.attribute = attribute
end
ActiveRecord::StatementInvalid (Mysql2::Error: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation 'like': SELECT `tags`.* FROM `tags` WHERE (name LIKE '☃')):
module RSpec
module Expectations
# If Test::Unit is loaed, we'll use its error as baseclass, so that Test::Unit
# will report unmet RSpec expectations as failures rather than errors.
superclass = ['Test::Unit::AssertionFailedError', '::StandardError'].map do |c|
eval(c) rescue nil
end.compact.first
class ExpectationNotMetError < superclass
def spec_failure?
Rake.application.instance_variable_get('@tasks')['default'].prerequisites.delete('test')
task :default => :spec
task :stats => "spec:statsetup"
desc "Run all specs in spec directory (excluding plugin specs)"
task :spec => :"spec:load" do
RSpec.run(:all) # or something similar
end