class TestCommon

Public Instance Methods

nu_test_rewrite_plugin() click to toggle source
# File vendor/qwik/lib/qwik/common-basic.rb, line 107
def nu_test_rewrite_plugin
  # This is tested in act-table.rb
end
test_download() click to toggle source
# File vendor/qwik/lib/qwik/common-send.rb, line 152
def test_download
  t_add_user

  page = @site.create_new
  page.store('t')

  # At the first, attach a test file.
  res = session('POST /test/1.files') {|req|
    req.query.update('content'=>t_make_content('t.txt', 't'))
  }
  ok_title('File attachment completed')

  # Get the content by download.
  res = session('/test/1.download/t.txt')
  ok_eq('text/plain', res['Content-Type'])
  ok_eq("attachment; filename=\"t.txt\"", res['Content-Disposition'])
  ok_eq('t', res.body)
end
test_generate_js() click to toggle source
# File vendor/qwik/lib/qwik/common-javascript.rb, line 33
    def test_generate_js
      c = Qwik::Action
      eq [:script, {:src=>'.theme/t.js', :type=>'text/javascript'}, ''],
         c.generate_script('t')
#      eq [[:script, {:src=>'.theme/js/base.js', :type=>'text/javascript'}, ''],
#          [:script, {:src=>'.theme/js/niftypp.js', :type=>'text/javascript'},
#            ''],
#          [:script, {:src=>'.theme/js/debugwindow.js',
#              :type=>'text/javascript'}, '']],
#        c.generate_js
    end
test_response() click to toggle source
# File vendor/qwik/lib/qwik/common-basic.rb, line 86
def test_response
  res = session

  # test_c_set_status
  @action.c_set_status(7743)
  ok_eq(7743, res.status)

  # test_c_set_contenttype
  @action.c_set_contenttype
  ok_eq("text/html; charset=Shift_JIS", res['Content-Type'])

  # test_c_set_no_cache
  @action.c_set_no_cache
  ok_eq('no-cache', res['Pragma'])
  ok_eq('no-cache', res['Cache-Control'])

  # test_c_set_body
  @action.c_set_body('body')
  ok_eq('body', res.body)
end
test_simple_send() click to toggle source
# File vendor/qwik/lib/qwik/common-send.rb, line 125
def test_simple_send
  t_add_user

  page = @site.create_new
  page.store('t')

  # At the first, attach a text file for test.
  res = session('POST /test/1.files') {|req|
    req.query.update('content'=>t_make_content('t.txt', 't'))
  }
  ok_title('File attachment completed')

  # Get the content using simple send.
  res = session('/test/1.files/t.txt')
  ok_eq('text/plain', res['Content-Type'])
  ok_eq('t', res.body)

  t_without_testmode {
    res = session('/test/1.files/t.txt')
    ok_eq('text/plain', res['Content-Type'])
    assert_instance_of(File, res.body)
    str = res.body.read
    res.body.close         # important
    ok_eq('t', str)
  }
end