Skip to content

Instantly share code, notes, and snippets.

View simcap's full-sized avatar

Simon simcap

View GitHub Profile
@simcap
simcap / SimpleSauceLabTest.java
Created October 19, 2011 19:55
SauceLab simple Selenium test
package fr.xebia.ateliers.cloudbees.saucelab;
import static org.junit.Assert.assertEquals;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.Before;
@simcap
simcap / CustomList.java
Created January 19, 2012 14:39
TDD workshop
public class CustomList {
private boolean readOnly;
private Object[] elements;
private int size;
public CustomList() {
this.elements = new Object[0];
this.size = 0;
this.readOnly = true;
@simcap
simcap / SetCarrierServiceFacade.java
Created September 13, 2012 08:43
Unit tests - Good & bad
public class SetCarrierServiceFacade {
@Autowired
private CarrierService carrierService;
@Autowired
private UserService userService;
@Autowired
private UserContactPointService userContactPointService;
@simcap
simcap / SetCarrierServiceFacadeTest.java
Created September 13, 2012 08:46
Unit tests - Good & bad
public class SetCarrierServiceFacadeTest {
@InjectMocks
private SetCarrierServiceFacade facade;
@Mock
private CarrierService carrierService;
@Mock
private UserContactPointService userContactPointService;
@simcap
simcap / SetCarrierServiceFacade.java
Created September 13, 2012 08:48
Unit tests - Good & bad
public class SetCarrierServiceFacade {
@Autowired
private CarrierService carrierService;
@Autowired
private UserService userService;
@Autowired
private UserContactPointService userContactPointService;
@simcap
simcap / SetCarrierServiceFacadeTest.java
Created September 13, 2012 08:51
Unit tests - Good & bad
public class SetCarrierServiceFacadeTest {
@InjectMocks
private SetCarrierServiceFacade facade;
@Mock
private CarrierService carrierService;
@Mock
private UserContactPointService userContactPointService;
@simcap
simcap / server.ru
Created February 4, 2013 21:25
Using only Ruby core creating a simple server (port 9292) with routes
#!/usr/bin/env ruby
require 'rack'
class MyApplication
def initialize
@routes = [ {:pattern => "poney", :response => lambda do |env, match|
[ 200, {'Content-Type' => 'text/html'}, ['<html><body><h1>Poney Islandais</h1></body></html>'] ]
end
}, {:pattern => "hello", :response => lambda do |env, match|
@simcap
simcap / todo.md
Last active August 29, 2015 14:02
TODO List Markdown example

My feature

  • first item
  • second item done
  • third item
@simcap
simcap / no_struct_for_poro.rb
Last active August 29, 2015 14:05
Why I do not like Struct for PORO (Plain Old Ruby Object) ?
Customer = Struct.new(:name, :address)
c = Customer.new('john') # Do not validate construction
c.name # => 'john'
c.address # => nil
c['name'] # => 'john'
# Extra unneeded API to access your property
c['name'] = 'robert'
@simcap
simcap / salad.rb
Last active August 29, 2015 14:06
A good intermediary for internal only access of instance variables
# A good intermediary for internal-only access of instance variables
# Here the example is with the access on the 'sauce' instance variable
class Salad
def initialize(sauce)
@sauce = sauce
end
attr_reader :sauce