yafs 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 727f42ad904ad4b964734e7b781fadc39d49d6c4
4
- data.tar.gz: 408a260d5fa3faac8a5300d0c5b47d4a71124dc8
3
+ metadata.gz: 5fbac96c9dc78bca768d564def895eff6f31fdf0
4
+ data.tar.gz: a06fce9becf8697cad8d9141e79fdaa077e3c248
5
5
  SHA512:
6
- metadata.gz: 6701a72834539e7f381a5d81fe9ff1ff4c18b3b78a74b55a220a5b73c443f51b7e4e00ff1f628587995029be83b1101a35a49feabd73c32e54ff136a27534313
7
- data.tar.gz: e84cf041c37ea207fe505e0f62c098d82e9dd949c5d94acacf19f6b726f2fc1574cca0ddc638ebed788fe7423d7348a84b1ef4464550792809bcfcbc447d5559
6
+ metadata.gz: cab486448f9f7a603e5f78c562d99cdd94f1d7f6ec1abb9933b43b2f1431afe1d5627d4138eb3ff972d551418cf315ed167405a34f9a71f43125ce0aff2ebf11
7
+ data.tar.gz: 3e71463bb73c5724a54bc9c87c075d80732657521ce19f39298a701395b80e97b689e3f607088284f3754629f3d09038aeae2da6ce6a27080140bcb65f8d3a11
@@ -8,6 +8,10 @@ module Fake
8
8
  def stop
9
9
  @fake_service.stop
10
10
  end
11
+
12
+ def clear
13
+ @fake_service.clear
14
+ end
11
15
  end
12
16
 
13
17
  def self.method_missing(method, *args, &block)
@@ -23,6 +23,10 @@ module Fake
23
23
  def stop
24
24
  @server.stop
25
25
  end
26
+
27
+ def clear
28
+ @app.clear_request_handlers
29
+ end
26
30
  end
27
31
  end
28
32
 
@@ -54,6 +54,10 @@ module Fake
54
54
  @handlers << request_handler
55
55
  end
56
56
 
57
+ def clear_request_handlers
58
+ @handlers = []
59
+ end
60
+
57
61
  def call(env)
58
62
  request = Fake::Request.new(env)
59
63
 
@@ -21,20 +21,28 @@ describe 'Fake Service' do
21
21
  end
22
22
 
23
23
  describe "Simple service without parameters" do
24
- before(:each) { Fake.start(port:4567) }
24
+ before(:each) { Fake.start(port:4568) }
25
25
  after(:each) { Fake.stop }
26
26
 
27
27
  it "can handle get" do
28
28
  Fake.get('/').respond(body:"_response_")
29
- response = HTTParty.get('http://localhost:4567')
29
+ response = HTTParty.get('http://localhost:4568')
30
30
  expect(response.body).to eq "_response_"
31
31
  end
32
32
 
33
33
  it "can handle post" do
34
34
  Fake.post('/').respond(body:"_response_")
35
- response = HTTParty.post('http://localhost:4567')
35
+ response = HTTParty.post('http://localhost:4568')
36
36
  expect(response.body).to eq "_response_"
37
37
  end
38
+ it "is possible to clear request handlers" do
39
+ Fake.get('/').respond(body:"response")
40
+ Fake.clear
41
+ Fake.get('/').respond(body:"other response")
42
+ response = HTTParty.get('http://localhost:4568')
43
+ expect(response.body).to eq "other response"
44
+ end
45
+
38
46
  end
39
47
 
40
48
  describe "Response code" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yafs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mika Lackman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-15 00:00:00.000000000 Z
11
+ date: 2016-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack