Skip to content

Instantly share code, notes, and snippets.

View juno's full-sized avatar
💰
writing code (almost) every weekday

Junya Ogura juno

💰
writing code (almost) every weekday
View GitHub Profile
@juno
juno / jasmine-example.js
Created November 30, 2010 10:28
Jasmineによるテストコードのサンプル
describe("Jasmine", function() {
it("makes testing JavaScript awesome!", function() {
expect(yourCode).toBeLotsBetter();
});
});
@juno
juno / jasmine-example2.js
Created December 1, 2010 09:05
Arrayクラスのテスト
describe('Array クラスは', function() {
it('length プロパティで配列長を取得する事ができる', function() {
var arr = [1, 2, 3];
expect(arr.length).toEqual(3);
});
});
@juno
juno / SpecRunner.html
Created December 1, 2010 09:19
Arrayクラスのテストを実行するためのSpecRunner.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Jasmine Test Runner</title>
<link rel="stylesheet" type="text/css" href="lib/jasmine-1.0.1/jasmine.css">
<script type="text/javascript" src="lib/jasmine-1.0.1/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-1.0.1/jasmine-html.js"></script>
<!-- include spec files here... -->
@juno
juno / jasmine.yml
Created December 1, 2010 09:39
jasmine initで生成されるjasmine.yml
# src_files
#
# Return an array of filepaths relative to src_dir to include before jasmine specs.
# Default: []
#
# EXAMPLE:
#
# src_files:
# - lib/source1.js
# - lib/source2.js
@juno
juno / heroku-api-client-example.rb
Created December 2, 2010 06:09
Example implement for heroku info APP_NAME. Requires rest-client and nokogiri.
require 'rest_client'
require 'nokogiri'
resource = RestClient::Resource.new('https://api.heroku.com', 'USERNAME', 'PASSWORD')
args = [:get, nil, {
'X-Heroku-API-Version' => '2',
'User-Agent' => 'my heroku client/1.0',
'X-Ruby-Version' => RUBY_VERSION,
'X-Ruby-Platform' => RUBY_PLATFORM
}].compact
@juno
juno / jasmine-example-3.js
Created December 7, 2010 10:27
beforeEachを使った例。
/**
* Array クラスのテスト
*/
describe('Array クラスは', function() {
var arr = null;
beforeEach(function() {
arr = [1, 2, 3];
});
@juno
juno / jasmine-example-4.js
Created December 7, 2010 10:31
beforeEachを使った例。
/**
* Array クラスのテスト
*/
describe("Array クラスは", function() {
var arr = null;
beforeEach(function() {
arr = [1, 2, 3];
});
@juno
juno / DocumentSpec-01.js
Created December 24, 2010 02:28
Jasmineによるdocument.getElementByIdのテスト
/**
* Document クラスのテスト
*/
describe('Document オブジェクトは', function() {
it('getElementById メソッドで特定の ID を持つ DOM オブジェクトを取得する事ができる', function() {
var elementId = 'test-node';
expect(document.getElementById(elementId)).not.toBeNull();
});
});
@juno
juno / rcov.rake
Created January 7, 2011 06:05 — forked from alexdreher/rcov.rake
Rails coverage rake task for rcov, rspec and steak
# Forked to get it working with Rails 3 and RSpec 2
#
# From http://github.com/jaymcgavren
#
# Save this as rcov.rake in lib/tasks and use rcov:all =>
# to get accurate spec/feature coverage data
#
# Use rcov:rspec or rcov:steak
# to get non-aggregated coverage reports for rspec or steak separately
@juno
juno / localtime.rb
Created January 7, 2011 06:52
convert heroku logs to localtime
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'time'
pattern = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}-\d{2}:\d{2}) (.+)$/
ARGF.each { |line| puts "#{Time.parse($1)} #{$2}" if line =~ pattern }