test/helper.rb in paperclip-2.4.5 vs test/helper.rb in paperclip-2.5.0

- old
+ new

@@ -8,13 +8,14 @@ require 'active_record' require 'active_record/version' require 'active_support' require 'mime/types' -require 'pry' require 'pathname' +require 'pathname' + puts "Testing against version #{ActiveRecord::VERSION::STRING}" `ruby -e 'exit 0'` # Prime $? with a value. begin @@ -51,10 +52,14 @@ config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml')) ActiveRecord::Base.logger = ActiveSupport::BufferedLogger.new(File.dirname(__FILE__) + "/debug.log") ActiveRecord::Base.establish_connection(config['test']) Paperclip.options[:logger] = ActiveRecord::Base.logger +Dir[File.join(File.dirname(__FILE__), 'support','*')].each do |f| + require f +end + def reset_class class_name ActiveRecord::Base.send(:include, Paperclip::Glue) Object.send(:remove_const, class_name) rescue nil klass = Object.const_set(class_name, Class.new(ActiveRecord::Base)) klass.class_eval{ include Paperclip::Glue } @@ -148,7 +153,25 @@ begin `ruby -e 'exit #{code.to_i}'` yield ensure `ruby -e 'exit #{saved_exitstatus.to_i}'` + end +end + +def fixture_file(filename) + File.join(File.dirname(__FILE__), 'fixtures', filename) +end + +def assert_success_response(url) + Net::HTTP.get_response(URI.parse(url)) do |response| + assert_equal "200", response.code, + "Expected HTTP response code 200, got #{response.code}" + end +end + +def assert_not_found_response(url) + Net::HTTP.get_response(URI.parse(url)) do |response| + assert_equal "404", response.code, + "Expected HTTP response code 404, got #{response.code}" end end