Last active
July 13, 2016 04:50
-
-
Save furugomu/a92b794dcf8cd60c723abecbc8ac4419 to your computer and use it in GitHub Desktop.
context for ActiveSupport::TestCase
This file contains 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 ActiveSupport::TestCase | |
# context 'foo' => class Context_foo < self | |
def self.context(name, &block) | |
class_name = "Context_#{name.gsub(/[[:^word:]]+/, '_')}".to_sym | |
const_set(class_name, Class.new(self, &block)) | |
end | |
end |
This file contains 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 FooTest < ActiveSupport::TestCase | |
context 'bar' do | |
test 'returns foobar' do | |
assert(Foo.bar == 'foobar') | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment