Class: Shark::RSpec::FakeMailingService::Request
- Inherits:
-
Object
- Object
- Shark::RSpec::FakeMailingService::Request
- Includes:
- Singleton
- Defined in:
- lib/shark/rspec/fake_mailing_service/request.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.setup ⇒ Object
11 12 13 14 |
# File 'lib/shark/rspec/fake_mailing_service/request.rb', line 11 def self.setup instance = self.instance instance.stub_requests end |
Instance Method Details
#host ⇒ Object
31 32 33 |
# File 'lib/shark/rspec/fake_mailing_service/request.rb', line 31 def host Shark.configuration.mailing_service.site end |
#log_info(message) ⇒ Object
35 36 37 |
# File 'lib/shark/rspec/fake_mailing_service/request.rb', line 35 def log_info() end |
#stub_requests ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/shark/rspec/fake_mailing_service/request.rb', line 16 def stub_requests WebMock.stub_request(:post, %r{^#{host}/mails}).to_return do |request| log_info "[Shark][MailingService] Faking POST request with body: #{request.body}" id = SecureRandom.uuid payload_data = JSON.parse(request.body)['data'] SharkSpec.fake_response(201, data: { type: 'mails', id: id, attributes: payload_data }) end end |