Module: Kangaru::Initialisers::RSpec::RequestHelper

Extended by:
RSpec::Matchers::DSL
Defined in:
lib/kangaru/initialisers/rspec/request_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#requestObject (readonly)

Returns the value of attribute request.



5
6
7
# File 'lib/kangaru/initialisers/rspec/request_helper.rb', line 5

def request
  @request
end

Instance Method Details

#resolve(path, params:) ⇒ Object



19
20
21
22
23
# File 'lib/kangaru/initialisers/rspec/request_helper.rb', line 19

def resolve(path, params:)
  @request = Kangaru::Request.new(path:, params:)

  Kangaru.application.router.resolve(request)
end

#stub_output(&block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/kangaru/initialisers/rspec/request_helper.rb', line 7

def stub_output(&block)
  stdout  = $stdout
  stderr  = $stderr
  $stdout = File.open(File::NULL, "w")
  $stderr = File.open(File::NULL, "w")

  block.call

  $stdout = stdout
  $stderr = stderr
end

#view_path(name) ⇒ Object



25
26
27
# File 'lib/kangaru/initialisers/rspec/request_helper.rb', line 25

def view_path(name)
  Kangaru.application!.view_path(described_class.path, name.to_s)
end