Skip to content

Instantly share code, notes, and snippets.

View jimsynz's full-sized avatar
💜

James Harton jimsynz

💜
View GitHub Profile
@jimsynz
jimsynz / gist:7633261
Last active December 29, 2015 06:59
Wouldn't it be super-awesome if you could automatically re-use scenarios as Givens in other scenarios?
Feature: New users can register and confirm accounts
Scenario: A new user registers for our service
Given I am on the home page
When I select "Register" from the nav
And I submit my details
Then I should see the thank you page
And I should receive a confirmation email
Scenario: The new user correctly pastes their confirmation code
isMultipleOf = (n)->
(order)->
order.get('quantity') % n == 0
max = (accumulator, item)->
accumulator = item if item > accumulator
accumulator
isGtZero = (quantity)->
quantity > 0
def send_status_email
# Sometimes a whole bunch of emails will be queued in quick-succession.
# This is to stop them all being sent to the customer. It deletes any
# jobs queued to send this email, and then queues another to happen in
# 1 minute.
applicable_job = proc do |job|
job.klass == 'CartNotifierWorker' && job.args == ['cart_status_changed', self.id]
end
Sidekiq::ScheduledSet.new.select(&applicable_job).map(&:delete)
CartNotifierWorker.perform_in(60.seconds, :cart_status_changed, self.id) if user?
{
"top_image":{},
"bottom_image":{},
"name":"2 Layer",
"state":"APPROVED",
"price":"62.0",
"width_in_mils":0,
"height_in_mils":0,
"pcb_layers":2,
"created_at":"2013-07-30T22:15:21Z",
` ..,,:..,`
,'+++++++'';':::,,:.
`'+######'##+'';;';;;::,:,
1) UserNotificationHelper should eq "foo"
Failure/Error: it { expect(method(:user)).to eq "foo"}
expected: "foo"
got: #<Method: RSpec::Core::ExampleGroup::Nested_1(UserNotificationHelper)#user>
(compared using ==)
Diff:
@@ -1,2 +1,2 @@
@jimsynz
jimsynz / adapter.js.coffee
Created August 19, 2013 05:03
More info re EPF validation issues.
App.Adapter = Ep.RestAdapter.extend
namespaceBinding: 'App.apiNamespace'
init: ->
@_super()
$.ajaxPrefilter (newOpts, oldOpts, xhr)->
xhr.setRequestHeader('Authorization', App.get('sessionToken.token'))
_typeToString: (type)->
if (typeof(type) == 'string')
chunks = type.split('.')
@jimsynz
jimsynz / users_controller.coffee
Created August 19, 2013 03:15
Does anyone have any ideas how to make promises look nicer in CoffeeScript?
registerNewUser: ->
@session.flush().then(((models)=>
newUser = @get('content')
@transitionToRoute('user', newUser)
), ((response)->
console.log response
))
%% name = Rubby::Parser
%% {
def ast
@ast || @result
end
}
%% ast-location = Rubby::Nodes
%% comment = ast Comment(value)
@jimsynz
jimsynz / expects.rb
Created June 26, 2013 22:44
A simple first pass at thinking about modernising RSpec's implicit subject syntax.
module ExpectsMethod
def expects(*what, &block)
its(*what, &block)
end
end
RSpec.configure do |c|
c.extend ExpectsMethod
c.alias_example_to :expected
end