mirror of
https://github.com/samsonjs/grape-active_model_serializers.git
synced 2026-04-27 14:57:43 +00:00
Added guard-rspec
This commit is contained in:
parent
dddd528ea4
commit
f50a86f890
4 changed files with 36 additions and 0 deletions
BIN
.DS_Store
vendored
BIN
.DS_Store
vendored
Binary file not shown.
24
Guardfile
Normal file
24
Guardfile
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
# A sample Guardfile
|
||||||
|
# More info at https://github.com/guard/guard#readme
|
||||||
|
|
||||||
|
guard 'rspec' do
|
||||||
|
watch(%r{^spec/.+_spec\.rb$})
|
||||||
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
||||||
|
watch('spec/spec_helper.rb') { "spec" }
|
||||||
|
|
||||||
|
# Rails example
|
||||||
|
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
||||||
|
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
||||||
|
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
||||||
|
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
||||||
|
watch('config/routes.rb') { "spec/routing" }
|
||||||
|
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
||||||
|
|
||||||
|
# Capybara features specs
|
||||||
|
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
||||||
|
|
||||||
|
# Turnip features and steps
|
||||||
|
watch(%r{^spec/acceptance/(.+)\.feature$})
|
||||||
|
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
||||||
|
end
|
||||||
|
|
||||||
|
|
@ -22,4 +22,5 @@ Gem::Specification.new do |gem|
|
||||||
gem.add_development_dependency "rack-test"
|
gem.add_development_dependency "rack-test"
|
||||||
gem.add_development_dependency "rake"
|
gem.add_development_dependency "rake"
|
||||||
gem.add_development_dependency "jazz_hands"
|
gem.add_development_dependency "jazz_hands"
|
||||||
|
gem.add_development_dependency 'guard-rspec'
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -85,5 +85,16 @@ describe Grape::ActiveModelSerializers do
|
||||||
get "/admin/jeff"
|
get "/admin/jeff"
|
||||||
last_response.body.should == "{\"user\":{\"first_name\":\"Jeff\",\"last_name\":null}}"
|
last_response.body.should == "{\"user\":{\"first_name\":\"Jeff\",\"last_name\":null}}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'uses the name of the closest scope (namespace/route) for the root' do
|
||||||
|
app.namespace :admin, :serializer => UserSerializer do
|
||||||
|
get('/jeff') do
|
||||||
|
User.new(first_name: 'Jeff')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
get "/admin/jeff"
|
||||||
|
last_response.body.should == "{\"admin\":{\"first_name\":\"Jeff\",\"last_name\":null}}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue