Sha256: aefd6c5ff2a394c87a230ffe92f7b4649bf3f3b260b3773ee3e054381c52a93e
Contents?: true
Size: 1.17 KB
Versions: 9
Compression:
Stored size: 1.17 KB
Contents
require './test/test_helper' require 'action_controller' require 'action_controller/test_case' require 'yaml' class StrategyControllerTest < ActionController::TestCase tests RendersController setup do @test_cases = YAML.load(File.open(Rails.root.join('fixtures', 'test_cases.yml'))) end test "test yml test cases" do @test_cases.each do |test_case| request = (test_case['request'] || {}) headers = request['headers'] params = request['params'] method = (request['method'] || "get").to_sym response = test_case['response'] @controller.request.stubs(:headers).returns(headers || {}) begin send(method, :index, params || {}) assert_equal(response, @response.body, custom_message(headers, params, method, response)) rescue => e fail(custom_message(headers, params, method, response) + ", but it failed with an exception '#{e.message}'") end end end def custom_message(headers, params, method, response) data = [] data << "headers:#{headers}" if headers data << "params:#{params}" if params "Expected #{data.join(",")} with method #{method} to yield #{response}" end end
Version data entries
9 entries across 9 versions & 2 rubygems