Sha256: 6470b6b7b6e05d64f8f47f1c9ab54a43f70b774e8b6d71826e67330805d6aab1

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

require 'test_helper'

ENV['RAILS_ENV'] = 'test'
require "dummy/config/environment"
require "rails/test_help" # adds stuff like @routes, etc.
require "roar/rails/test_case"

class TestCaseTest < ActionController::TestCase
  include Roar::Rails::TestCase
  
  class BandController < ActionController::Base
    def show
      render :text => "#{request.body.string}#{params[:id]}"
    end
    
  end
  
  tests BandController
  
  test "allows POST without body" do
    post :show
    assert_equal "", response.body
  end
  
  test "allows POST with document" do
    post :show, "{}"
    assert_equal "{}", response.body
  end
  
  test "allows POST with document and options" do
    post :show, "{}", :id => 1
    assert_equal "{}1", response.body
  end
  
  test "allows GET" do
    get :show, :id => 1
    assert_equal "1", response.body
  end
  
  test "allows PUT" do
    put :show, "{}", :id => 1
    assert_equal "{}1", response.body
  end
  
  test "allows DELETE" do
    delete :show, "{}", :id => 1
    assert_equal "{}1", response.body
  end
  
  test "#assert_body" do
    get :show, :id => 1
    assert_body "1"
    
    # TODO: check message.
    assert_raises MiniTest::Assertion do
      assert_body "3"
    end
  end
  
  test "#assert_body with xml" do
    @controller.instance_eval do
      def show
        render :text => "<order/>"
      end
    end
    
    get :show
    assert_body "<order></order>", :xml => true
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
roar-rails-0.0.1 test/test_case_test.rb