mock-web-service 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ module MockWebService
2
+ class Async
3
+ include Singleton
4
+
5
+ def initialize
6
+ @queue = Queue.new
7
+ Thread.new { loop { @queue.pop.call } }
8
+ end
9
+
10
+ def run(&blk)
11
+ @queue.push blk
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,27 @@
1
+ require_relative 'async'
2
+
3
+ module MockWebService
4
+
5
+ class Server
6
+ @@requests = []
7
+
8
+ def start
9
+ Async.instance.run { Sinatra::Base.start!({:bind => '0.0.0.0'}) }
10
+ end
11
+
12
+ def add_response(response)
13
+ Sinatra::Base.reset!
14
+ Sinatra::Base.post '*/*' do
15
+ content_type 'text/xml'
16
+ @@requests.push(request.body.read)
17
+ response
18
+ end
19
+ end
20
+
21
+ def get_latest_request
22
+ @@requests.pop
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -0,0 +1,6 @@
1
+ require 'mock-web-service/server'
2
+ require 'sinatra'
3
+
4
+ module MockWebService
5
+
6
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mock-web-service
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Mosaic
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-08-21 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Tool for mocking web requests
15
+ email: mosaic.development@sherwin.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/mock_web_service.rb
21
+ - lib/mock-web-service/server.rb
22
+ - lib/mock-web-service/async.rb
23
+ homepage: ''
24
+ licenses:
25
+ - MIT
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ! '>='
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubyforge_project:
44
+ rubygems_version: 1.8.28
45
+ signing_key:
46
+ specification_version: 3
47
+ summary: Beta
48
+ test_files: []
49
+ has_rdoc: