Sha256: 2356241a4878b4a6be68996408e697ec4fcf96a81c1532aa55dd1572da6557ab

Contents?: true

Size: 1.05 KB

Versions: 8

Compression:

Stored size: 1.05 KB

Contents

require 'test/unit'
require 'test/zentest_assertions'

unless defined? $TESTING_RTC then
  $TESTING_RTC = true

  begin
    require 'test/rails'
  rescue LoadError, NameError
    $TESTING_RTC = false
  end
end

class TRController < ApplicationController
end if $TESTING_RTC

class TestRailsControllerTestCase < Test::Rails::ControllerTestCase

  def setup
    @controller_class_name = 'TRController'
    super
  end

  def assigns
    { 'ivar' => 'value' }
  end

  def test_assert_assigned
    assert_assigned :ivar
    assert_assigned :ivar, 'value'

    assert_raise Test::Unit::AssertionFailedError do
      assert_assigned :no_ivar
    end

    e = assert_raise Test::Unit::AssertionFailedError do
      assert_assigned :ivar, 'bad_value'
    end

    expected = <<-EOF.strip
assert_assigned :ivar.
<\"bad_value\"> expected but was
<\"value\">.
    EOF

    assert_equal expected, e.message
  end

  def test_deny_assigned
    deny_assigned :no_ivar

    assert_raise Test::Unit::AssertionFailedError do
      deny_assigned :ivar
    end
  end

end if $TESTING_RTC

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
omghax-test_rails-1.0.0 test/test_rails_controller_test_case.rb
omghax-test_rails-1.1.0 test/test_rails_controller_test_case.rb
ryanbriones-ZenTest-3.11.1 test/test_rails_controller_test_case.rb
ZenTest-3.9.2 test/test_rails_controller_test_case.rb
ZenTest-3.9.3 test/test_rails_controller_test_case.rb
ZenTest-3.10.0 test/test_rails_controller_test_case.rb
ZenTest-3.11.0 test/test_rails_controller_test_case.rb
ZenTest-3.11.1 test/test_rails_controller_test_case.rb