Skip to content

Instantly share code, notes, and snippets.

@jtrim
Last active November 2, 2015 19:42
Show Gist options
  • Save jtrim/750c081d762856e150e1 to your computer and use it in GitHub Desktop.
Save jtrim/750c081d762856e150e1 to your computer and use it in GitHub Desktop.
require 'yaml'
require 'busted'
require 'ostruct'
obj = Object.new
module Stuff
def bar
end
end
module Fooo
def baar
puts "bar"
end
end
results = [
"Busted.cache? { Class.new }",
"Busted.cache? { Class.new { def foo; end } }",
"Busted.cache? { Klass = Class.new { def foo; end } }",
"Busted.cache? { class Foo; end }",
"Busted.cache? { obj.extend(Stuff) }",
"Busted.cache? { def obj.do_a_thing; end }",
"Busted.cache? { obj.extend(Fooo) }",
"Busted.cache? { OpenStruct.new(foo: 'foo', bar: 'bar') }",
"Busted.cache? { thing = OpenStruct.new(foo: 'foo', bar: 'bar') }"
].map { |c| [c, eval(c, binding)] }
results.each { |(command, result)| puts "- #{command}\n => #{result}" }
@jtrim
Copy link
Author

jtrim commented Nov 2, 2015

- Busted.cache? { Class.new }
  => false
- Busted.cache? { Class.new { def foo; end } }
  => false
- Busted.cache? { Klass = Class.new { def foo; end } }
  => true
- Busted.cache? { class Foo; end }
  => true
- Busted.cache? { obj.extend(Stuff) }
  => false
- Busted.cache? { def obj.do_a_thing; end }
  => false
- Busted.cache? { obj.extend(Fooo) }
  => false
- Busted.cache? { OpenStruct.new(foo: 'foo', bar: 'bar') }
  => false
- Busted.cache? { thing = OpenStruct.new(foo: 'foo', bar: 'bar') }
  => false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment