lib/fixtury/test_hooks.rb in fixtury-0.3.0 vs lib/fixtury/test_hooks.rb in fixtury-0.3.1

- old
+ new

@@ -20,21 +20,21 @@ # define fixtures if blocks are given if block_given? raise ArgumentError, "A fixture cannot be defined in an anonymous class" if name.nil? - namespace = name.underscore + namespace = fixtury_namespace ns = ::Fixtury.schema namespace.split("/").each do |ns_name| ns = ns.namespace(ns_name){} end names.each do |fixture_name| ns.fixture(fixture_name, &definition) - self.fixtury_dependencies += ["#{namespace}/#{fixture_name}"] + self.fixtury_dependencies += ["/#{namespace}/#{fixture_name}"] end # otherwise, just record the dependency else self.fixtury_dependencies += names.flatten.compact.map(&:to_s) @@ -62,21 +62,23 @@ EV end end end + def fixtury_namespace + name.underscore + end + end def fixtury(name) return nil unless fixtury_store 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, execution_context: self) - end + local_alias = "/#{self.class.fixtury_namespace}/#{name}" + if self.fixtury_dependencies.include?(local_alias) + return fixtury_store.get(local_alias, execution_context: self) end unless self.fixtury_dependencies.include?(name) raise ArgumentError, "Unrecognized fixtury dependency `#{name}` for #{self.class}" end