Module: DisableTestFixtures::ClassMethods
- Defined in:
- lib/disable_test_fixtures.rb
Instance Method Summary collapse
-
#disable_fixtures(tests = true) ⇒ Object
#deprecated.
-
#disable_fixtures_for(tests = nil, &block) ⇒ Object
Disables fixtures for the particular tests in this test case, accepts :.
- #enable_fixtures ⇒ Object
-
#enable_fixtures_for(tests = nil, &block) ⇒ Object
The opposite of #disable_fixtures_for.
- #fixtures_disabled?(test = nil) ⇒ Boolean
Instance Method Details
#disable_fixtures(tests = true) ⇒ Object
#deprecated
46 47 48 |
# File 'lib/disable_test_fixtures.rb', line 46 def disable_fixtures(tests = true) @fixtures_disabled_tests = tests end |
#disable_fixtures_for(tests = nil, &block) ⇒ Object
Disables fixtures for the particular tests in this test case, accepts :
String/Symbol - test name
Array of strings/symbols - test names
Regexp - matching test names
Proc - will get test name passed
:all symbol
NOTE: fixture disabling is inherited thru the inheritance chain thus if You’ve disabled them in super (e.g. ActiveSupport::TestCase) there’s no need to disable them again.
26 27 28 29 30 31 32 |
# File 'lib/disable_test_fixtures.rb', line 26 def disable_fixtures_for(tests = nil, &block) tests = tests.map { |e| e.to_s } if tests.is_a?(Array) tests = block if tests.nil? && block_given? @fixtures_disabled_tests = tests == :all ? true : tests @fixtures_disabled_tests_negated = false @fixtures_disabled_tests end |
#enable_fixtures ⇒ Object
50 51 52 |
# File 'lib/disable_test_fixtures.rb', line 50 def enable_fixtures @fixtures_disabled_tests = false end |
#enable_fixtures_for(tests = nil, &block) ⇒ Object
The opposite of #disable_fixtures_for.
NOTE: fixture disabling is inherited thru the inheritance chain thus if You’ve disabled them in super (e.g. ActiveSupport::TestCase) there’s no need to disable them again.
39 40 41 42 43 |
# File 'lib/disable_test_fixtures.rb', line 39 def enable_fixtures_for(tests = nil, &block) outcome = disable_fixtures_for(tests, &block) @fixtures_disabled_tests_negated = true outcome end |
#fixtures_disabled?(test = nil) ⇒ Boolean
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/disable_test_fixtures.rb', line 54 def fixtures_disabled?(test = nil) fixtures_disabled_tests = @fixtures_disabled_tests #fixtures_disabled_tests = self.instance_variable_get(:@fixtures_disabled_tests) if fixtures_disabled_tests.nil? superclass.respond_to?(:fixtures_disabled?) ? superclass.fixtures_disabled?(test) : false else outcome = case fixtures_disabled_tests when String then test == fixtures_disabled_tests when Symbol then test == fixtures_disabled_tests.to_s when Regexp then !!(test =~ fixtures_disabled_tests) when Array then fixtures_disabled_tests.include?(test) when Proc then fixtures_disabled_tests.arity == 1 ? fixtures_disabled_tests.call(test) : fixtures_disabled_tests.call else !! fixtures_disabled_tests end @fixtures_disabled_tests_negated ? ! outcome : outcome end end |