Skip to content

Instantly share code, notes, and snippets.

View antulik's full-sized avatar

Anton Katunin antulik

View GitHub Profile
class Reconciliation::Transaction < Reconciliation::Validator
def initialize transaction
@transaction = transaction
end
def new_error
Reconciliation::GatewayErrors.new @transaction.history, @transaction
end
def verify options = {}
@antulik
antulik / README.md
Created October 12, 2012 06:03
Integration testing of google analytics/kissmetrics script.

To easily explain, imaging you are developing google analytics or kissmetrics and you need to do integration testing of the javascript file. That's the file which people include on their website. Assume client also needs to push some events like signups to the web analytics tool (like kissmetrics) and javascript syntax would be _ga.push(['register', event, extra_data])

The challenge is that in you tests you can't run it from your application as it will share user session and it wouldn't test same origin policy.

Tools stack: Capybara, Webkit, Rspec, Sinatra

So the solution is to have a separate application which will act as a dummy client. I've chose sinatra as it fits perfectly for that role. One of the cool features that rack has is its ability to mount other rack applications inside it. So in run_dummy_client helper we mount sinatra application to /dummy_client path.

But that's not all. In order for this to work we need to run dummy client from different domain. That could be easily done through

@antulik
antulik / pack.js
Created November 17, 2012 06:25
D3 Pack with links
var width = 960,
height = 960,
format = d3.format(",d");
var pack = d3.layout.pack()
.size([width - 4, height - 4])
.padding(10)
.value(function(d) { return d.size; });
var vis = d3.select("#chart").append("svg")
@antulik
antulik / _.md
Created February 2, 2013 05:03
d3.timer
@antulik
antulik / data_conversion.js
Last active December 12, 2015 08:19
Convert csv to json string
var csv_url = "/proj-pop-age-all-series-qld.csv";
d3.csv(csv_url, function(a) {
a.forEach(function(el){
el.year = parseInt(el.year)
el.age = parseInt(el.age)
el.low = parseInt(el.low)
el.medium = parseInt(el.medium)
el.high = parseInt(el.high)
})
@antulik
antulik / _.md
Created February 9, 2013 03:42
martix_heat
@antulik
antulik / _.md
Created February 9, 2013 06:21
mouse_circle
@antulik
antulik / _.md
Created February 9, 2013 06:30
series_lines
@antulik
antulik / _.md
Created February 9, 2013 06:44
force_example
@antulik
antulik / README.md
Last active December 14, 2015 10:09
CampJS D3.JS Links