Skip to content

Instantly share code, notes, and snippets.

@neerajsingh0101
Created January 28, 2009 21:13
Show Gist options
  • Save neerajsingh0101/54190 to your computer and use it in GitHub Desktop.
Save neerajsingh0101/54190 to your computer and use it in GitHub Desktop.
module Test # :nodoc: all
module Unit
class TestCase
def self.should_assign_to_value(name,value)
should "assign @#{name}" do
assert assigns(name.to_sym), "The action isn't assigning to @#{name}"
if value =~ /#\{/
tmp = '"' + value + '"'
assert_equal assigns(name.to_sym),eval(tmp,binding)
else
assert_equal assigns(name.to_sym),value
end
end
end
def self.should_redirect_to(url)
should "redirect to #{url.inspect}" do
instantiate_variables_from_assigns do
if url =~ /#\{/
tmp = '"' + url + '"'
assert_redirected_to eval(tmp, self.send(:binding), __FILE__, __LINE__)
else
assert_redirected_to eval(url, self.send(:binding), __FILE__, __LINE__)
end
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment