Class: Webhookdb::Tasks::Specs

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/webhookdb/tasks/specs.rb

Instance Method Summary collapse

Constructor Details

#initializeSpecs

Returns a new instance of Specs.



10
11
12
13
14
15
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/webhookdb/tasks/specs.rb', line 10

def initialize
  super()
  namespace :specs do
    desc "Run API integration tests in the 'integration' folder of this gem. " \
         "To run your own tests, create a task similar to this one, " \
         "that calls Webhookdb::SpecHelpers::Citest.run_tests."
    task :integration do
      require "rspec/core"
      require "slack-notifier"
      require "webhookdb/spec_helpers/integration"
      require "webhookdb/spec_helpers/citest"
      Webhookdb::SpecHelpers::Citest.run_tests(Webhookdb::SpecHelpers::Citest::INTEGRATION_TESTS_DIR)
    end

    desc "The release process needs to finish quickly, so start the integration tests in another dyno."
    task :heroku_integration_step1 do
      require "webhookdb/heroku"
      Webhookdb::Heroku.client.dyno.create(
        Webhookdb::Heroku.app_name,
        command: "bundle exec rake specs:heroku_integration_step2",
        attach: false,
        time_to_live: 1.minute.to_i,
        type: "run",
      )
    end
    desc "Sleep 20 seconds to wait for the **next** one-off dyno to have the new code."
    task :heroku_integration_step2 do
      sleep(20)
      require "webhookdb/heroku"
      Webhookdb::Heroku.client.dyno.create(
        Webhookdb::Heroku.app_name,
        command: "bundle exec rake specs:heroku_integration_step3",
        env: {"INTEGRATION_TESTS" => "true"},
        attach: false,
        time_to_live: 10.minute.to_i,
        type: "run",
      )
    end
    desc "Run the actual integration tests."
    task :heroku_integration_step3 do
      require "webhookdb/heroku"
      Rake::Task["specs:integration"].invoke
    end

    desc "Do a thing through Rake so it's easy to run under the debugger"
    task :debugtask do
      require "webhookdb"
      Webhookdb.load_app
      sint = Webhookdb::ServiceIntegration[84]
      row_pk = 710
      expiring_before = 1.week.from_now
      sint.replicator.renew_watch_channel(row_pk:, expiring_before:)
    end
  end
end