Module: Webhookdb::IntegrationSpecHelpers
- Includes:
- Appydays::Configurable, Appydays::Loggable
- Defined in:
- lib/webhookdb/spec_helpers/integration.rb
Class Method Summary collapse
- .auth_customer(customer = nil) ⇒ Object
- .included(context) ⇒ Object
- .parse_cookie(resp) ⇒ Object
- .store_cookies ⇒ Object
- .stored_cookies ⇒ Object
- .url(more) ⇒ Object
- .with_async_publisher ⇒ Object
Class Method Details
.auth_customer(customer = nil) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/webhookdb/spec_helpers/integration.rb', line 67 module_function def auth_customer(customer=nil) if customer.nil? customer = Webhookdb::Fixtures.customer.instance resp = post("/v1/auth", body: {email: customer.email}) expect(resp).to party_status(202) customer = Webhookdb::Customer[email: customer.email] end code = Webhookdb::Fixtures.reset_code(customer:).create resp = post("/v1/auth", body: {email: customer.email, token: code.token}) expect(resp).to party_status(200) return customer.refresh end |
.included(context) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/webhookdb/spec_helpers/integration.rb', line 18 def self.included(context) # We run few workers on staging so need time to process things. Rspec::Eventually.timeout = 60 # We're in no rush for integration tests. Rspec::Eventually.pause = 1 context.before(:each) do |example| raise "Unit tests should not be run during integration tests (or this test needs an :integration flag" unless example.[:integration] @to_destroy = [] WebMock.allow_net_connect! if defined?(WebMock) end context.after(:each) do @to_destroy.each(&:destroy) WebMock.disable_net_connect! if defined?(WebMock) end super end |
.parse_cookie(resp) ⇒ Object
50 51 52 53 54 |
# File 'lib/webhookdb/spec_helpers/integration.rb', line 50 module_function def (resp) = HTTParty::CookieHash.new resp.get_fields("Set-Cookie")&.each { |c| .(c) } return end |
.store_cookies ⇒ Object
56 57 58 59 60 61 |
# File 'lib/webhookdb/spec_helpers/integration.rb', line 56 module_function def response = yield() @stored_cookies = (response) Webhookdb::IntegrationSpecHelpers.logger.debug "Got cookies: %p" % [] return response end |
.stored_cookies ⇒ Object
63 64 65 |
# File 'lib/webhookdb/spec_helpers/integration.rb', line 63 module_function def return @stored_cookies end |
.url(more) ⇒ Object
46 47 48 |
# File 'lib/webhookdb/spec_helpers/integration.rb', line 46 module_function def url(more) return "#{Webhookdb.api_url}#{more}" end |