Sha256: fa18b8e197e311cc97fbfaf64e0064bdbba8f1244b683d95e1c95e0313d4deaf

Contents?: true

Size: 1.34 KB

Versions: 13

Compression:

Stored size: 1.34 KB

Contents

require 'test_helper'

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 options, only" do
    post :show, :id => 1
    assert_equal "1", 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

13 entries across 13 versions & 2 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/roar-rails-1.2.0/test/test_case_test.rb
roar-rails-1.2.0 test/test_case_test.rb
roar-rails-1.1.0 test/test_case_test.rb
roar-rails-1.0.2 test/test_case_test.rb
roar-rails-1.0.1 test/test_case_test.rb
roar-rails-1.0.0 test/test_case_test.rb
roar-rails-0.1.6 test/test_case_test.rb
roar-rails-0.1.5 test/test_case_test.rb
roar-rails-0.1.4 test/test_case_test.rb
roar-rails-0.1.3 test/test_case_test.rb
roar-rails-0.1.2 test/test_case_test.rb
roar-rails-0.1.1 test/test_case_test.rb
roar-rails-0.1.0 test/test_case_test.rb