Skip to content

Commit

Permalink
Add retryable to all API call
Browse files Browse the repository at this point in the history
  • Loading branch information
sue445 committed Jun 13, 2018
1 parent d432b80 commit 06e96cc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
21 changes: 14 additions & 7 deletions spec/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
end

it "successful real http connection" do # rubocop:disable RSpec/ExampleLength
category_and_boards = Itest5ch::Board.all
category_and_boards = Retryable.with_context(:default) do
Itest5ch::Board.all
end

expect(category_and_boards).to be_an_instance_of(Hash)

Expand All @@ -21,7 +23,13 @@

board = boards.sample

threads = board.threads
thread_exception_cb = proc do |_exception|
puts "Error: #{board.json_url}"
end

threads = Retryable.with_context(:default, exception_cb: thread_exception_cb) do
board.threads
end

aggregate_failures do
expect(threads).not_to be_empty
Expand All @@ -30,14 +38,13 @@

thread = threads.sample

exception_cb = proc do |_exception|
comment_exception_cb = proc do |_exception|
puts "Error: #{thread.json_url}"
end

comments =
Retryable.with_context(:default, exception_cb: exception_cb) do
thread.comments
end
comments = Retryable.with_context(:default, exception_cb: comment_exception_cb) do
thread.comments
end

aggregate_failures do
expect(comments).not_to be_empty
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
require "active_support/time"
require "rspec-parameterized"
require "retryable"
require "open-uri"

Dir["#{__dir__}/support/**/*.rb"].each {|f| require f }

Expand Down

0 comments on commit 06e96cc

Please sign in to comment.