This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SalesEngine | |
module Helper | |
def attribute(name) | |
define_method name do | |
instance_variable_get "@#{name}" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "#slice" do | |
context "when given no parameters" do | |
it "returns removes one slice of the apple" do | |
apple = Fruit::Apple.new | |
apple.stub(:remaining_slices).and_return(5) | |
expect(apple.slice).to eq 1 | |
end | |
it "reports the correct number of remaining slices" do | |
apple = Fruit::Apple.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SendConfirmationEmail | |
@queue = :confirmation_email | |
def self.perform(order_user_email, confirmation_code, confirmation_hash) | |
UserMailer.order_confirmation(order_user_email, confirmation_code, confirmation_hash) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.increase_popularity ; end | |
def self.popular ; end | |
end | |
class RedisPopularityCounter | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('fetchCurrentUser', function() { | |
it('creates a parsed user', function(done) { | |
var simulatedAjaxResponse = { | |
firstName: "Tomas", | |
lastName: "Jakobsen" | |
}; | |
$.ajax = function(){ return Q(simulatedAjaxResponse); } | |
var userPromise = fetchCurrentUser(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe("Included matchers:", function() { | |
it("The 'toBe' matcher compares with ===", function() { | |
var a = 12; | |
var b = a; | |
expect(a).toBe(b); | |
expect(a).not.toBe(null); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// structs | |
// first way of creating structs | |
#include <stdio.h> | |
#include <stdlib.h> | |
struct Person { | |
char *name; | |
int age; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
typedef struct person1 { | |
char *name; | |
}Person1; | |
struct Person2 { | |
char *name; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
// miniunit | |
// source: http://www.jera.com/techinfo/jtns/jtn002.html | |
#define mu_assert(message, test) do { if (!(test)) return message; } while (0) | |
#define mu_run_test(test) do { char *message = test(); tests_run++; \ | |
if (message) return message; } while (0) | |
extern int tests_run; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <arpa/inet.h> | |
#include <stdlib.h> | |
#include <netdb.h> | |
#include <string.h> | |
#include <netinet/in.h> | |
int main(int argc, char *argv[]) { |
OlderNewer