Sha256: 9b4e0f1296442d85b6e08e94107ee8587447fb453d514c27c26ab2067d55229a

Contents?: true

Size: 1.23 KB

Versions: 10

Compression:

Stored size: 1.23 KB

Contents

module Shoulda
  module ActionController
    module Matchers
      class RespondWithMatcher
        def to(where)
           @location = case where
           when Symbol
             where == :back ? where : {:action => where.to_s}
           else
             where
           end
           self
         end
         
         def description
           description = "respond with #{@status}"
           description << " to #{@location.inspect}" unless @location.nil?
           description
         end
         
         def matches?(controller)
           @controller = controller
           (correct_status_code? || correct_status_code_range?) && correct_redirect_location
         end
         
         def expectation
           expectation = "response to be a #{@status},"
           expectation << " redirecting to #{@location.inspect}, " if @location
           expectation << " but was #{response_code}"
           expectation << " redirected to #{@controller.response.redirected_to.inspect}" if @location
           expectation
         end
         private
           def correct_redirect_location
             return true unless @location
             @controller.response.redirected_to == @location
           end
       end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
exposure-0.2.1 spec/custom_matchers.rb
exposure-0.2.0 spec/custom_matchers.rb
exposure-0.1.3 spec/custom_matchers.rb
exposure-0.1.2 spec/custom_matchers.rb
exposure-0.1.1 spec/custom_matchers.rb
exposure-0.1.0 spec/custom_matchers.rb
exposure-0.0.7 spec/custom_matchers.rb
exposure-0.0.6 spec/custom_matchers.rb
exposure-0.0.5 spec/custom_matchers.rb
exposure-0.0.4 spec/custom_matchers.rb