Sha256: 6d4fff9aebf93b3d6faac66aebab7886c367df7434545ddd182717becbe3ba3f

Contents?: true

Size: 1.45 KB

Versions: 5

Compression:

Stored size: 1.45 KB

Contents

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

$TESTING_RTC = true

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

class View; end

class TestRailsViewTestCase < Test::Rails::ViewTestCase

  def setup
    # override
    @request = Object.new
    def @request.body; @body; end
    def @request.body=(body); @body = body; end

    @assert_tag = []
  end

  def test_assert_text_area
    @request.body = '
<form action="/post/save">
<textarea id="post_body" name="post[body]">
OMG he like hates me and he\'s like going out with this total skank!~ oh noes!!~
</textarea>
</form>
'

    assert_text_area '/post/save', 'post[body]'

    expected = {
      :tag => 'form', :attributes => { :action => '/post/save' },
        :descendant => {
          :tag => 'textarea', :attributes => { :name => 'post[body]' } } }

    assert_equal expected, @assert_tag.first

    assert_text_area '/post/save', 'post[body]',
                     "OMG he like hates me and he's like going out with this total skank!~ oh noes!!~"

    expected = {
      :tag => 'form', :attributes => { :action => '/post/save' },
        :descendant => {
          :tag => 'textarea', :attributes => { :name => 'post[body]' },
            :content => 
              "OMG he like hates me and he's like going out with this total skank!~ oh noes!!~" } }

    assert_equal expected, @assert_tag.last
  end

  def assert_tag(arg)
    @assert_tag << arg
  end

end if $TESTING_RTC

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ZenTest-3.4.2 test/test_rails_view_test_case.rb
ZenTest-3.4.3 test/test_rails_view_test_case.rb
ZenTest-3.5.1 test/test_rails_view_test_case.rb
ZenTest-3.5.2 test/test_rails_view_test_case.rb
ZenTest-3.6.0 test/test_rails_view_test_case.rb