0
@@ -211,6 +211,15 @@ module ThoughtBot # :nodoc:
0
@update = ActionOptions.new
0
@destroy = ActionOptions.new
0
@denied = DeniedOptions.new
0
+ @create.flash ||= /created/i
0
+ @update.flash ||= /updated/i
0
+ @destroy.flash ||= /removed/i
0
+ @denied.flash ||= /denied/i
0
@actions = VALID_ACTIONS
0
@formats = VALID_FORMATS
0
@@ -242,14 +251,6 @@ module ThoughtBot # :nodoc:
0
@create.redirect ||= "#{@object}_url(#{singular_args.join(', ')})"
0
@update.redirect ||= "#{@object}_url(#{singular_args.join(', ')})"
0
@denied.redirect ||= "new_session_url"
0
- @create.flash ||= /created/i
0
- @update.flash ||= /updated/i
0
- @destroy.flash ||= /removed/i
0
- @denied.flash ||= /denied/i
0
@@ -306,22 +307,29 @@ module ThoughtBot # :nodoc:
0
# :section: Test macros
0
# Macro that creates a test asserting that the flash contains the given value.
0
- # val can be a String
or a Regex0
+ # val can be a String
, a Regex, or nil (indicating that the flash should not be set)0
+ # should_set_the_flash_to "Thank you for placing this order."
0
# should_set_the_flash_to /created/i
0
+ # should_set_the_flash_to nil
0
def should_set_the_flash_to(val)
0
- should "have #{val.inspect} in the flash" do
0
- assert_contains flash.values, val, ", Flash: #{flash.inspect}"
0
+ should "have #{val.inspect} in the flash" do
0
+ assert_contains flash.values, val, ", Flash: #{flash.inspect}"
0
+ should "not set the flash" do
0
+ assert_equal({}, flash, "Flash was set to:\n#{flash.inspect}")
0
- # Macro that creates a test asserting that the flash is empty
0
+ # Macro that creates a test asserting that the flash is empty. Same as
0
+ # @should_set_the_flash_to nil@
0
def should_not_set_the_flash
0
- should "not set the flash" do
0
- assert_equal({}, flash, "Flash was set to:\n#{flash.inspect}")
0
+ should_set_the_flash_to nil
0
# Macro that creates a test asserting that the controller assigned to @name
0
@@ -367,9 +375,12 @@ module ThoughtBot # :nodoc:
0
# Macro that creates a test asserting that the controller returned a redirect to the given path.
0
+ # The given string is evaled to produce the resulting redirect path. All of the instance variables
0
+ # set by the controller are available to the evaled string.
0
- # should_redirect_to "/"
0
+ # should_redirect_to '"/"'
0
+ # should_redirect_to "users_url(@user)"
0
def should_redirect_to(url)
0
should "redirect to \"#{url}\"" do
0
instantiate_variables_from_assigns do
Comments
No one has commented yet.