Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

run! removed

  • Loading branch information...
commit 1e85fc689395bda2e3decdef0093247f65ba9131 1 parent 38d8df8
Elad Meidar authored
30 README.rdoc
View
@@ -9,7 +9,7 @@ FakeWeb is awesome, but it allows you only to register *one* response per url, a
== Installation
Command line:
- sudo gem install sinatra_fake_webservice+
+ sudo gem install sinatra_fake_webservice
Or in bundler (0.9.x) add this line to your .gemfile:
@@ -26,17 +26,33 @@ and then simply use the familiar sinatra DSL to create methods and responses.
@fakews.get '/awesome' do
"YAY!!"
- end+
+ end
+
+ @fakews.post '/omglol' do
+ "YAY!! i posted #{params[:awesome]}"
+ end
+ @fakews.delete '/awesome' do
+ "there, i kiiled #{params[:id]}"
+ end
+
+ @fakews.put '/awesome' do
+ "yay, i saved the worlds"
+ end
+
tada!
-i simply used Net::HTTP to access the sinatra app, but i bet there are more ways to do it:
+== Tests
- res = Net::HTTP.start(@fakews.host, @fakews.port) do |http|
- http.get('/awesome')
- end
+I added a few methods to wrap HTTP requests:
+
+* get_response(path)
+* post_response(path, data, headers, dest)
+* put_response(path, data, headers, dest)
+* delete_response(path, data, headers, dest)
+
+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).
- assert_equal "YAY!!", res.body
== Note on Patches/Pull Requests
2  lib/sinatra_webservice.rb
View
@@ -30,7 +30,7 @@ def running?
end
def run!
- if Thread.list.size > 1
+ if Thread.list.size > 2
Thread.list.first.kill
end
6 sinatra_fake_webservice.gemspec
View
@@ -5,11 +5,11 @@
Gem::Specification.new do |s|
s.name = %q{sinatra_fake_webservice}
- s.version = "0.2.0"
+ s.version = "0.9.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Elad Meidar"]
- s.date = %q{2010-02-18}
+ s.date = %q{2010-03-03}
s.description = %q{FakeWeb allows you to fake a response from a specific url, this gem intends to give developers the option to allow several responses from the same url based on parameters (ex: WSDL)}
s.email = %q{elad@nautilus6.com}
s.extra_rdoc_files = [
@@ -23,9 +23,7 @@ Gem::Specification.new do |s|
"README.rdoc",
"Rakefile",
"VERSION",
- "lib/sinatra_ext.rb",
"lib/sinatra_webservice.rb",
- "lib/web_service.rb",
"metal/sinatra_stem.rb",
"sinatra.log",
"sinatra_fake_webservice.gemspec",
2  test/test_sinatra_fake_webservice.rb
View
@@ -23,6 +23,8 @@ class TestSinatraFakeWebservice < Test::Unit::TestCase
@sinatra_app.put '/gimmieitnow' do
"yay, i haz it."
end
+
+ #@sinatra_app.run!
end
should "have default host and port" do
Please sign in to comment.
Something went wrong with that request. Please try again.