From f00bddd0013ba1be4b06124030ce61a600ef6add Mon Sep 17 00:00:00 2001 From: tsaleh Date: Tue, 24 Jul 2007 16:53:54 +0000 Subject: [PATCH] Fixed private helper git-svn-id: https://svn.thoughtbot.com/plugins/shoulda/trunk@145 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa --- lib/shoulda.rb | 7 ++--- .../controller_tests/controller_tests.rb | 30 +++++++++++++++++-- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/lib/shoulda.rb b/lib/shoulda.rb index 9a37420d..b72c27d7 100644 --- a/lib/shoulda.rb +++ b/lib/shoulda.rb @@ -1,10 +1,9 @@ -# $LOAD_PATH << File.join(File.dirname(__FILE__), 'controller_tests') +require 'yaml' require 'shoulda/private_helpers' +require 'shoulda/general' +require 'shoulda/context' require 'shoulda/active_record_helpers' require 'shoulda/controller_tests/controller_tests.rb' -require 'shoulda/context' -require 'shoulda/general' -require 'yaml' shoulda_options = {} diff --git a/lib/shoulda/controller_tests/controller_tests.rb b/lib/shoulda/controller_tests/controller_tests.rb index 47514137..c9085df6 100644 --- a/lib/shoulda/controller_tests/controller_tests.rb +++ b/lib/shoulda/controller_tests/controller_tests.rb @@ -1,7 +1,6 @@ module ThoughtBot # :nodoc: module Shoulda # :nodoc: # = Macro test helpers for your controllers - # module Controller def self.included(other) # :nodoc: other.class_eval do @@ -201,9 +200,36 @@ module ThoughtBot # :nodoc: private + SPECIAL_INSTANCE_VARIABLES = %w{ + _cookies + _flash + _headers + _params + _request + _response + _session + action_name + before_filter_chain_aborted + cookies + flash + headers + ignore_missing_templates + logger + params + request + request_origin + response + session + template + template_class + template_root + url + variables_added + }.map(&:to_s) + def instantiate_variables_from_assigns(*names, &blk) old = {} - names = @response.template.assigns.keys if names.empty? + names = (@response.template.assigns.keys - SPECIAL_INSTANCE_VARIABLES) if names.empty? names.each do |name| old[name] = instance_variable_get("@#{name}") instance_variable_set("@#{name}", assigns(name.to_sym))