Last active
November 20, 2015 03:56
-
-
Save YumaInaura/75ff7ee8f932b3941478 to your computer and use it in GitHub Desktop.
Rspec で クラスメソッドのスタブを作る方法 ref: http://qiita.com/Yinaura/items/dfc09fd6d4b953181e2d
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 Example | |
| def self.class_method | |
| 'This is real class method' | |
| 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
| require 'spec_helper' | |
| describe do | |
| before do | |
| allow(Example).to receive(:class_method).and_return('This is stub class method') | |
| end | |
| it do | |
| p Example.class_method | |
| end | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment