specs for bitbucket representers
This commit is contained in:
parent
c45484ba19
commit
a2be395401
|
|
@ -6,15 +6,15 @@ module Bitbucket
|
|||
end
|
||||
|
||||
def file_path
|
||||
inline.fetch('path', nil)
|
||||
inline.fetch('path')
|
||||
end
|
||||
|
||||
def old_pos
|
||||
inline.fetch('from', nil)
|
||||
inline.fetch('from')
|
||||
end
|
||||
|
||||
def new_pos
|
||||
inline.fetch('to', nil)
|
||||
inline.fetch('to')
|
||||
end
|
||||
|
||||
def parent_id
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Bitbucket::Representation::Comment do
|
||||
describe '#author' do
|
||||
it { expect(described_class.new('user' => { 'username' => 'Ben' }).author).to eq('Ben') }
|
||||
it { expect(described_class.new({}).author).to eq('Anonymous') }
|
||||
end
|
||||
|
||||
describe '#note' do
|
||||
it { expect(described_class.new('content' => { 'raw' => 'Text' }).note).to eq('Text') }
|
||||
it { expect(described_class.new({}).note).to be_nil }
|
||||
end
|
||||
|
||||
describe '#created_at' do
|
||||
it { expect(described_class.new('created_on' => Date.today).created_at).to eq(Date.today) }
|
||||
end
|
||||
|
||||
describe '#updated_at' do
|
||||
it { expect(described_class.new('updated_on' => Date.today).updated_at).to eq(Date.today) }
|
||||
it { expect(described_class.new('created_on' => Date.today).updated_at).to eq(Date.today) }
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Bitbucket::Representation::Issue do
|
||||
describe '#iid' do
|
||||
it { expect(described_class.new('id' => 1).iid).to eq(1) }
|
||||
end
|
||||
|
||||
describe '#kind' do
|
||||
it { expect(described_class.new('kind' => 'bug').kind).to eq('bug') }
|
||||
end
|
||||
|
||||
describe '#author' do
|
||||
it { expect(described_class.new({ 'reporter' => { 'username' => 'Ben' }}).author).to eq('Ben') }
|
||||
it { expect(described_class.new({}).author).to eq('Anonymous') }
|
||||
end
|
||||
|
||||
describe '#description' do
|
||||
it { expect(described_class.new({ 'content' => { 'raw' => 'Text' }}).description).to eq('Text') }
|
||||
it { expect(described_class.new({}).description).to be_nil }
|
||||
end
|
||||
|
||||
describe '#state' do
|
||||
it { expect(described_class.new({ 'state' => 'invalid' }).state).to eq('closed') }
|
||||
it { expect(described_class.new({ 'state' => 'wontfix' }).state).to eq('closed') }
|
||||
it { expect(described_class.new({ 'state' => 'resolved' }).state).to eq('closed') }
|
||||
it { expect(described_class.new({ 'state' => 'duplicate' }).state).to eq('closed') }
|
||||
it { expect(described_class.new({ 'state' => 'closed' }).state).to eq('closed') }
|
||||
it { expect(described_class.new({ 'state' => 'opened' }).state).to eq('opened') }
|
||||
end
|
||||
|
||||
describe '#title' do
|
||||
it { expect(described_class.new('title' => 'Issue').title).to eq('Issue') }
|
||||
end
|
||||
|
||||
describe '#created_at' do
|
||||
it { expect(described_class.new('created_on' => Date.today).created_at).to eq(Date.today) }
|
||||
end
|
||||
|
||||
describe '#updated_at' do
|
||||
it { expect(described_class.new('edited_on' => Date.today).updated_at).to eq(Date.today) }
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Bitbucket::Representation::PullRequestComment do
|
||||
describe '#iid' do
|
||||
it { expect(described_class.new('id' => 1).iid).to eq(1) }
|
||||
end
|
||||
|
||||
describe '#file_path' do
|
||||
it { expect(described_class.new('inline' => { 'path' => '/path' }).file_path).to eq('/path') }
|
||||
end
|
||||
|
||||
describe '#old_pos' do
|
||||
it { expect(described_class.new('inline' => { 'from' => 3 }).old_pos).to eq(3) }
|
||||
end
|
||||
|
||||
describe '#new_pos' do
|
||||
it { expect(described_class.new('inline' => { 'to' => 3 }).new_pos).to eq(3) }
|
||||
end
|
||||
|
||||
|
||||
describe '#parent_id' do
|
||||
it { expect(described_class.new({ 'parent' => { 'id' => 2 }}).parent_id).to eq(2) }
|
||||
it { expect(described_class.new({}).parent_id).to be_nil }
|
||||
end
|
||||
|
||||
describe '#inline?' do
|
||||
it { expect(described_class.new('inline' => {}).inline?).to be_truthy }
|
||||
it { expect(described_class.new({}).inline?).to be_falsey }
|
||||
end
|
||||
|
||||
describe '#has_parent?' do
|
||||
it { expect(described_class.new('parent' => {}).has_parent?).to be_truthy }
|
||||
it { expect(described_class.new({}).has_parent?).to be_falsey }
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Bitbucket::Representation::PullRequest do
|
||||
describe '#iid' do
|
||||
it { expect(described_class.new('id' => 1).iid).to eq(1) }
|
||||
end
|
||||
|
||||
describe '#author' do
|
||||
it { expect(described_class.new({ 'author' => { 'username' => 'Ben' }}).author).to eq('Ben') }
|
||||
it { expect(described_class.new({}).author).to eq('Anonymous') }
|
||||
end
|
||||
|
||||
describe '#description' do
|
||||
it { expect(described_class.new({ 'description' => 'Text' }).description).to eq('Text') }
|
||||
it { expect(described_class.new({}).description).to be_nil }
|
||||
end
|
||||
|
||||
describe '#state' do
|
||||
it { expect(described_class.new({ 'state' => 'MERGED' }).state).to eq('merged') }
|
||||
it { expect(described_class.new({ 'state' => 'DECLINED' }).state).to eq('closed') }
|
||||
it { expect(described_class.new({}).state).to eq('opened') }
|
||||
end
|
||||
|
||||
describe '#title' do
|
||||
it { expect(described_class.new('title' => 'Issue').title).to eq('Issue') }
|
||||
end
|
||||
|
||||
describe '#source_branch_name' do
|
||||
it { expect(described_class.new({ source: { branch: { name: 'feature' } } }.with_indifferent_access).source_branch_name).to eq('feature') }
|
||||
it { expect(described_class.new({ source: {} }.with_indifferent_access).source_branch_name).to be_nil }
|
||||
end
|
||||
|
||||
describe '#source_branch_sha' do
|
||||
it { expect(described_class.new({ source: { commit: { hash: 'abcd123' } } }.with_indifferent_access).source_branch_sha).to eq('abcd123') }
|
||||
it { expect(described_class.new({ source: {} }.with_indifferent_access).source_branch_sha).to be_nil }
|
||||
end
|
||||
|
||||
describe '#target_branch_name' do
|
||||
it { expect(described_class.new({ destination: { branch: { name: 'master' } } }.with_indifferent_access).target_branch_name).to eq('master') }
|
||||
it { expect(described_class.new({ destination: {} }.with_indifferent_access).target_branch_name).to be_nil }
|
||||
end
|
||||
|
||||
describe '#target_branch_sha' do
|
||||
it { expect(described_class.new({ destination: { commit: { hash: 'abcd123' } } }.with_indifferent_access).target_branch_sha).to eq('abcd123') }
|
||||
it { expect(described_class.new({ destination: {} }.with_indifferent_access).target_branch_sha).to be_nil }
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Bitbucket::Representation::User do
|
||||
describe '#username' do
|
||||
it 'returns correct value' do
|
||||
user = described_class.new('username' => 'Ben')
|
||||
|
||||
expect(user.username).to eq('Ben')
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue