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 BaseClass | |
def self.find | |
"find" | |
end | |
end | |
# in class definition | |
class ClassA < BaseClass | |
def self.find_with_my_name | |
find_without_my_name + " ClassA" |
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
# | |
# write it in the bottom of spec/spec_helper.rb | |
# | |
def method_missing(name, *args) | |
if matched = name.to_s.match(/mock_(.*)/) | |
klass = matched[1].classify.constantize | |
var_name = "@#{name.to_s}" | |
self.class.send(:define_method, name) do |*stubs| | |
stubs = stubs.try(:first) || {} | |
instance_variable_get(var_name) || |
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
# | |
# extension for rspec | |
# this extension enables to check should_receive in stub_chain | |
# you must require this file in 'spec/spec_helper.rb' | |
# | |
# | |
# Example: | |
# in controller, | |
# | |
# def index |
NewerOlder