Skip to content

Instantly share code, notes, and snippets.

View paulspencerwilliams's full-sized avatar

Paul Williams paulspencerwilliams

View GitHub Profile
@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;
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']}"
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|
module Matchers
class BeACreatedFor
def initialize(expected_model)
@expected_model = expected_model
end
def matches?(actual_response)
false
end
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)>'
package uk.me.paulswilliams.auction.fakes;
import org.jivesoftware.smack.*;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.tcp.XMPPTCPConnection;
import java.io.IOException;
import static java.lang.String.format;
ConnectionConfiguration connectionConfig = new ConnectionConfiguration(XMPP_HOSTNAME, 5222);
connectionConfig.setSecurityMode(ConnectionConfiguration.SecurityMode.required);
connectionConfig.setKeystorePath("/Users/will/src/auction_sniper_jruby/cacerts.jks");
connectionConfig.setKeystorePath("/Users/will/src/auction_sniper_jruby/ca-bundle.crt");
this.connection = new XMPPTCPConnection(connectionConfig);
this.connection.connect();
this.connection.login(format(ITEM_ID_AS_LOGIN, itemId), AUCTION_PASSWORD, AUCTION_RESOURCE);
-----BEGIN CERTIFICATE-----
MIIDlDCCAnygAwIBAgIEVGYhRTANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQGEwJV
UzERMA8GA1UECAwIQ29sb3JhZG8xDzANBgNVBAcMBkRlbnZlcjEaMBgGA1UECgwR
VmluZXMgWE1QUCBTZXJ2ZXIxEjAQBgNVBAMMCWxvY2FsaG9zdDAeFw0xNDExMTMx
NTM1MzNaFw0xNTExMTQxNTM1MzNaMGExCzAJBgNVBAYTAlVTMREwDwYDVQQIDAhD
b2xvcmFkbzEPMA0GA1UEBwwGRGVudmVyMRowGAYDVQQKDBFWaW5lcyBYTVBQIFNl
cnZlcjESMBAGA1UEAwwJbG9jYWxob3N0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
MIIBCgKCAQEAwmav/2UJklAhffbtJhAXi3y94y5+CttEBqXbdl/GYqP7xuEaf8e/
FbUqupyyyPqhv2g7fRqmpPA3zMJaVoHXF5Ixm+UdUu/0ADXLs3UMjiCydmVH9thd
2elJZbx2Nl0n5PBBMKVfh3W+i2gKTaLoz3B7YjcShDwlYv3SfHXkaS31Vden/kfy
Traceback (most recent call last):
File "./pin.py", line 3, in <module>
from M2Crypto import X509
ImportError: No module named M2Crypto
/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/bin/java -ea -Didea.launcher.port=7539 "-Didea.launcher.bin.path=/Applications/IntelliJ IDEA 14 CE.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Applications/IntelliJ IDEA 14 CE.app/Contents/lib/idea_rt.jar:/Applications/IntelliJ IDEA 14 CE.app/Contents/plugins/junit/lib/junit-rt.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/lib/javafx-doclet.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/lib/tools.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaV