Module: GollyUtils::Testing::DynamicFixtures::ClassMethods
- Included in:
- GollyUtils::Testing::DynamicFixtures
- Defined in:
- lib/golly-utils/testing/dynamic_fixtures.rb
Instance Method Summary collapse
-
#def_fixture(name, options = {}, &block) { ... } ⇒ void
Defines a dynamic fixture.
-
#run_all_in_dynamic_fixture(name, options = {}) { ... } ⇒ void
RSpec helper that directs that all examples be run in the same (initially-clean) copy of a given dynamic fixture.
-
#run_each_in_dynamic_fixture(name, options = {}) ⇒ void
RSpec helper that directs that each example be run in it's own clean copy of a given dynamic fixture.
Instance Method Details
#def_fixture(name, options = {}, &block) { ... } ⇒ void
This method returns an undefined value.
Defines a dynamic fixture.
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/golly-utils/testing/dynamic_fixtures.rb', line 56 def def_fixture(name, ={}, &block) raise "Block not provided." unless block .validate_option_keys :cd_into, :dir_name name= DynamicFixtures.normalise_dynfix_name(name) STDERR.warn "Dyanmic fixture being redefined: #{name}." if $gu_dynamic_fixtures[name] $gu_dynamic_fixtures[name]= .merge(block: block) nil end |
#run_all_in_dynamic_fixture(name, options = {}) { ... } ⇒ void
This method returns an undefined value.
RSpec helper that directs that all examples be run in the same (initially-clean) copy of a given dynamic fixture.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/golly-utils/testing/dynamic_fixtures.rb', line 99 def run_all_in_dynamic_fixture(name, ={}, &block) .validate_option_keys :cd_into, :dir_name require 'golly-utils/testing/rspec/files' name= DynamicFixtures.normalise_dynfix_name(name) # actually just wanted dup run_all_in_empty_dir([:dir_name]) { copy_dynamic_fixture name block.() if block } if cd_into= [:cd_into] class_eval <<-EOB around(:each){|ex| Dir.chdir(#{cd_into.inspect}){ ex.run } } EOB end end |
#run_each_in_dynamic_fixture(name, options = {}) ⇒ void
This method returns an undefined value.
RSpec helper that directs that each example be run in it's own clean copy of a given dynamic fixture.
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/golly-utils/testing/dynamic_fixtures.rb', line 74 def run_each_in_dynamic_fixture(name, ={}) raise "Block not supported." if block_given? .validate_option_keys DynamicFixtures::INSIDE_DYNAMIC_FIXTURE_OPTIONS class_eval <<-EOB around :each do |ex| inside_dynamic_fixture(#{name.inspect}, #{.inspect}){ ex.run } end EOB nil end |