module RSpec::Resources::DSL::Actions::ClassMethods
Public Instance Methods
describe_create(opts = {}, &block)
click to toggle source
rubocop:disable Metrics/AbcSize
# File lib/rspec/resources/dsl/actions.rb, line 48 def describe_create(opts = {}, &block) path = metadata[:base_path] describe "POST #{path}", opts do let(:params) { |ce| attributes_for(ce.metadata[:resource_name]) } let(:instantiation_resource) { accessible_resource } before do |current_example| if Util.nested_resource? current_example.metadata # we need to fill in the other ids with valid stuff instpath = instantiate_path(path, instantiation_resource) instantiation_resource.destroy! else instpath = path end post instpath, params: params.to_json, headers: request_headers end instance_eval(&block) include_if_needed(:create).auth_examples include_if_needed(:create).restricted_examples end end
describe_destroy(opts = {}, &block)
click to toggle source
# File lib/rspec/resources/dsl/actions.rb, line 92 def describe_destroy(opts = {}, &block) path = id_path_template describe "DELETE #{path}", opts do subject { accessible_resource } before { delete instantiate_path(path, subject), headers: request_headers } instance_eval(&block) include_if_needed(:destroy).auth_examples include_if_needed(:destroy).restricted_examples end end
describe_index(opts = {}, &block)
click to toggle source
# File lib/rspec/resources/dsl/actions.rb, line 12 def describe_index(opts = {}, &block) path = metadata[:base_path] describe "GET #{path}", opts do subject { [accessible_resource] } let(:params) { {} } before do subject # force subject creation get instantiate_path(path, subject.first), params: params, headers: request_headers end instance_eval(&block) include_if_needed(:index).auth_examples include_if_needed(:index).restricted_examples end end
describe_show(opts = {}, &block)
click to toggle source
# File lib/rspec/resources/dsl/actions.rb, line 32 def describe_show(opts = {}, &block) path = id_path_template describe "GET #{path}", opts do subject { accessible_resource } before { get instantiate_path(path, subject), headers: request_headers } instance_eval(&block) include_if_needed(:show).auth_examples include_if_needed(:show).restricted_examples end end
describe_update(opts = {}, &block)
click to toggle source
rubocop:enable Metrics/AbcSize
# File lib/rspec/resources/dsl/actions.rb, line 75 def describe_update(opts = {}, &block) path = id_path_template describe "PATCH/PUT #{path}", opts do subject { accessible_resource } let(:params) { |ce| attributes_for(ce.metadata[:resource_name]) } before { patch instantiate_path(path, subject), params: params.to_json, headers: request_headers } instance_eval(&block) include_if_needed(:update).auth_examples include_if_needed(:update).restricted_examples end end
Private Instance Methods
id_path_template()
click to toggle source
# File lib/rspec/resources/dsl/actions.rb, line 113 def id_path_template path = metadata[:base_path] metadata[:single_resource] ? path : (path + '/:id') end
include_if_needed(action)
click to toggle source
# File lib/rspec/resources/dsl/actions.rb, line 109 def include_if_needed(action) IncludeIfNeeded.new(self, action) end