Permalink
Browse files

add a spec

  • Loading branch information...
jugyo committed Mar 6, 2012
1 parent f1b5544 commit ec41b4840ad6b2d29e732d8d24475eb1c79eace6
Showing with 40 additions and 2 deletions.
  1. +8 −0 Rakefile
  2. +3 −2 mocktra.gemspec
  3. +24 −0 spec/mocktra_spec.rb
  4. +5 −0 spec/spec_helper.rb
View
@@ -1 +1,9 @@
require "bundler/gem_tasks"
+
+require 'rspec/core'
+require 'rspec/core/rake_task'
+RSpec::Core::RakeTask.new(:spec) do |spec|
+ spec.pattern = FileList['spec/**/*_spec.rb']
+end
+
+task :default => :spec
View
@@ -19,8 +19,9 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]
# specify any dependencies here; for example:
- # s.add_development_dependency "rspec"
- s.add_runtime_dependency "webmock"
+ s.add_development_dependency "rake"
+ s.add_development_dependency "rspec", "~> 2.8"
+ s.add_development_dependency "httpclient"
s.add_runtime_dependency "webmock", "~> 1.8"
s.add_runtime_dependency "sinatra", "~> 1.3"
end
View
@@ -0,0 +1,24 @@
+require 'spec_helper'
+
+describe Mocktra do
+ it 'works' do
+ Mocktra('www.example.com') do
+ get '/foo' do
+ 'FOO!!'
+ end
+
+ post '/foo' do
+ params.inspect
+ end
+ end
+
+ require 'httpclient'
+ client = HTTPClient.new
+
+ res = client.get("http://www.example.com/foo")
+ res.body.should == 'FOO!!'
+
+ res = client.post("http://www.example.com/foo", 'bar' => 'baz')
+ res.body.should == '{"bar"=>"baz"}'
+ end
+end
View
@@ -0,0 +1,5 @@
+require 'rspec'
+require 'mocktra'
+
+RSpec.configure do |config|
+end

0 comments on commit ec41b48

Please sign in to comment.