Skip to content

Instantly share code, notes, and snippets.

user = User mimic
user should receive(firstName: "Guybrush", authenticate!("Guybrush", "lechucksucks") andReturn(true))
user authenticate!(user name, "lechucksucks") should be true
user stub!(:name) andReturn("Guybrush Threepwood")
user mock!(:occupation) andReturn("Fearsome Pirate") anyNumberOfTimes
JavaGround java:sql:ResultSet do(
mimic!(Mixins Enumerable)
each = dmacro(
[code]
while(self next, code evaluateOn(call ground, Rekoird Row mimic(self)))
self,
[argName, code]
lexical = call LexicalBlock createFrom(call list(argName, code), call ground)
Message from = dmacro(
"returns the message chain for the argument given",
[code]
code deepCopy)
*** - couldn't find cell 'name' on 'Origin_0x295106F' (Condition Error NoSuchCell)
["Guybrush", "Elaine", "LeChuck"].each {|name| puts "Hello #{name}"}
["Guybrush", "Elaine", "LeChuck"] each(name, "Hello #{name}" println)
module BetterToInteger
def self.included(string_class)
string_class.alias_method_chain :to_i, :logging
end
def to_i_with_logging
returning(to_i_without_logging) do |new_value|
logger.log "Converting from #{self} to #{new_value}"
end
end
irb(main):003:0> "".method(:to_widget)
=> #<Method: String#to_widget>
irb(main):003:0> "".method(:to_widget)
=> #<Method: String#to_widget>
irb(main):003:0> "".method(:to_widget)
=> #<Method: String(StringExtensions)#to_widget>
class String
def to_widget
Widget.new self.gsub(/foo/, "bar")
end
end