File: test_response.rb

package info (click to toggle)
ruby-net-sftp 1%3A2.1.2-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 528 kB
  • ctags: 860
  • sloc: ruby: 5,015; makefile: 4
file content (53 lines) | stat: -rw-r--r-- 1,947 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
require 'common'

class ResponseTest < Net::SFTP::TestCase
  def test_code_should_default_to_FX_OK
    response = Net::SFTP::Response.new(mock("response"))
    assert_equal Net::SFTP::Response::FX_OK, response.code
  end

  def test_brackets_should_symbolize_key
    response = Net::SFTP::Response.new(mock("response"), :handle => "foo")
    assert_equal "foo", response['handle']
  end

  def test_to_s_with_nil_message_should_show_default_message
    response = Net::SFTP::Response.new(mock("response"), :code => 14)
    assert_equal "no space on filesystem (14)", response.to_s
  end

  def test_to_s_with_empty_message_should_show_default_message
    response = Net::SFTP::Response.new(mock("response"), :code => 14, :message => "")
    assert_equal "no space on filesystem (14)", response.to_s
  end

  def test_to_s_with_default_message_should_show_default_message
    response = Net::SFTP::Response.new(mock("response"), :code => 14, :message => "no space on filesystem")
    assert_equal "no space on filesystem (14)", response.to_s
  end

  def test_to_s_with_explicit_message_should_show_explicit_message
    response = Net::SFTP::Response.new(mock("response"), :code => 14, :message => "out of space")
    assert_equal "out of space (no space on filesystem, 14)", response.to_s
  end

  def test_ok_should_be_true_when_code_is_FX_OK
    response = Net::SFTP::Response.new(mock("response"))
    assert_equal true, response.ok?
  end

  def test_ok_should_be_false_when_code_is_not_FX_OK
    response = Net::SFTP::Response.new(mock("response"), :code => 14)
    assert_equal false, response.ok?
  end

  def test_eof_should_be_true_when_code_is_FX_EOF
    response = Net::SFTP::Response.new(mock("response"), :code => 1)
    assert_equal true, response.eof?
  end

  def test_eof_should_be_false_when_code_is_not_FX_EOF
    response = Net::SFTP::Response.new(mock("response"), :code => 14)
    assert_equal false, response.eof?
  end
end