Skip to content

Commit

Permalink
Delay between specs to avoid failure due to '429 Too Many Requests'
Browse files Browse the repository at this point in the history
  • Loading branch information
tk committed Aug 22, 2015
1 parent ec581ac commit 80e84c5
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 19 deletions.
5 changes: 0 additions & 5 deletions spec/lib/togglv8/clients_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
describe 'Clients' do
before :all do
sleep(1)
@toggl = TogglV8::API.new(Testing::API_TOKEN)
@workspaces = @toggl.workspaces
@workspace_id = @workspaces.first['id']
Expand All @@ -18,7 +17,6 @@

context 'new client' do
before :all do
sleep(1)
@client = @toggl.create_client({ 'name' => 'new client', 'wid' => @workspace_id })
client_ids = @toggl.my_clients.map { |c| c['id'] }
expect(client_ids).to eq [ @client['id'] ]
Expand All @@ -42,7 +40,6 @@

context 'multiple clients' do
before :all do
sleep(1)
@client2 = @toggl.create_client({ 'name' => 'new client 2', 'wid' => @workspace_id })
end

Expand Down Expand Up @@ -85,7 +82,6 @@

context 'new client projects' do
before :all do
sleep(1)
@project = @toggl.create_project({ 'name' => 'project', 'wid' => @workspace_id, 'cid' => @client['id'] })
end

Expand Down Expand Up @@ -114,7 +110,6 @@

context 'updated client' do
before :each do
sleep(1)
@client = @toggl.create_client({ 'name' => 'client to update', 'wid' => @workspace_id })
end

Expand Down
1 change: 0 additions & 1 deletion spec/lib/togglv8/dashboard_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
describe 'Dashboard' do
before :all do
sleep(1)
@toggl = TogglV8::API.new(Testing::API_TOKEN)
@workspaces = @toggl.workspaces
@workspace_id = @workspaces.first['id']
Expand Down
3 changes: 0 additions & 3 deletions spec/lib/togglv8/projects_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
describe 'Projects' do
before :all do
sleep(1)
@toggl = TogglV8::API.new(Testing::API_TOKEN)
@workspaces = @toggl.workspaces
@workspace_id = @workspaces.first['id']
Expand All @@ -13,7 +12,6 @@

context 'new project' do
before :all do
sleep(1)
@project = @toggl.create_project({ 'name' => 'new project', 'wid' => @workspace_id })
project_ids = @toggl.my_projects.map { |p| p['id'] }
expect(project_ids).to eq [ @project['id'] ]
Expand Down Expand Up @@ -52,7 +50,6 @@

context 'updated project' do
before :each do
sleep(1)
@project = @toggl.create_project({ 'name' => 'project to update', 'wid' => @workspace_id })
end

Expand Down
3 changes: 0 additions & 3 deletions spec/lib/togglv8/tags_spec.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
describe 'Tags' do
before :all do
sleep(1)
@toggl = TogglV8::API.new(Testing::API_TOKEN)
@workspaces = @toggl.workspaces
@workspace_id = @workspaces.first['id']
end

context 'new tag' do
before :all do
sleep(1)
@tag = @toggl.create_tag({ 'name' => 'new tag', 'wid' => @workspace_id })
tag_ids = @toggl.my_tags.map { |t| t['id'] }
expect(tag_ids).to eq [ @tag['id'] ]
Expand All @@ -30,7 +28,6 @@

context 'updated tag' do
before :each do
sleep(1)
@tag = @toggl.create_tag({ 'name' => 'tag to update', 'wid' => @workspace_id })
end

Expand Down
3 changes: 0 additions & 3 deletions spec/lib/togglv8/tasks_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
describe 'Tasks', :pro_account do
before :all do
sleep(1)
@toggl = TogglV8::API.new(Testing::API_TOKEN)
@workspaces = @toggl.workspaces
@workspace_id = @workspaces.first['id']
Expand All @@ -13,7 +12,6 @@

context 'new task' do
before :all do
sleep(1)
@task = @toggl.create_task({ name: 'new task', pid: @project['id'] })
task_ids = @toggl.get_project_tasks(@project['id']).map { |t| t['id'] }
expect(task_ids).to eq [ @task['id'] ]
Expand Down Expand Up @@ -60,7 +58,6 @@

context 'multiple tasks' do
before :each do
sleep(1)
@task1 = @toggl.create_task({ name: 'task1', pid: @project['id'] })
@task2 = @toggl.create_task({ name: 'task2', pid: @project['id'] })
@task3 = @toggl.create_task({ name: 'task3', pid: @project['id'] })
Expand Down
1 change: 0 additions & 1 deletion spec/lib/togglv8/time_entries_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

describe 'Time Entries' do
before :all do
sleep(1)
@toggl = TogglV8::API.new(Testing::API_TOKEN)
@workspaces = @toggl.workspaces
@workspace_id = @workspaces.first['id']
Expand Down
1 change: 0 additions & 1 deletion spec/lib/togglv8/users_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
describe 'Users' do
before :all do
sleep(1)
@toggl = TogglV8::API.new(Testing::API_TOKEN)
@user = @toggl.me(all=true)
end
Expand Down
4 changes: 4 additions & 0 deletions spec/lib/togglv8_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
require 'fileutils'

describe 'TogglV8::API' do
before :each do
sleep(Testing::DELAY_SEC)
end

it 'initializes with api_token' do
toggl = TogglV8::API.new(Testing::API_TOKEN)
me = toggl.me
Expand Down
10 changes: 8 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@
end

config.before(:suite) do
TogglV8SpecHelper.setUp()
TogglV8SpecHelper.setUp()
puts "NOTE: Delaying #{Testing::DELAY_SEC} second(s) between specs to avoid failure due to '429 Too Many Requests'"
end

config.before(:each) do
sleep(Testing::DELAY_SEC)
end

# The settings below are suggested to provide a good initial experience
Expand Down Expand Up @@ -131,4 +136,5 @@ class Testing
API_TOKEN = '4880adbe1bee9a241fa08070d33bd49f'
USERNAME = 'togglv8@mailinator.com'
PASSWORD = 'togglv8'
end
DELAY_SEC = 1
end

0 comments on commit 80e84c5

Please sign in to comment.