the_pirate_bay 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "the_pirate_bay"
2
+ require "webmock/rspec"
2
3
 
3
4
  # This file was generated by the `rspec --init` command. Conventionally, all
4
5
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
@@ -17,3 +18,15 @@ RSpec.configure do |config|
17
18
  # --seed 1234
18
19
  config.order = 'random'
19
20
  end
21
+
22
+ def fixture_path
23
+ File.expand_path("../fixtures", __FILE__)
24
+ end
25
+
26
+ def fixture(file)
27
+ File.read(File.join(fixture_path, '/', file))
28
+ end
29
+
30
+ def stub_get(path, endpoint = ThePirateBay::ENDPOINT.to_s)
31
+ stub_request(:get, [endpoint, path].join('/'))
32
+ end
@@ -3,25 +3,32 @@ require "spec_helper"
3
3
  describe ThePirateBay::Torrent do
4
4
  let(:api) { ThePirateBay.new }
5
5
 
6
- context ".search", focus: true do
7
- let(:torrents) { api.torrents.search("Fringe") }
6
+ context ".search" do
7
+ before :all do
8
+ stub_get("search/Fringe/0/99/0").
9
+ to_return(:status => 200, :body => fixture("torrent/search.html"))
10
+ @torrents = api.torrents.search("Fringe")
11
+ end
8
12
 
9
13
  it "returns torrents results" do
10
- torrents.class.should == Array
14
+ @torrents.class.should == Array
11
15
  end
12
16
 
13
17
  it "instantiates torrents collection objects" do
14
- torrents.first.class.should == ThePirateBay::Torrent::Collection
18
+ @torrents.first.class.should == ThePirateBay::Torrent::Collection
15
19
  end
16
20
 
17
21
  it "assigns torrents attributes" do
18
- torrents.first.id.should == "7811310"
22
+ @torrents.first.id.should == "7810640"
19
23
  end
20
24
  end
21
25
 
22
26
  context ".find" do
23
27
  it "returns a particular torrent" do
24
- api.torrents.find("7723168").should include("Fringe S05E03 HDTV")
28
+ stub_get("torrent/7723168").
29
+ to_return(:status => 200, :body => fixture("torrent/find.html"))
30
+ torrent = api.torrents.find("7723168")
31
+ torrent.name.should == "Fringe S05E03 HDTV x264-LOL [eztv]"
25
32
  end
26
33
  end
27
34
  end
@@ -20,5 +20,6 @@ Gem::Specification.new do |gem|
20
20
  gem.add_dependency "faraday", "~> 0.8.4"
21
21
  gem.add_dependency "nokogiri", "~> 1.5.5"
22
22
 
23
- gem.add_development_dependency "rspec", "~> 2.11.0"
23
+ gem.add_development_dependency "rspec", "~> 2.12.0"
24
+ gem.add_development_dependency "webmock", "~> 1.9.0"
24
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: the_pirate_bay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-10 00:00:00.000000000 Z
12
+ date: 2012-11-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
16
- requirement: &70181583441780 !ruby/object:Gem::Requirement
16
+ requirement: &70305416074080 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.8.4
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70181583441780
24
+ version_requirements: *70305416074080
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: nokogiri
27
- requirement: &70181583469940 !ruby/object:Gem::Requirement
27
+ requirement: &70305416073580 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,18 +32,29 @@ dependencies:
32
32
  version: 1.5.5
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70181583469940
35
+ version_requirements: *70305416073580
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70181583469480 !ruby/object:Gem::Requirement
38
+ requirement: &70305416073120 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
42
42
  - !ruby/object:Gem::Version
43
- version: 2.11.0
43
+ version: 2.12.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70181583469480
46
+ version_requirements: *70305416073120
47
+ - !ruby/object:Gem::Dependency
48
+ name: webmock
49
+ requirement: &70305416072660 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.9.0
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70305416072660
47
58
  description: Ruby Client for ThePirateBay.se
48
59
  email:
49
60
  - javier@tractical.com
@@ -62,6 +73,7 @@ files:
62
73
  - lib/the_pirate_bay/api.rb
63
74
  - lib/the_pirate_bay/client.rb
64
75
  - lib/the_pirate_bay/connection.rb
76
+ - lib/the_pirate_bay/core_ext/string.rb
65
77
  - lib/the_pirate_bay/errors.rb
66
78
  - lib/the_pirate_bay/model.rb
67
79
  - lib/the_pirate_bay/response.rb
@@ -69,6 +81,8 @@ files:
69
81
  - lib/the_pirate_bay/torrent.rb
70
82
  - lib/the_pirate_bay/torrent/collection.rb
71
83
  - lib/the_pirate_bay/version.rb
84
+ - spec/fixtures/torrent/find.html
85
+ - spec/fixtures/torrent/search.html
72
86
  - spec/spec_helper.rb
73
87
  - spec/the_pirate_bay/torrent_spec.rb
74
88
  - spec/the_pirate_bay_spec.rb
@@ -98,6 +112,8 @@ signing_key:
98
112
  specification_version: 3
99
113
  summary: ThePirateBay.se Client
100
114
  test_files:
115
+ - spec/fixtures/torrent/find.html
116
+ - spec/fixtures/torrent/search.html
101
117
  - spec/spec_helper.rb
102
118
  - spec/the_pirate_bay/torrent_spec.rb
103
119
  - spec/the_pirate_bay_spec.rb