Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 52 additions & 52 deletions test/client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe TrackerApi do
it 'has a version' do
::TrackerApi::VERSION.wont_be_nil
_(::TrackerApi::VERSION).wont_be_nil
end
end

Expand All @@ -13,10 +13,10 @@
token: '12345',
logger: LOGGER)

client.url.must_equal 'http://test.com'
client.api_version.must_equal '/foo-bar/1'
client.token.must_equal '12345'
client.logger.must_equal LOGGER
_(client.url).must_equal 'http://test.com'
_(client.api_version).must_equal '/foo-bar/1'
_(client.token).must_equal '12345'
_(client.logger).must_equal LOGGER
end

describe '.projects' do
Expand All @@ -27,18 +27,18 @@
VCR.use_cassette('get all projects', record: :new_episodes) do
projects = client.projects(fields: ':default,account,current_velocity,labels(name),epics(:default,label(name))')

projects.wont_be_empty
_(projects).wont_be_empty
project = projects.first
project.must_be_instance_of TrackerApi::Resources::Project
project.id.must_equal pt_user[:project_id]
_(project).must_be_instance_of TrackerApi::Resources::Project
_(project.id).must_equal pt_user[:project_id]

project.account.must_be_instance_of TrackerApi::Resources::Account
_(project.account).must_be_instance_of TrackerApi::Resources::Account

project.labels.wont_be_empty
project.labels.first.must_be_instance_of TrackerApi::Resources::Label
_(project.labels).wont_be_empty
_(project.labels.first).must_be_instance_of TrackerApi::Resources::Label

project.epics.wont_be_empty
project.epics.first.must_be_instance_of TrackerApi::Resources::Epic
_(project.epics).wont_be_empty
_(project.epics.first).must_be_instance_of TrackerApi::Resources::Epic
end
end
end
Expand All @@ -52,11 +52,11 @@
VCR.use_cassette('get project', record: :new_episodes) do
project = client.project(project_id)

project.must_be_instance_of TrackerApi::Resources::Project
project.id.must_equal project_id
_(project).must_be_instance_of TrackerApi::Resources::Project
_(project.id).must_equal project_id

project.account.must_be_nil
project.account_id.wont_be_nil
_(project.account).must_be_nil
_(project.account_id).wont_be_nil
end
end
end
Expand All @@ -69,9 +69,9 @@
VCR.use_cassette('get workspace', record: :new_episodes) do
workspace = client.workspace(pt_user[:workspace_id])

workspace.must_be_instance_of TrackerApi::Resources::Workspace
workspace.id.must_equal pt_user[:workspace_id]
workspace.name.wont_be_empty
_(workspace).must_be_instance_of TrackerApi::Resources::Workspace
_(workspace.id).must_equal pt_user[:workspace_id]
_(workspace.name).wont_be_empty
end
end
end
Expand All @@ -85,10 +85,10 @@
VCR.use_cassette('get all workspaces', record: :new_episodes) do
workspaces = client.workspaces(fields: ':default,projects(id,name)')

workspaces.wont_be_empty
_(workspaces).wont_be_empty
workspace = workspaces.first
workspace.must_be_instance_of TrackerApi::Resources::Workspace
workspace.id.must_equal pt_user[:workspace_id]
_(workspace).must_be_instance_of TrackerApi::Resources::Workspace
_(workspace.id).must_equal pt_user[:workspace_id]
end
end
end
Expand All @@ -105,10 +105,10 @@
VCR.use_cassette('get me', record: :new_episodes) do
me = client.me

me.must_be_instance_of TrackerApi::Resources::Me
me.username.must_equal username
_(me).must_be_instance_of TrackerApi::Resources::Me
_(me.username).must_equal username

me.projects.map(&:project_id).must_include project_id
_(me.projects.map(&:project_id)).must_include project_id
end
end
end
Expand All @@ -124,14 +124,14 @@

# skip pagination with a hugh limit
unpaged_stories = project.stories(limit: 300)
unpaged_stories.wont_be_empty
unpaged_stories.length.must_be :>, 7
_(unpaged_stories).wont_be_empty
_(unpaged_stories.length).must_be :>, 7

# force pagination with a small limit
paged_stories = project.stories(limit: 7)
paged_stories.wont_be_empty
paged_stories.length.must_equal unpaged_stories.length
paged_stories.map(&:id).sort.uniq.must_equal unpaged_stories.map(&:id).sort.uniq
_(paged_stories).wont_be_empty
_(paged_stories.length).must_equal unpaged_stories.length
_(paged_stories.map(&:id).sort.uniq).must_equal unpaged_stories.map(&:id).sort.uniq
end
end

Expand All @@ -141,8 +141,8 @@

# force no pagination
stories = project.stories(limit: 7, auto_paginate: false)
stories.wont_be_empty
stories.length.must_equal 7
_(stories).wont_be_empty
_(stories.length).must_equal 7
end
end

Expand All @@ -152,8 +152,8 @@

done_iterations = project.iterations(scope: :done, offset: -12, limit: 5)

done_iterations.wont_be_empty
done_iterations.length.must_be :<=, 12
_(done_iterations).wont_be_empty
_(done_iterations.length).must_be :<=, 12
end
end
end
Expand All @@ -166,8 +166,8 @@
VCR.use_cassette('client: get single story by story id', record: :new_episodes) do
story = client.story('66728004', fields: ':default,owned_by')

story.must_be_instance_of TrackerApi::Resources::Story
story.owned_by.wont_be_nil
_(story).must_be_instance_of TrackerApi::Resources::Story
_(story.owned_by).wont_be_nil
end
end
end
Expand All @@ -180,8 +180,8 @@
VCR.use_cassette('client: get single epic by epic id', record: :new_episodes) do
epic = client.epic('1087314', fields: ':default,label_id')

epic.must_be_instance_of TrackerApi::Resources::Epic
epic.label_id.wont_be_nil
_(epic).must_be_instance_of TrackerApi::Resources::Epic
_(epic.label_id).wont_be_nil
end
end
end
Expand All @@ -194,13 +194,13 @@
VCR.use_cassette('get all notifications', record: :new_episodes) do
notifications = client.notifications

notifications.wont_be_empty
_(notifications).wont_be_empty
notification = notifications.first
notification.must_be_instance_of TrackerApi::Resources::Notification
_(notification).must_be_instance_of TrackerApi::Resources::Notification

notification.project.id.must_equal pt_user[:project_id]
notification.story.must_be_instance_of TrackerApi::Resources::Story
notification.performer.must_be_instance_of TrackerApi::Resources::Person
_(notification.project.id).must_equal pt_user[:project_id]
_(notification.story).must_be_instance_of TrackerApi::Resources::Story
_(notification.performer).must_be_instance_of TrackerApi::Resources::Person
end
end
end
Expand All @@ -213,19 +213,19 @@
VCR.use_cassette('get my activities', record: :new_episodes) do
activities = client.activity(fields: ':default')

activities.wont_be_empty
_(activities).wont_be_empty
activity = activities.first
activity.must_be_instance_of TrackerApi::Resources::Activity
_(activity).must_be_instance_of TrackerApi::Resources::Activity

activity.changes.wont_be_empty
activity.changes.first.must_be_instance_of TrackerApi::Resources::Change
_(activity.changes).wont_be_empty
_(activity.changes.first).must_be_instance_of TrackerApi::Resources::Change

activity.primary_resources.wont_be_empty
activity.primary_resources.first.must_be_instance_of TrackerApi::Resources::PrimaryResource
_(activity.primary_resources).wont_be_empty
_(activity.primary_resources.first).must_be_instance_of TrackerApi::Resources::PrimaryResource

activity.project.must_be_instance_of TrackerApi::Resources::Project
_(activity.project).must_be_instance_of TrackerApi::Resources::Project

activity.performed_by.must_be_instance_of TrackerApi::Resources::Person
_(activity.performed_by).must_be_instance_of TrackerApi::Resources::Person
end
end
end
Expand Down
26 changes: 13 additions & 13 deletions test/comment_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
comment = story.create_comment(text: text)
end

comment.text.must_equal text
comment.clean?.must_equal true
_(comment.text).must_equal text
_(comment.clean?).must_equal true
end

it 'can create a comment with file attachment' do
Expand All @@ -28,9 +28,9 @@
VCR.use_cassette('create comment with attachment', record: :new_episodes) do
comment = story.create_comment(text: text, files: files)
end
comment.text.must_equal text
comment.attachments.size.must_equal 1
comment.clean?.must_equal true
_(comment.text).must_equal text
_(comment.attachments.size).must_equal 1
_(comment.clean?).must_equal true
end

it 'can update an existing comment' do
Expand All @@ -41,37 +41,37 @@
existing_comment.save
end

existing_comment.text.must_equal new_text
existing_comment.clean?.must_equal true
_(existing_comment.text).must_equal new_text
_(existing_comment.clean?).must_equal true
end

it 'can create attachments in a comment' do
files = [File.expand_path('../Gemfile', File.dirname(__FILE__))]
VCR.use_cassette('create attachments', record: :new_episodes) do
existing_comment.create_attachments(files: files)
existing_comment.attachments.size.must_equal 1
existing_comment.clean?.must_equal true
_(existing_comment.attachments.size).must_equal 1
_(existing_comment.clean?).must_equal true
end
end

it 'can delete attachments in a comment' do
files = [File.expand_path('../Gemfile', File.dirname(__FILE__))]
VCR.use_cassette('delete attachments', record: :new_episodes) do
existing_comment.create_attachments(files: files)
existing_comment.attachments.size.must_equal 1
_(existing_comment.attachments.size).must_equal 1
existing_comment.delete_attachments
existing_comment.attachments.size.must_equal 0
_(existing_comment.attachments.size).must_equal 0
end
end

it 'can delete a comment' do
VCR.use_cassette('delete comment', record: :new_episodes) do
current_story = project.story(story_id)
new_comment_id = current_story.create_comment(text: "test comment").id
current_story.comments.last.id.must_equal new_comment_id
_(current_story.comments.last.id).must_equal new_comment_id
current_story.comments.last.delete
current_story = project.story(story_id)
current_story.comments.last.id.wont_equal new_comment_id
_(current_story.comments.last.id).wont_equal new_comment_id
end
end
end
4 changes: 2 additions & 2 deletions test/file_attachment_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
it 'can be deleted' do
VCR.use_cassette('delete an attachment', record: :new_episodes) do
comment_with_attachments = story.create_comment(text: "test comment", files: [File.expand_path('../Gemfile', File.dirname(__FILE__))])
comment_with_attachments.attachments(reload: true).size.must_equal 1
_(comment_with_attachments.attachments(reload: true).size).must_equal 1
comment_with_attachments.attachments.first.delete
comment_with_attachments.attachments(reload: true).size.must_equal 0
_(comment_with_attachments.attachments(reload: true).size).must_equal 0
end
end
end
5 changes: 4 additions & 1 deletion test/minitest_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

require 'minitest/byebug' if ENV['DEBUG']
require 'minitest/autorun'
require 'mocha/mini_test'

require 'mocha'
Mocha::VERSION.to_f >= 1.9 ? require('mocha/minitest') : require('mocha/mini_test')

require 'awesome_print'
require 'multi_json'
require 'vcr'
Expand Down
Loading