public
Description: Newzbin Library to search Newzbin
Clone URL: git://github.com/maddox/newzbin.git
Search Repo:
maddox (author)
Fri May 09 09:35:25 -0700 2008
commit  898ff371d4a9385e9bff137555774bab37b5152e
tree    704389bade542af4bcddabd8fd62df8fbbaa40d3
parent  b39ace75e26d9c35e70c0af22c2ffb6692f498c8
newzbin / specs / connection_spec.rb
100644 94 lines (68 sloc) 2.4 kb
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
require 'newzbin'
include Newzbin
 
 
describe Connection, "when first creating without cookies or user/pass" do
  before(:each) do
    @newzbin_conn = Connection.new
  end
 
  it "should have a host" do
    @newzbin_conn.host.should eql('http://v3.newzbin.com')
  end
 
  it "should have a search path" do
    @newzbin_conn.search_path.should eql('/search/')
  end
 
  it "should have a dnzb path path" do
    @newzbin_conn.dnzb_path.should eql('/dnzb')
  end
 
end
 
 
describe Connection, "when first creating with cookies" do
  before(:each) do
    @newzbin_conn = Connection.new(:nzbSmoke => "RKTU0McXx%24Uc4e4KXP1L0sl4O1U9YOchO%2B0DA%3D", :nzbSessionID => "a0fed567eb1a3e6e95c8a3d46fe0c6e7")
  end
 
  it "should have an nzbsmoke" do
    @newzbin_conn.nzbSmoke.should eql('RKTU0McXx%24Uc4e4KXP1L0sl4O1U9YOchO%2B0DA%3D')
  end
 
  it "should have an nzbSessionID" do
    @newzbin_conn.nzbSessionID.should eql('a0fed567eb1a3e6e95c8a3d46fe0c6e7')
  end
 
end
 
 
describe Connection, "when first creating with username and pass" do
  before(:each) do
    @newzbin_conn = Connection.new(:username => "jon", :password => "mypass")
  end
 
  it "should have a username" do
    @newzbin_conn.username.should eql('jon')
  end
 
  it "should have a password" do
    @newzbin_conn.password.should eql('mypass')
  end
 
end
 
describe Connection, "when doing a search without cookies" do
  before(:each) do
    newzbin_conn = Connection.new
    @nzbs = newzbin_conn.search(:q => 'independence day', :ps_rb_video_format => 16, :category => 6)
  end
 
  it "should return an array of items" do
    @nzbs.class.should be(Array)
  end
 
  it "should return items" do
    @nzbs.size.should have_at_least(1).things
  end
 
  it "should get attributes for nzbs" do
    @nzbs.first.attributes.size.should eql(0)
  end
 
end
 
describe Connection, "when doing a search with cookies" do
  before(:each) do
    newzbin_conn = Connection.new(:nzbSmoke => "mZGahEjpg%24OnX89Sy2ExeYzlZciM5YbYWFGH0%3D", :nzbSessionID => "4196bbbb3218497a20f56fece443e7dd")
    @nzbs = newzbin_conn.search(:q => 'independence day', :ps_rb_video_format => 16, :category => 6)
  end
 
  it "should return an array of items" do
    @nzbs.class.should be(Array)
  end
 
  it "should return items" do
    @nzbs.size.should have_at_least(1).things
  end
 
  it "should get attributes for nzbs" do
    @nzbs.first.attributes.should have_at_least(1).things
  end
 
end