Created
July 22, 2013 11:29
-
-
Save delba/6053176 to your computer and use it in GitHub Desktop.
get tested_class in rails test
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 'test_helper' | |
class ArticleTest < ActiveSupport::TestCase | |
test 'tested_class is Article' do | |
assert_same Article, tested_class | |
end | |
private | |
def tested_class | |
@tested_class ||= begin | |
/(?<klass>.+)Test/ =~ self.class.name | |
klass.constantize | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment