Ruby
instance_evalが面白い
こういうのはgithubにいれたらいいのか。。。
expectationsは書きやすい。
require "rubygems" require "expectations" class Project attr_accessor :room_id def initialize(room_id) @room_id = room_id end end Expectations do expect 10 do project = Project.new(10) project.instance_eval("room_id") end end
rubyのクラスメソッドとprivateメソッドの違い
ごちゃごちゃしたのでメモ。当たり前なんだけれども
require "rubygems" require "expectations" class Hoge def self.hello_hello "hello" end private def hello "hello" end end Expectations do expect true do Hoge.private_instance_methods.include?("hello") end expect true do Hoge.public_methods.include?("hello_hello") end end