Module: RSpec::Resources::DSL::Actions::ClassMethods
- Defined in:
- lib/rspec/resources/dsl/actions.rb
Instance Method Summary collapse
-
#describe_create(opts = {}, &block) ⇒ Object
rubocop:disable Metrics/AbcSize.
- #describe_destroy(opts = {}, &block) ⇒ Object
- #describe_index(opts = {}, &block) ⇒ Object
- #describe_show(opts = {}, &block) ⇒ Object
-
#describe_update(opts = {}, &block) ⇒ Object
rubocop:enable Metrics/AbcSize.
Instance Method Details
#describe_create(opts = {}, &block) ⇒ Object
rubocop:disable Metrics/AbcSize
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/rspec/resources/dsl/actions.rb', line 48 def describe_create(opts = {}, &block) path = [:base_path] describe "POST #{path}", opts do let(:params) { |ce| attributes_for(ce.[:resource_name]) } let(:instantiation_resource) { accessible_resource } before do |current_example| if Util.nested_resource? current_example. # 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) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# 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) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rspec/resources/dsl/actions.rb', line 12 def describe_index(opts = {}, &block) path = [: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) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# 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) ⇒ Object
rubocop:enable Metrics/AbcSize
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# 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.[: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 |