sinatra_fake_webservice 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,7 +9,7 @@ FakeWeb is awesome, but it allows you only to register *one* response per url, a
9
9
  == Installation
10
10
 
11
11
  Command line:
12
- sudo gem install sinatra_fake_webservice+
12
+ sudo gem install sinatra_fake_webservice
13
13
 
14
14
  Or in bundler (0.9.x) add this line to your .gemfile:
15
15
 
@@ -26,17 +26,33 @@ and then simply use the familiar sinatra DSL to create methods and responses.
26
26
 
27
27
  @fakews.get '/awesome' do
28
28
  "YAY!!"
29
- end+
29
+ end
30
+
31
+ @fakews.post '/omglol' do
32
+ "YAY!! i posted #{params[:awesome]}"
33
+ end
30
34
 
35
+ @fakews.delete '/awesome' do
36
+ "there, i kiiled #{params[:id]}"
37
+ end
38
+
39
+ @fakews.put '/awesome' do
40
+ "yay, i saved the worlds"
41
+ end
42
+
31
43
  tada!
32
44
 
33
- i simply used Net::HTTP to access the sinatra app, but i bet there are more ways to do it:
45
+ == Tests
34
46
 
35
- res = Net::HTTP.start(@fakews.host, @fakews.port) do |http|
36
- http.get('/awesome')
37
- end
47
+ I added a few methods to wrap HTTP requests:
48
+
49
+ * get_response(path)
50
+ * post_response(path, data, headers, dest)
51
+ * put_response(path, data, headers, dest)
52
+ * delete_response(path, data, headers, dest)
53
+
54
+ The most important thing to remember, is that you'll have to point your webservice api wrapper (twitter_auth or whatever) to use "localhost" and the fake sinatra app's port, available via a simple getter (#port).
38
55
 
39
- assert_equal "YAY!!", res.body
40
56
 
41
57
  == Note on Patches/Pull Requests
42
58
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.0
1
+ 0.9.1
@@ -30,7 +30,7 @@ class SinatraWebService
30
30
  end
31
31
 
32
32
  def run!
33
- if Thread.list.size > 1
33
+ if Thread.list.size > 2
34
34
  Thread.list.first.kill
35
35
  end
36
36
 
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sinatra_fake_webservice}
8
- s.version = "0.9.0"
8
+ s.version = "0.9.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Elad Meidar"]
@@ -23,6 +23,8 @@ class TestSinatraFakeWebservice < Test::Unit::TestCase
23
23
  @sinatra_app.put '/gimmieitnow' do
24
24
  "yay, i haz it."
25
25
  end
26
+
27
+ #@sinatra_app.run!
26
28
  end
27
29
 
28
30
  should "have default host and port" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra_fake_webservice
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elad Meidar