Class: ODDB::State::Drugs::TestIncompleteRegs

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
test/test_state/drugs/incompleteregistrations.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



71
72
73
74
# File 'test/test_state/drugs/incompleteregistrations.rb', line 71

def setup
  @session = State::Drugs::StubIncompleteRegsSession.new
  @state = State::Drugs::IncompleteRegs.new(@session, nil)
end

- (Object) test_update_bsv



75
76
77
78
79
# File 'test/test_state/drugs/incompleteregistrations.rb', line 75

def test_update_bsv
  file = @session.user_input = { :bsv_url => 'http://www.oddb.org/file.xls' }
  @state.update_bsv
  assert_equal([:i_bsv_in_progress], @state.infos)
end

- (Object) test_update_bsv2



80
81
82
83
84
85
# File 'test/test_state/drugs/incompleteregistrations.rb', line 80

def test_update_bsv2
  file = @session.user_input = { :bsv_url => 'http://www.oddb.org/nofilethere.xls' }
  @state.update_bsv
  result = @state.errors[:bsv_url].message
  assert_equal('e_file_not_found', result)
end

- (Object) test_update_bsv3



86
87
88
89
90
91
# File 'test/test_state/drugs/incompleteregistrations.rb', line 86

def test_update_bsv3
  file = @session.user_input = { :bsv_url => 'http://www.oddb.org/nofilethere.doc' }
  @state.update_bsv
  result = @state.errors[:bsv_url].message
  assert_equal('e_invalid_url', result)
end

- (Object) test_url_parts



92
93
94
95
96
97
98
99
100
# File 'test/test_state/drugs/incompleteregistrations.rb', line 92

def test_url_parts
  assert_nil(@state.url_parts('fdesafdas'))
  expected = [
    'www.foo.bar',
    '/files/baz.xls',
    'baz.xls',
  ]
  assert_equal(expected, @state.url_parts('http://www.foo.bar/files/baz.xls'))
end