http_machinegun 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +19 -19
- data/lib/http_machinegun.rb +2 -2
- data/lib/http_machinegun/version.rb +1 -1
- data/spec/client_spec.rb +8 -0
- metadata +2 -2
data/README.md
CHANGED
@@ -15,34 +15,34 @@ http_machinegun fire -u #{url}
|
|
15
15
|
|
16
16
|
```ruby
|
17
17
|
#simple get request by one times
|
18
|
-
http_machinegun fire -u localhost
|
18
|
+
http_machinegun fire -u http://localhost
|
19
19
|
|
20
20
|
#get request to 3000 port option by one times
|
21
|
-
http_machinegun fire -u localhost -p 3000
|
21
|
+
http_machinegun fire -u http://localhost -p 3000
|
22
22
|
|
23
23
|
#post request with data by one times
|
24
|
-
http_machinegun fire -u localhost -d abc -m post
|
24
|
+
http_machinegun fire -u http://localhost -d abc -m post
|
25
25
|
#or
|
26
|
-
http_machinegun fire -u localhost -d data.txt
|
26
|
+
http_machinegun fire -u http://localhost -d data.txt
|
27
27
|
|
28
28
|
#get request with data by ten times
|
29
|
-
http_machinegun fire -u localhost -t 10
|
29
|
+
http_machinegun fire -u http://localhost -t 10
|
30
30
|
```
|
31
31
|
|
32
32
|
###options
|
33
|
-
* -u, --url
|
34
|
-
target url
|
35
|
-
|
36
|
-
* -p, --port
|
37
|
-
target port
|
38
|
-
|
39
|
-
* -d, --data_or_file
|
40
|
-
string or file path
|
41
|
-
|
42
|
-
* -m, --method
|
43
|
-
http method (get,post,put,delete )
|
44
|
-
|
45
|
-
* -t, --thread_number
|
46
|
-
request number of times you want
|
33
|
+
* -u, --url
|
34
|
+
target url
|
35
|
+
|
36
|
+
* -p, --port
|
37
|
+
target port
|
38
|
+
|
39
|
+
* -d, --data_or_file
|
40
|
+
string or file path
|
41
|
+
|
42
|
+
* -m, --method
|
43
|
+
http method (get,post,put,delete )
|
44
|
+
|
45
|
+
* -t, --thread_number
|
46
|
+
request number of times you want
|
47
47
|
|
48
48
|
|
data/lib/http_machinegun.rb
CHANGED
@@ -29,9 +29,9 @@ module HttpMachinegun
|
|
29
29
|
results = Parallel.each(clients, :in_threads => Parallel.processor_count) {|url|
|
30
30
|
res = client.execute
|
31
31
|
if res.code =~ /^[^2]..$/
|
32
|
-
|
32
|
+
say("http_status_code:" + res.code + "\n", :red)
|
33
33
|
else
|
34
|
-
|
34
|
+
say("http_status_code:" + res.code + "\n", :green)
|
35
35
|
end
|
36
36
|
|
37
37
|
res
|
data/spec/client_spec.rb
CHANGED
@@ -4,6 +4,7 @@ require 'spec_helper'
|
|
4
4
|
describe HttpMachinegun::Client do
|
5
5
|
let(:url) { "http://example.com" }
|
6
6
|
let(:url_fully) { "http://example.com:8080/" }
|
7
|
+
let(:sub_url) { "http://example.com:8080/sub.html" }
|
7
8
|
let(:port) { 8080 }
|
8
9
|
let(:send_data) { "abcdefg" }
|
9
10
|
before do
|
@@ -12,6 +13,7 @@ describe HttpMachinegun::Client do
|
|
12
13
|
stub_request(:post , url_fully).to_return{|req| { :body => "succeed post request and request body #{send_data}" } }
|
13
14
|
stub_request(:put , url_fully).to_return{|req| { :body => "succeed put request and request body #{send_data}" } }
|
14
15
|
stub_request(:delete , url_fully).to_return(:body => 'succeed delete request')
|
16
|
+
stub_request(:get , sub_url).to_return(:body => "succeed get request to #{sub_url}")
|
15
17
|
end
|
16
18
|
|
17
19
|
context "base header" do
|
@@ -84,4 +86,10 @@ describe HttpMachinegun::Client do
|
|
84
86
|
it { subject.body.should eql "succeed delete request" }
|
85
87
|
end
|
86
88
|
end
|
89
|
+
|
90
|
+
context "access below root path" do
|
91
|
+
subject { HttpMachinegun::Client.new(sub_url, port, send_data).http_method(:get).set_body.execute }
|
92
|
+
it { subject.code.should eql "200" }
|
93
|
+
it { subject.body.should eql "succeed get request to #{sub_url}" }
|
94
|
+
end
|
87
95
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http_machinegun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|