lib/fixtury/test_hooks.rb in fixtury-0.2.1 vs lib/fixtury/test_hooks.rb in fixtury-0.3.0.beta

- old
+ new

@@ -38,18 +38,20 @@ # otherwise, just record the dependency else self.fixtury_dependencies += names.flatten.compact.map(&:to_s) end - if opts[:accessor] + accessor_option = opts.key?(:accessor) ? opts[:accessor] : true - if opts[:accessor] != true && names.length > 1 + if accessor_option + + if accessor_option != true && names.length > 1 raise ArgumentError, "A named :accessor option is only available when providing one fixture" end names.each do |fixture_name| - method_name = opts[:accessor] == true ? fixture_name.split("/").last : opts[:accessor] + method_name = accessor_option == true ? fixture_name.split("/").last : accessor_option ivar = :"@#{method_name}" class_eval <<-EV, __FILE__, __LINE__ + 1 def #{method_name} return #{ivar} if defined?(#{ivar}) @@ -70,18 +72,18 @@ name = name.to_s unless name.include?("/") local_name = "#{self.class.name.underscore}/#{name}" if self.fixtury_dependencies.include?(local_name) - return fixtury_store.get(local_name) + return fixtury_store.get(local_name, execution_context: self) end end unless self.fixtury_dependencies.include?(name) raise ArgumentError, "Unrecognized fixtury dependency `#{name}` for #{self.class}" end - fixtury_store.get(name) + fixtury_store.get(name, execution_context: self) end def fixtury_store ::Fixtury::Store.instance end