test/test_helper.rb in smurf-1.0.4 vs test/test_helper.rb in smurf-1.0.5

- old
+ new

@@ -1,19 +1,22 @@ ENV["RAILS_ENV"] = "test" -ENV["RAILS_ROOT"] = File.expand_path(File.join(File.dirname(__FILE__), 'rails')) -require File.expand_path(File.join(ENV["RAILS_ROOT"], 'config', 'environment')) -require File.expand_path(File.join(File.dirname(__FILE__), '..', 'init')) +require ::File.expand_path('../rails/config/environment', __FILE__) +# Rails.public_path = Rails.root + "test" + "rails" + "public" require 'riot' +require 'ostruct' +# require 'smurf' +require ::File.expand_path('../../lib/smurf', __FILE__) + class AssetFile def self.base_path - @path ||= File.join(File.join(ENV["RAILS_ROOT"], 'public')) + @path ||= Rails.public_path end def self.read(relative_path) - File.read(File.join(base_path, relative_path)) + File.read(base_path + relative_path) end end class Riot::Context def should_have_same_contents(expected_path, actual_path) @@ -21,14 +24,25 @@ AssetFile.read(actual_path) end.equals(AssetFile.read(expected_path)) end end -Riot::Situation.instance_eval do +class Riot::Situation include ActionView::Helpers::TagHelper include ActionView::Helpers::AssetTagHelper + + def controller; nil; end + + def config + OpenStruct.new({ + :assets_dir => Rails.public_path, + :javascripts_dir => Rails.public_path + "/javascripts", + :stylesheets_dir => Rails.public_path + "/stylesheets", + :perform_caching => true + }) + end end at_exit do - artifacts = Dir.glob(File.join(AssetFile.base_path, '**', 'cache', 'actual.*')) + artifacts = Dir.glob(File.join(AssetFile.base_path, '**', 'cache', 'actual*.*')) FileUtils.rm(artifacts) end