Class: Shark::RSpec::FakeNotificationService::Request
- Inherits:
-
Object
- Object
- Shark::RSpec::FakeNotificationService::Request
- Includes:
- Singleton
- Defined in:
- lib/shark/rspec/fake_notification_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_notification_service/request.rb', line 11 def self.setup instance = self.instance instance.stub_requests end |
Instance Method Details
#host ⇒ Object
43 44 45 |
# File 'lib/shark/rspec/fake_notification_service/request.rb', line 43 def host Shark.configuration.notification_service.site end |
#log_info(message) ⇒ Object
47 48 49 |
# File 'lib/shark/rspec/fake_notification_service/request.rb', line 47 def log_info() Shark.logger.info "[Shark][NotificationService] #{}" end |
#stub_requests ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/shark/rspec/fake_notification_service/request.rb', line 16 def stub_requests WebMock.stub_request( :post, %r{^#{host}/notifications/bulk_creation} ).to_return do |request| log_info "Faking POST bulk creation request with body: #{request.body}" SharkSpec.fake_response(201, data: { type: 'notifications', id: '12345678-1234-1234-1234-1234567890ab' }) end WebMock.stub_request(:post, %r{^#{host}/notifications}).to_return do |request| log_info "Faking POST request with body: #{request.body}" id = SecureRandom.uuid payload_data = JSON.parse(request.body)['data'] SharkSpec.fake_response(201, data: { type: 'notifications', id: id, attributes: payload_data }) end end |