Module: RSpec::Resources::DSL::Characteristics::ClassMethods

Defined in:
lib/rspec/resources/dsl/characteristics.rb

Instance Method Summary collapse

Instance Method Details

#hidden_attributes(*params) ⇒ Object



15
16
17
18
# File 'lib/rspec/resources/dsl/characteristics.rb', line 15

def hidden_attributes(*params)
  params = params.first if params.length == 1 && params.first.is_a?(Array)
  let(:hidden_attributes) { params }
end

#it_has_restricted_access(for_resource: :restricted_resource, only: %i[index show create update destroy])) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/rspec/resources/dsl/characteristics.rb', line 31

def it_has_restricted_access(for_resource: :restricted_resource, only: i[index show create update destroy])
  [:it_has_restricted_access] = {
    for_resource: for_resource,
    error_status: 404,
    only: only,
  }
end

#it_needs_authentication(with_headers: :auth_headers, only: %i[index show create update destroy])) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/rspec/resources/dsl/characteristics.rb', line 20

def it_needs_authentication(with_headers: :auth_headers, only: i[index show create update destroy])
  [:it_needs_authentication] = {
    headers: with_headers,
    error_status: 401,
    only: only,
  }

  [:request_headers] ||= []
  [:request_headers].push with_headers
end

#visible_attributes(*params) ⇒ Object



10
11
12
13
# File 'lib/rspec/resources/dsl/characteristics.rb', line 10

def visible_attributes(*params)
  params = params.first if params.length == 1 && params.first.is_a?(Array)
  let(:visible_attributes) { params }
end