Commit a2be3954 authored by Valery Sizov's avatar Valery Sizov

specs for bitbucket representers

parent c45484ba
...@@ -6,15 +6,15 @@ module Bitbucket ...@@ -6,15 +6,15 @@ module Bitbucket
end end
def file_path def file_path
inline.fetch('path', nil) inline.fetch('path')
end end
def old_pos def old_pos
inline.fetch('from', nil) inline.fetch('from')
end end
def new_pos def new_pos
inline.fetch('to', nil) inline.fetch('to')
end end
def parent_id def parent_id
......
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
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
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
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
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment