This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Get Grape, Rack::Test and RSpec all working together

  • Loading branch information...
titanous committed Jul 24, 2012
1 parent dca202c commit dcf730c549921b413edadae1fd457659e2917d83
Showing with 51 additions and 2 deletions.
  1. +1 −0 .rspec
  2. +8 −1 Rakefile
  3. 0 bin/sp-server
  4. +2 −1 lib/sp-server.rb
  5. +9 −0 lib/sp-server/api.rb
  6. +7 −0 sp-server.gemspec
  7. +14 −0 spec/sp-server/api_spec.rb
  8. +10 −0 spec/spec_helper.rb
View
1 .rspec
@@ -0,0 +1 @@
+--color --backtrace --format documentation
View
@@ -1 +1,8 @@
-require "bundler/gem_tasks"
+require 'bundler/setup'
+require 'bundler/gem_tasks'
+
+require 'rspec/core/rake_task'
+RSpec::Core::RakeTask.new(:spec) do |spec|
+ spec.pattern = 'spec/**/*_spec.rb'
+end
+task :default => :spec
View
0 bin/sp-server 100644 → 100755
No changes.
View
@@ -2,6 +2,7 @@
module SP
module Server
- # Your code goes here...
+ autoload :API, 'sp-server/api'
end
end
+
View
@@ -0,0 +1,9 @@
+require 'grape'
+
+module SP
+ module Server
+ class API < Grape::API
+
+ end
+ end
+end
View
@@ -16,4 +16,11 @@ Gem::Specification.new do |gem|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.require_paths = ["lib"]
+
+ gem.add_runtime_dependency 'grape'
+
+ gem.add_development_dependency 'rack-test'
+ gem.add_development_dependency 'rspec', '~> 2.11'
+ gem.add_development_dependency 'bundler'
+ gem.add_development_dependency 'rake'
end
View
@@ -0,0 +1,14 @@
+require 'spec_helper'
+
+describe SP::Server::API do
+ def app
+ SP::Server::API
+ end
+
+ describe "GET /foo" do
+ it "works" do
+ get "/foo"
+ last_response.status.should == 404
+ end
+ end
+end
View
@@ -0,0 +1,10 @@
+$LOAD_PATH.unshift(File.dirname(__FILE__))
+$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
+
+require 'bundler/setup'
+require 'rack/test'
+require 'sp-server'
+
+RSpec.configure do |config|
+ config.include Rack::Test::Methods
+end

0 comments on commit dcf730c

Please sign in to comment.