Skip to content

Instantly share code, notes, and snippets.

View paulspencerwilliams's full-sized avatar

Paul Williams paulspencerwilliams

View GitHub Profile
vagrant@rails-dev-box:~$ vines-services init wat
/usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- i18n/core_ext/string/interpolate (LoadError)
from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /var/lib/gems/2.1.0/gems/activesupport-3.2.20/lib/active_support/core_ext/string/interpolation.rb:2:in `<top (required)>'
from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /var/lib/gems/2.1.0/gems/activesupport-3.2.20/lib/active_support/core_ext/string.rb:9:in `<top (required)>'
from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /var/lib/gems/2.1.0/gems/activesupport-3.2.20/lib/active_support/core_ext.rb:2:in `block in <top (required)>'
module Matchers
class BeACreatedFor
def initialize(expected_model)
@expected_model = expected_model
end
def matches?(actual_response)
false
end
require 'rspec/expectations'
include ActionController::UrlFor
#include ActionController::RackDelegation
RSpec::Matchers.define :be_a_created_for do | expected |
match do | actual |
expect(actual).to have_http_status(:created)
expect(actual.headers["Locaton"]).to eql(url_for(expected))
end
failure_message do |actual|
require 'rspec/expectations'
RSpec::Matchers.define :be_a_created_for do | expected |
match do | actual |
expect(actual).to have_http_status(:created)
expect(actual.headers["Location"]).to eql("http://test.host/websites/2")
end
failure_message do |actual|
"Expected response to be a <created>, but was #{actual.status}
Expected Location to be a <was this?>, but was #{actual.headers['Location']}"
@paulspencerwilliams
paulspencerwilliams / gist:9525937
Created March 13, 2014 10:35
Moq does not take a snapshot of parameters passed into a mocked method, and any mutation after the 'Act' stage of a test will be picked up if the object reference is used in a callback from a later Verify statement. The below test unexpectedly fails.
using Moq;
using NUnit.Framework;
namespace MockTester
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@paulspencerwilliams
paulspencerwilliams / gist:7616944
Created November 23, 2013 16:48
Why do I get a "error: not found: type LineElement" when trying to load this scala file?
abstract class Element {
def contents: Array[String]
def height: Int = contents.length
def width: Int = if (height == 0) 0 else contents(0).length
def beside(that: Element): Element = {
new LineElement("hello")
}
}
class Activity < ActiveRecord::Base
def self.random_undone(amount_to_return)
Activity.where(:done => false).random(amount_to_return)
end
end
@paulspencerwilliams
paulspencerwilliams / gist:6146918
Created August 3, 2013 15:48
How to map user readable uppercase 'Attributes' for models in tabular Given steps with lowercase rails model attributes
Background:
Given the following set of activites exist
| Activity | Weather |
| Got to the Weston Super Mare | Sunny |
| Visit Sea Life Center | Raining |
| Visit West Midlands Safari Park | Sunny |
| Visit Madame Tussauds | Raining |
Scenario: Suggesting a set of sunny activities
When I state that Saturday's weather will be "Sunny"
@paulspencerwilliams
paulspencerwilliams / repo.sh
Created August 1, 2013 14:14
Script to reproduce Error when running with Rails4, Ruby2 - https://github.com/netzpirat/guard-cucumber/issues/42
#/usr/bin/env ruby
rails new BugReproduce -T
cd BugReproduce
echo "group :test do" >> Gemfile
echo " gem 'rspec-rails'" >> Gemfile
echo " gem 'cucumber-rails'" >> Gemfile
echo " gem 'database_cleaner'" >> Gemfile
echo "end" >> Gemfile
echo "group :development do" >> Gemfile
@paulspencerwilliams
paulspencerwilliams / gist:6131005
Created August 1, 2013 12:45
Output of guard running cucumber-rails and cucumber-rspec in newly created rails 4 project without minitest support by using -T on Rails new command.
13:44:23 - INFO - Guard is using Tmux to send notifications.
13:44:23 - INFO - Guard is using TerminalTitle to send notifications.
13:44:23 - INFO - Guard::RSpec is running
13:44:23 - INFO - Running all features
Disabling profiles...
DEPRECATION WARNING: ActionController::Integration is deprecated and will be removed, use ActionDispatch::Integration instead. (called from require at /Users/will/src/whatshallwedo/features/support/env.rb:7)
DEPRECATION WARNING: ActionController::IntegrationTest is deprecated and will be removed, use ActionDispatch::IntegrationTest instead. (called from require at /Users/will/src/whatshallwedo/features/support/env.rb:7)
0 scenarios