logs_tf 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +1 -0
- data/.gitignore +18 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +43 -0
- data/README.md +4 -0
- data/lib/logs_tf/log.rb +20 -0
- data/lib/logs_tf/upload.rb +104 -0
- data/lib/logs_tf/version.rb +3 -0
- data/lib/logs_tf.rb +6 -0
- data/logs_tf.gemspec +24 -0
- data/spec/fixtures/logs/broder_vs_epsilon.log +4539 -0
- data/spec/fixtures/logs/broken_log.log +1 -0
- data/spec/fixtures/vcr/upload.yml +6321 -0
- data/spec/logs_tf/upload_spec.rb +79 -0
- data/spec/spec_helper.rb +11 -0
- metadata +161 -0
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module LogsTF
|
4
|
+
|
5
|
+
describe Upload do
|
6
|
+
|
7
|
+
let(:file) { File.open(File.expand_path('../../fixtures/logs/broder_vs_epsilon.log', __FILE__)) }
|
8
|
+
let(:log) { Log.new(file, "cp_granlands", "qux") }
|
9
|
+
let(:logs_tf_url) { 'http://213.216.248.72:3000' }
|
10
|
+
let(:upload) { Upload.new(log, logs_tf_url ) }
|
11
|
+
|
12
|
+
|
13
|
+
vcr_options = { :cassette_name => "upload", :record => :new_episodes, :match_requests_on => [:method, :uri, :body] }
|
14
|
+
context "uploading logfiles", :vcr => vcr_options do
|
15
|
+
|
16
|
+
describe "#send" do
|
17
|
+
|
18
|
+
it "knows the status of the request" do
|
19
|
+
upload.send
|
20
|
+
upload.should be_request_success
|
21
|
+
end
|
22
|
+
|
23
|
+
it "knows if tf.logs was able to parse the log" do
|
24
|
+
upload.send
|
25
|
+
upload.should be_upload_success
|
26
|
+
end
|
27
|
+
|
28
|
+
it "knows the log's location after sending" do
|
29
|
+
upload.send
|
30
|
+
upload.url.should == "#{logs_tf_url}/91"
|
31
|
+
end
|
32
|
+
|
33
|
+
it "raises the appropriate error when upload was unsuccessful" do
|
34
|
+
upload.stub(:connection => stub(:connection).as_null_object)
|
35
|
+
upload.stub(:request_success? => true)
|
36
|
+
upload.stub(:upload_success? => false)
|
37
|
+
upload.should_receive(:raise_logs_tf_error)
|
38
|
+
upload.send
|
39
|
+
end
|
40
|
+
|
41
|
+
it "raises an error when the response status is not 200" do
|
42
|
+
upload.stub(:connection => stub(:connection).as_null_object)
|
43
|
+
upload.stub(:request_success? => false)
|
44
|
+
expect{upload.send}.to raise_error Upload::RequestError
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#raise_logs_tf_error' do
|
50
|
+
|
51
|
+
before { upload.stub(:response => stub(:body => '{ "error": "foobar" }')) }
|
52
|
+
|
53
|
+
it "raises InvalidLogError" do
|
54
|
+
upload.stub(:error => "Invalid log file")
|
55
|
+
expect{upload.raise_logs_tf_error}.to raise_error Upload::InvalidLogError
|
56
|
+
end
|
57
|
+
|
58
|
+
it "raises MissingLogError" do
|
59
|
+
upload.stub(:error => "No file")
|
60
|
+
expect{upload.raise_logs_tf_error}.to raise_error Upload::MissingLogError
|
61
|
+
end
|
62
|
+
|
63
|
+
it "raises NotAuthenticatedError" do
|
64
|
+
upload.stub(:error => "Not authenticated")
|
65
|
+
expect{upload.raise_logs_tf_error}.to raise_error Upload::NotAuthenticatedError
|
66
|
+
end
|
67
|
+
|
68
|
+
it "raises InvalidAPIKeyError" do
|
69
|
+
upload.stub(:error => "Invalid API key")
|
70
|
+
expect{upload.raise_logs_tf_error}.to raise_error Upload::InvalidAPIKeyError
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logs_tf
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Arie
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: faraday
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.8.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.8.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: multipart-post
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.1.0
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.1.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: vcr
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 2.4.0
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.4.0
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: pry-nav
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.2.3
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.2.3
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rspec
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 2.12.0
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 2.12.0
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: ZenTest
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 4.9.0
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 4.9.0
|
110
|
+
description: A gem to interface with the logs.tf API
|
111
|
+
email: rubygems@ariekanarie.nl
|
112
|
+
executables: []
|
113
|
+
extensions: []
|
114
|
+
extra_rdoc_files: []
|
115
|
+
files:
|
116
|
+
- .autotest
|
117
|
+
- .gitignore
|
118
|
+
- .rspec
|
119
|
+
- Gemfile
|
120
|
+
- Gemfile.lock
|
121
|
+
- README.md
|
122
|
+
- lib/logs_tf.rb
|
123
|
+
- lib/logs_tf/log.rb
|
124
|
+
- lib/logs_tf/upload.rb
|
125
|
+
- lib/logs_tf/version.rb
|
126
|
+
- logs_tf.gemspec
|
127
|
+
- spec/fixtures/logs/broder_vs_epsilon.log
|
128
|
+
- spec/fixtures/logs/broken_log.log
|
129
|
+
- spec/fixtures/vcr/upload.yml
|
130
|
+
- spec/logs_tf/upload_spec.rb
|
131
|
+
- spec/spec_helper.rb
|
132
|
+
homepage: http://github.com/Arie/logs_tf
|
133
|
+
licenses: []
|
134
|
+
post_install_message:
|
135
|
+
rdoc_options: []
|
136
|
+
require_paths:
|
137
|
+
- lib
|
138
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
+
none: false
|
140
|
+
requirements:
|
141
|
+
- - ! '>='
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
requirements: []
|
151
|
+
rubyforge_project:
|
152
|
+
rubygems_version: 1.8.25
|
153
|
+
signing_key:
|
154
|
+
specification_version: 3
|
155
|
+
summary: Logs.tf
|
156
|
+
test_files:
|
157
|
+
- spec/fixtures/logs/broder_vs_epsilon.log
|
158
|
+
- spec/fixtures/logs/broken_log.log
|
159
|
+
- spec/fixtures/vcr/upload.yml
|
160
|
+
- spec/logs_tf/upload_spec.rb
|
161
|
+
- spec/spec_helper.rb
|