spec/support/fixtures.rb in trackerific-0.3.5 vs spec/support/fixtures.rb in trackerific-0.4.0

- old
+ new

@@ -1,14 +1,20 @@ +# Provides easy access to XML fixtures module Fixtures - + # Gets the path to the fixtures + # @return [String] + # @api private + def fixture_path + File.join(File.dirname(__FILE__), "..", "fixtures") + end + # Loads a fixture + # @param [Symbol] name the fixture to load + # @param [Symbol] ext the exention of the fixture. defaults to :xml + # @example Load ups_success_response.xml + # response = load_fixture :ups_success_response + # @return [String] the contents of the file + # @api private def load_fixture(name, ext = :xml) - - file_name = File.join("spec/fixtures/", "#{name.to_s}.#{ext.to_s}") - f = File.open(file_name, 'r') - data = ""; - f.lines.each { |line| data += line } - f.close - return data - + file_name = File.join(fixture_path, "#{name.to_s}.#{ext.to_s}") + File.read(file_name) end - end