Skip to content

Instantly share code, notes, and snippets.

View jbpros's full-sized avatar
🖐️
yo

Julien Biezemans jbpros

🖐️
yo
View GitHub Profile
@jbpros
jbpros / basic.feature
Created May 30, 2011 14:51
Cucumber implementation-independent feature ideas
Feature: Basic feature execution
In order to do BDD
As a cucumber afficionado
I want to run basic cucumber features
# 1. Not abstract enough: first step is language dependent
Scenario: Simple flat steps
Given the following step definition:
"""
When(/a step passes/, function() {
@jbpros
jbpros / core.feature
Created June 19, 2011 21:07
Remove doc tables from core
Scenario: All steps passing means the scenario passes
Given a scenario "Basic Arithmetic" with:
"""
When I add 4 and 5
Then the result is 9
"""
When Cucumber executes "Basic Arithmetic" with these step mappings:
| I add 4 and 5 | passing |
| the result is 9 | passing |
Then the scenario passes
@jbpros
jbpros / some_spec.js
Created August 9, 2011 21:00
Stub node modules with jasmine
require('./spec_helper.js');
describe("something.act()", function() {
it("calls the 'root' function of my module", function() {
var mod = spyOnModule('my_module');
something.act();
expect(mod).toHaveBeenCalled();
});
});
@jbpros
jbpros / some_view_spec.rb
Created September 8, 2011 10:17
Expect yielding a content_for block in a view spec (rspec)
it "yields the footer" do
footer = "the footer contents"
view.content_for(:footer) { footer }
render
rendered.should have_content footer
end
@jbpros
jbpros / server.js
Created September 15, 2011 20:43
Error: No wrapper for core module crypto
cucumber@0.1.5 /Users/jbpros/Projects/cucumber-js
├─┬ browserify@1.4.6
│ ├── coffee-script@1.1.2
│ ├── commondir@0.0.0
│ ├─┬ detective@0.0.3
│ │ ├─┬ burrito@0.2.9
│ │ │ ├── traverse@0.5.1
│ │ │ └── uglify-js@1.0.7
│ │ └─┬ findit@0.1.0 extraneous
│ │ └── UNMET DEPENDENCY seq >=0.1.7
# activity.rb
def full_duration
return (duration_in_minutes.to_f / 60).round(1)
end
# activity_spec.rb
describe "full_duration()" do
context "when duration_in_minutes is saved in the database" do
@jbpros
jbpros / spec_helper.coffee
Created October 27, 2011 12:36
Create an "uninitialized" object in your jasmine specs
global.newUninitialized = (klass) ->
createInstanceOfKlass = (() ->
F = (args) ->
klass.apply(this, args)
F.prototype = klass.prototype
() ->
new F(arguments);
)()
@jbpros
jbpros / gist:1322767
Created October 28, 2011 17:00 — forked from Slicertje/gist:1322603
Detect if callback is called
function doTest (callback) {
var isCallbackCalled = false;
var successCallback = function () {
isCallbackCalled = true;
};
callback.apply(null, [ successCallback ]);
if (isCallbackCalled) {
@jbpros
jbpros / ace_gherkin_mode.js
Created November 4, 2011 20:17
Paste this into a console when editing a feature on Github and see the light!
//// https://github.com/cucumber/ace/blob/gherkin-mode/lib/ace/mode/gherkin_highlight_rules.js ////
define('ace/mode/gherkin_highlight_rules', function(require, exports, module) {
var oop = require("pilot/oop");
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
var GherkinHighlightRules = function()
{
this.$rules = {
describe Class do
describe "SOME_CONSTANT" do
it "is 12" do
Class::SOME_CONSTANT.should eql 12
end
end
end