This repository has been archived by the owner on Jan 2, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove unused class definition from generated service template
- Loading branch information
Showing
2 changed files
with
59 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# encoding: utf-8 | ||
$:.unshift File.expand_path("../lib", __FILE__) | ||
require 'bundler' | ||
require 'active_support/inflector' | ||
|
||
class Default < Thor | ||
include Thor::Actions | ||
|
||
desc "service VERB URI FILENAME", "Generate scaffolding for a new service" | ||
def service(verb, route, path) | ||
route = route.gsub(/^\//, "") # strip leading forward slash | ||
path_without_suffix = path.gsub(/\.rb$/, "") | ||
create_file(File.join("api", "#{path_without_suffix}.rb")) do | ||
<<-RUBY.gsub(/^\s{6}/, '') | ||
describe_service "#{route}" do |service| | ||
service.formats :json | ||
service.http_verb :#{verb.downcase} | ||
service.disable_auth # on by default | ||
# INPUT | ||
service.param.string :name, :default => 'World', :doc => "The name of the person to greet." | ||
# OUTPUT | ||
service.response do |response| | ||
response.object do |obj| | ||
obj.string :message, :doc => "The greeting message sent back. Defaults to 'World'." | ||
obj.datetime :at, :doc => "The timestamp of when the message was dispatched." | ||
end | ||
end | ||
# DOCUMENTATION | ||
service.documentation do |doc| | ||
doc.overall "This service provides a simple hello world implementation example." | ||
doc.example "curl -I 'http://localhost:9292/hello_world?name=Matt'" | ||
end | ||
# ACTION/IMPLEMENTATION | ||
service.implementation do | ||
halt 501, "Not Implemented, which is a pity, I'm sure" | ||
end | ||
end | ||
RUBY | ||
end | ||
|
||
class_name = path_without_suffix.classify.gsub(/::/, '') # strip modules; just want a unique class name for spec | ||
create_file(File.join("test", "integration", "#{path_without_suffix}_test.rb")) do | ||
<<-RUBY.gsub(/^\s{6}/, '') | ||
require 'test_helpers' | ||
class #{class_name}Spec < MiniTest::Spec | ||
it "performs request" do | ||
TestApi.#{verb} "/#{route}", {} | ||
assert_api_response | ||
end | ||
end | ||
RUBY | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.