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
import junit.framework.TestSuite; | |
import org.junit.runner.Description; | |
import org.junit.runner.JUnitCore; | |
import org.junit.runner.notification.RunListener; | |
public class Main { | |
public static void main(String[] args) { | |
JUnitCore core = new JUnitCore(); | |
core.addListener(new RunListener() { |
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
$:.unshift(File.dirname(__FILE__)) | |
require 'spec_helper' | |
module BowlongGameMacro | |
class BowlongGamePlayer | |
def initialize | |
@game = Game.new | |
end | |
def roll_spare |
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
import org.jmock.cglib.MockObjectTestCase; | |
public class ExampleTest extends MockObjectTestCase { | |
public void testExample() throws Exception { | |
... | |
final Mock mock = new Mock(ClassName.class); | |
mock.expects(once()).method("methodName").will(returnValue("returnValue")); | |
mock.proxy(); | |
... |
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
Timer timer = new Timer(true); | |
... | |
TimerTask task = new TimerTask() { | |
public void run() { | |
// The action to be performed by this timer task. | |
} | |
}; | |
timer.scheduleAtFixedRate(task, 0, watchInterval); |
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
ruby -e 'Dir.glob("*").each { |jar| system("jar tvf #{jar}") }' |
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
image = MiniMagick::Image.open('original.png') | |
image.resize '800x600' | |
image.write('resized.png') |
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
#!/usr/bin/env ruby | |
require 'irb' | |
class Array | |
def sample | |
detect {|elem| elem.to_sym == :muryoimpl } | |
end | |
end | |
IRB.start(__FILE__) |
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
# | |
# RSpec の its('foo.bar.baz') { ... } にインスパイアされたものです。 | |
# | |
# array.map(&:foo).map(&:bar).map(&:baz) を array.map_chain('foo.bar.baz') と | |
# 書けるものを書いてみたけれど、実際のところ AR でもちいると n+1 query が起きるため | |
# Gems にするには今ひとつはばかれるのであった。 | |
# | |
class Array | |
def map_chain(method_names) | |
case method_names |
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
# | |
# artist.rb | |
# | |
class Artist | |
def initialize(name) | |
@name = name | |
end | |
attr_reader :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
module Readline | |
def readline | |
# ... | |
end | |
module_function :readline | |
def self.input=(input) | |
# ... | |
end |
OlderNewer