nsisam 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/nsisam/fake_client.rb +0 -7
- data/nsisam.gemspec +1 -1
- data/spec/fake_client_spec.rb +0 -36
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.4
|
data/lib/nsisam/fake_client.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'json'
|
2
2
|
require 'base64'
|
3
3
|
require File.dirname(__FILE__) + '/response'
|
4
|
-
require 'webmock'
|
5
|
-
include WebMock::API
|
6
4
|
|
7
5
|
|
8
6
|
module NSISam
|
@@ -28,16 +26,12 @@ module NSISam
|
|
28
26
|
def store(data)
|
29
27
|
key = Time.now.nsec.to_s
|
30
28
|
@storage[key] = JSON.load(data.to_json) unless @expire
|
31
|
-
if data.kind_of?(Hash) and data.has_key?(:file) and data.has_key?(:filename)
|
32
|
-
stub_request(:get, "http://#{@host}:#{@port}/file/#{key}").to_return(body: Base64.decode64(data[:file]))
|
33
|
-
end
|
34
29
|
Response.new 'key' => key, 'checksum' => 0
|
35
30
|
end
|
36
31
|
|
37
32
|
def store_file(file, filename, type=:file)
|
38
33
|
key = Time.now.to_i.to_s
|
39
34
|
@storage[key] = {type.to_s => Base64.encode64(file), filename: filename}.to_json unless @expire
|
40
|
-
stub_request(:get, "http://#{@host}:#{@port}/file/#{key}").to_return(body: file)
|
41
35
|
Response.new "key" => key, "checksum" => 0
|
42
36
|
end
|
43
37
|
|
@@ -84,7 +78,6 @@ module NSISam
|
|
84
78
|
hash = {file: file, filename: filename}
|
85
79
|
@storage[key] = hash
|
86
80
|
remove_request_stub(:get, "http://#{@host}:#{@port}/file/#{key}")
|
87
|
-
stub_request(:get, "http://#{@host}:#{@port}/file/#{key}").to_return(body: file)
|
88
81
|
Response.new "key" => key, "checksum" => 0
|
89
82
|
end
|
90
83
|
|
data/nsisam.gemspec
CHANGED
data/spec/fake_client_spec.rb
CHANGED
@@ -58,42 +58,6 @@ describe "NSISam::FakeClient" do
|
|
58
58
|
response.checksum.should_not be_nil
|
59
59
|
end
|
60
60
|
|
61
|
-
context "can host files" do
|
62
|
-
it "stored by #store_file" do
|
63
|
-
response = @nsisam.store_file("file not in base64", 'dumb.txt')
|
64
|
-
response.key.should_not be_nil
|
65
|
-
request = Net::HTTP.get_response(URI.parse("http://#{@nsisam.host}:#{@nsisam.port}/file/#{response.key}"))
|
66
|
-
request.body.should == "file not in base64"
|
67
|
-
end
|
68
|
-
|
69
|
-
it "stored by #store in a dict with file and filename" do
|
70
|
-
data = {file: Base64.encode64('a file'), filename: 'dumb.txt'}
|
71
|
-
response = @nsisam.store(data)
|
72
|
-
request = Net::HTTP.get_response(URI.parse(@nsisam.download_link_for_file(response.key)))
|
73
|
-
request.body.should == "a file"
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should update the hosted file when the file is updated through #store" do
|
77
|
-
data = {file: Base64.encode64('a file'), filename: 'dumb.txt'}
|
78
|
-
response = @nsisam.store(data)
|
79
|
-
request = Net::HTTP.get_response(URI.parse(@nsisam.download_link_for_file(response.key)))
|
80
|
-
request.body.should == "a file"
|
81
|
-
|
82
|
-
data = {file: Base64.encode64('another file'), filename: 'dumb.txt'}
|
83
|
-
response = @nsisam.store(data)
|
84
|
-
request = Net::HTTP.get_response(URI.parse(@nsisam.download_link_for_file(response.key)))
|
85
|
-
request.body.should == "another file"
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should update the hosted file when the file is updated through #store_file" do
|
89
|
-
response = @nsisam.store_file('a file', 'dumb.txt')
|
90
|
-
request = Net::HTTP.get_response(URI.parse(@nsisam.download_link_for_file(response.key)))
|
91
|
-
request.body.should == "a file"
|
92
|
-
|
93
|
-
response = @nsisam.update_file(response.key, 'another file', 'dumb.txt')
|
94
|
-
request = Net::HTTP.get_response(URI.parse(@nsisam.download_link_for_file(response.key)))
|
95
|
-
request.body.should == "another file"
|
96
|
-
end
|
97
61
|
end
|
98
62
|
|
99
63
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nsisam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -188,7 +188,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
188
188
|
version: '0'
|
189
189
|
segments:
|
190
190
|
- 0
|
191
|
-
hash: -
|
191
|
+
hash: -3029408733778659421
|
192
192
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
193
193
|
none: false
|
194
194
|
requirements:
|