-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
154 additions
and
83 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,3 @@ | ||
--color | ||
--format=documentation | ||
|
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 |
---|---|---|
@@ -1,38 +1,18 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'rails', '3.2.8' | ||
|
||
# Bundle edge Rails instead: | ||
# gem 'rails', :git => 'git://github.com/rails/rails.git' | ||
|
||
gem 'sqlite3' | ||
gem 'jquery-rails' | ||
gem 'grape' | ||
|
||
|
||
# Gems used only for assets and not required | ||
# in production environments by default. | ||
group :assets do | ||
gem 'sass-rails', '~> 3.2.3' | ||
gem 'coffee-rails', '~> 3.2.1' | ||
|
||
# See https://github.com/sstephenson/execjs#readme for more supported runtimes | ||
# gem 'therubyracer', :platforms => :ruby | ||
|
||
gem 'uglifier', '>= 1.0.3' | ||
end | ||
|
||
gem 'jquery-rails' | ||
|
||
# To use ActiveModel has_secure_password | ||
# gem 'bcrypt-ruby', '~> 3.0.0' | ||
|
||
# To use Jbuilder templates for JSON | ||
# gem 'jbuilder' | ||
|
||
# Use unicorn as the app server | ||
# gem 'unicorn' | ||
|
||
# Deploy with Capistrano | ||
# gem 'capistrano' | ||
|
||
# To use debugger | ||
# gem 'debugger' | ||
group :test do | ||
gem "rspec" | ||
gem "rspec-rails" | ||
gem "capybara" | ||
end |
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
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,8 @@ | ||
class API < Grape::API | ||
prefix 'api' | ||
format :json | ||
mount API_v1 | ||
end | ||
|
||
|
||
|
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,13 @@ | ||
class API_v1 < Grape::API | ||
version 'v1', :using => :path, :vendor => 'acme', :format => :json | ||
resource :system do | ||
desc "Returns pong." | ||
get :ping do | ||
{ :ping => "pong" } | ||
end | ||
desc "Raises an exception." | ||
get :raise do | ||
raise "Unexpected error." | ||
end | ||
end | ||
end |
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
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,9 @@ | ||
if Rails.env.development? | ||
api_files = Dir["#{Rails.root}/app/api/**/*.rb"] | ||
api_reloader = ActiveSupport::FileUpdateChecker.new(api_files) do | ||
Rails.application.reload_routes! | ||
end | ||
ActionDispatch::Callbacks.to_prepare do | ||
api_reloader.execute_if_updated | ||
end | ||
end |
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 |
---|---|---|
@@ -1,58 +1,3 @@ | ||
GrapeOnRails::Application.routes.draw do | ||
# The priority is based upon order of creation: | ||
# first created -> highest priority. | ||
|
||
# Sample of regular route: | ||
# match 'products/:id' => 'catalog#view' | ||
# Keep in mind you can assign values other than :controller and :action | ||
|
||
# Sample of named route: | ||
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase | ||
# This route can be invoked with purchase_url(:id => product.id) | ||
|
||
# Sample resource route (maps HTTP verbs to controller actions automatically): | ||
# resources :products | ||
|
||
# Sample resource route with options: | ||
# resources :products do | ||
# member do | ||
# get 'short' | ||
# post 'toggle' | ||
# end | ||
# | ||
# collection do | ||
# get 'sold' | ||
# end | ||
# end | ||
|
||
# Sample resource route with sub-resources: | ||
# resources :products do | ||
# resources :comments, :sales | ||
# resource :seller | ||
# end | ||
|
||
# Sample resource route with more complex sub-resources | ||
# resources :products do | ||
# resources :comments | ||
# resources :sales do | ||
# get 'recent', :on => :collection | ||
# end | ||
# end | ||
|
||
# Sample resource route within a namespace: | ||
# namespace :admin do | ||
# # Directs /admin/products/* to Admin::ProductsController | ||
# # (app/controllers/admin/products_controller.rb) | ||
# resources :products | ||
# end | ||
|
||
# You can have the root of your site routed with "root" | ||
# just remember to delete public/index.html. | ||
# root :to => 'welcome#index' | ||
|
||
# See how all your routes lay out with "rake routes" | ||
|
||
# This is a legacy wild controller route that's not recommended for RESTful applications. | ||
# Note: This route will make all actions in every controller accessible via GET requests. | ||
# match ':controller(/:action(/:id))(.:format)' | ||
mount API => '/' | ||
end |
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,13 @@ | ||
require 'spec_helper' | ||
|
||
describe API do | ||
context "v1" do | ||
context "system" do | ||
it "ping" do | ||
get "/api/v1/system/ping" | ||
response.body.should == { :ping => "pong" }.to_json | ||
end | ||
end | ||
end | ||
end | ||
|
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,21 @@ | ||
require 'spec_helper' | ||
|
||
describe "Grape on Rails", :js => true, :type => :feature do | ||
context "homepage" do | ||
before :each do | ||
visit "/" | ||
end | ||
it "displays index.html page" do | ||
page.find("#header h2").should have_content "riding Ruby on Rails" | ||
end | ||
end | ||
context "exception" do | ||
before :each do | ||
visit "/api/v1/system/raise" | ||
end | ||
it "displays 500 page" do | ||
page.find("title").text.should == "Action Controller: Exception caught" | ||
end | ||
end | ||
end | ||
|
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,14 @@ | ||
require 'rubygems' | ||
|
||
require File.expand_path("../../config/environment", __FILE__) | ||
|
||
require 'rspec/rails' | ||
RSpec.configure do |config| | ||
config.mock_with :rspec | ||
config.expect_with :rspec | ||
config.include RSpec::Rails::RequestExampleGroup, :type => :request, :example_group => { | ||
:file_path => /spec\/api/ | ||
} | ||
end | ||
|
||
require 'capybara/rspec' |