This file contains hidden or 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
| class Object | |
| def self.dirname | |
| eval "File.expand_path(File.dirname(__FILE__))" | |
| end | |
| end | |
| class Bar | |
| end | |
| puts Bar.dirname |
This file contains hidden or 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
| require 'lib/plugin' | |
| class Bar < Plugin | |
| end | |
| puts Bar.dirname | |
| # in lib/plugin | |
| class Plugin | |
| def self.dirname |
This file contains hidden or 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
| class BusinessEvent | |
| def self.inherited(clazz) | |
| subclasses << clazz | |
| end | |
| def self.subclasses | |
| @@subclasses ||= [] | |
| end | |
| end |
This file contains hidden or 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
| class BusinessEvent | |
| def self.subclasses | |
| subclasses = [] | |
| ObjectSpace.each_object(Module) {|m| subclasses << m if m.ancestors.include? self and m != self} | |
| subclasses | |
| end | |
| end | |
| class OrderEvent < BusinessEvent | |
| end |
This file contains hidden or 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 LayoutHelper | |
| def layout(options={}, &block) | |
| options.prepend! 'layout', :class | |
| capture_haml do | |
| haml_tag(:table, options) do | |
| haml_concat capture_haml(&block) | |
| end | |
| end | |
| end | |
This file contains hidden or 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 RSpec | |
| module Core | |
| class ExampleGroup | |
| alias_example_to :observe | |
| end | |
| module ObjectExtensions | |
| alias_method :context, :describe | |
| end | |
| end | |
| end |
This file contains hidden or 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
| $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) | |
| $LOAD_PATH.unshift(File.dirname(__FILE__)) | |
| require 'rspec' | |
| require 'instructions' | |
| # Requires supporting files with custom matchers and macros, etc, | |
| # in ./support/ and its subdirectories. | |
| Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} | |
| RSpec.configure do |config| |
This file contains hidden or 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
| # sample class to mock and test against | |
| class Thing | |
| def foo | |
| bar | |
| end | |
| def bar | |
| end | |
| end |
This file contains hidden or 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
| # see: https://gist.github.com/728575 | |
| describe Thing do | |
| concern { subject.foo } | |
| it { should_have_received(:bar) } | |
| end |
This file contains hidden or 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
| # See the spec report at: http://screencast.com/t/lzXadGVp | |
| # sample class to mock and test against | |
| class Thing | |
| def foo | |
| bar | |
| end | |
| def bar | |
| end |