mavenlink 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/Gemfile +3 -0
  6. data/README.md +241 -0
  7. data/Rakefile +28 -0
  8. data/bin/mavenlink-console +18 -0
  9. data/doc/ml_logo_lb-primary.png +0 -0
  10. data/lib/config/specification.yml +1665 -0
  11. data/lib/mavenlink.rb +134 -0
  12. data/lib/mavenlink/account_invitation.rb +4 -0
  13. data/lib/mavenlink/account_membership.rb +4 -0
  14. data/lib/mavenlink/additional_item.rb +4 -0
  15. data/lib/mavenlink/assignment.rb +5 -0
  16. data/lib/mavenlink/attachment.rb +11 -0
  17. data/lib/mavenlink/backup_approver_association.rb +4 -0
  18. data/lib/mavenlink/client.rb +116 -0
  19. data/lib/mavenlink/concerns/custom_fieldable.rb +9 -0
  20. data/lib/mavenlink/concerns/indestructible.rb +11 -0
  21. data/lib/mavenlink/concerns/locked_record.rb +30 -0
  22. data/lib/mavenlink/cost_rate.rb +4 -0
  23. data/lib/mavenlink/custom_field.rb +4 -0
  24. data/lib/mavenlink/custom_field_choice.rb +5 -0
  25. data/lib/mavenlink/custom_field_value.rb +4 -0
  26. data/lib/mavenlink/errors.rb +47 -0
  27. data/lib/mavenlink/expense.rb +4 -0
  28. data/lib/mavenlink/expense_category.rb +4 -0
  29. data/lib/mavenlink/expense_report_submission.rb +7 -0
  30. data/lib/mavenlink/external_payment.rb +4 -0
  31. data/lib/mavenlink/external_reference.rb +24 -0
  32. data/lib/mavenlink/fixed_fee_item.rb +4 -0
  33. data/lib/mavenlink/holiday.rb +4 -0
  34. data/lib/mavenlink/holiday_calendar.rb +4 -0
  35. data/lib/mavenlink/holiday_calendar_association.rb +4 -0
  36. data/lib/mavenlink/holiday_calendar_membership.rb +4 -0
  37. data/lib/mavenlink/invoice.rb +4 -0
  38. data/lib/mavenlink/logger.rb +62 -0
  39. data/lib/mavenlink/model.rb +279 -0
  40. data/lib/mavenlink/organization.rb +4 -0
  41. data/lib/mavenlink/organization_membership.rb +4 -0
  42. data/lib/mavenlink/participation.rb +4 -0
  43. data/lib/mavenlink/post.rb +4 -0
  44. data/lib/mavenlink/project_template.rb +4 -0
  45. data/lib/mavenlink/project_template_assignment.rb +4 -0
  46. data/lib/mavenlink/railtie.rb +7 -0
  47. data/lib/mavenlink/rate_card.rb +4 -0
  48. data/lib/mavenlink/rate_card_role.rb +4 -0
  49. data/lib/mavenlink/rate_card_set.rb +4 -0
  50. data/lib/mavenlink/rate_card_set_version.rb +30 -0
  51. data/lib/mavenlink/rate_card_version.rb +4 -0
  52. data/lib/mavenlink/request.rb +241 -0
  53. data/lib/mavenlink/resolution.rb +4 -0
  54. data/lib/mavenlink/response.rb +22 -0
  55. data/lib/mavenlink/role.rb +5 -0
  56. data/lib/mavenlink/settings.rb +11 -0
  57. data/lib/mavenlink/skill.rb +4 -0
  58. data/lib/mavenlink/skill_category.rb +4 -0
  59. data/lib/mavenlink/skill_membership.rb +4 -0
  60. data/lib/mavenlink/specificators/association.rb +13 -0
  61. data/lib/mavenlink/specificators/attribute.rb +13 -0
  62. data/lib/mavenlink/specificators/base.rb +24 -0
  63. data/lib/mavenlink/specificators/validation.rb +27 -0
  64. data/lib/mavenlink/status_report.rb +4 -0
  65. data/lib/mavenlink/story.rb +8 -0
  66. data/lib/mavenlink/story_allocation_day.rb +5 -0
  67. data/lib/mavenlink/story_dependency.rb +5 -0
  68. data/lib/mavenlink/story_task.rb +5 -0
  69. data/lib/mavenlink/tag.rb +5 -0
  70. data/lib/mavenlink/time_adjustment.rb +4 -0
  71. data/lib/mavenlink/time_entry.rb +4 -0
  72. data/lib/mavenlink/time_off_entry.rb +4 -0
  73. data/lib/mavenlink/timesheet_submission.rb +4 -0
  74. data/lib/mavenlink/user.rb +5 -0
  75. data/lib/mavenlink/vendor.rb +4 -0
  76. data/lib/mavenlink/workspace.rb +21 -0
  77. data/lib/mavenlink/workspace_group.rb +5 -0
  78. data/lib/mavenlink/workspace_invoice_preference.rb +4 -0
  79. data/lib/mavenlink/workweek.rb +4 -0
  80. data/lib/mavenlink/workweek_membership.rb +4 -0
  81. data/mavenlink.gemspec +29 -0
  82. data/spec/lib/mavenlink/account_membership_spec.rb +8 -0
  83. data/spec/lib/mavenlink/assignment_spec.rb +17 -0
  84. data/spec/lib/mavenlink/attachment_spec.rb +30 -0
  85. data/spec/lib/mavenlink/backup_approver_association_spec.rb +9 -0
  86. data/spec/lib/mavenlink/client_spec.rb +187 -0
  87. data/spec/lib/mavenlink/concerns/indestructible_spec.rb +13 -0
  88. data/spec/lib/mavenlink/concerns/locked_record_spec.rb +28 -0
  89. data/spec/lib/mavenlink/cost_rate_spec.rb +9 -0
  90. data/spec/lib/mavenlink/custom_field_value_spec.rb +10 -0
  91. data/spec/lib/mavenlink/expense_report_submission_spec.rb +16 -0
  92. data/spec/lib/mavenlink/expense_spec.rb +23 -0
  93. data/spec/lib/mavenlink/external_references_spec.rb +144 -0
  94. data/spec/lib/mavenlink/holiday_calendar_association_spec.rb +8 -0
  95. data/spec/lib/mavenlink/holiday_calendar_membership_spec.rb +8 -0
  96. data/spec/lib/mavenlink/holiday_spec.rb +7 -0
  97. data/spec/lib/mavenlink/invalid_request_error_spec.rb +9 -0
  98. data/spec/lib/mavenlink/invoice_spec.rb +176 -0
  99. data/spec/lib/mavenlink/model_spec.rb +439 -0
  100. data/spec/lib/mavenlink/post_spec.rb +23 -0
  101. data/spec/lib/mavenlink/rate_card_set_version_spec.rb +119 -0
  102. data/spec/lib/mavenlink/record_invalid_error_spec.rb +16 -0
  103. data/spec/lib/mavenlink/record_not_found_error_spec.rb +9 -0
  104. data/spec/lib/mavenlink/request_spec.rb +381 -0
  105. data/spec/lib/mavenlink/response_spec.rb +50 -0
  106. data/spec/lib/mavenlink/role_spec.rb +9 -0
  107. data/spec/lib/mavenlink/settings_spec.rb +23 -0
  108. data/spec/lib/mavenlink/skill_category_spec.rb +7 -0
  109. data/spec/lib/mavenlink/skill_membership_spec.rb +9 -0
  110. data/spec/lib/mavenlink/skill_spec.rb +8 -0
  111. data/spec/lib/mavenlink/specificators/association_spec.rb +25 -0
  112. data/spec/lib/mavenlink/specificators/attribute_spec.rb +25 -0
  113. data/spec/lib/mavenlink/specificators/validation_spec.rb +39 -0
  114. data/spec/lib/mavenlink/story_allocation_day_spec.rb +64 -0
  115. data/spec/lib/mavenlink/story_dependency_spec.rb +16 -0
  116. data/spec/lib/mavenlink/story_spec.rb +69 -0
  117. data/spec/lib/mavenlink/time_adjustment_spec.rb +13 -0
  118. data/spec/lib/mavenlink/time_entry_spec.rb +43 -0
  119. data/spec/lib/mavenlink/time_off_entry_spec.rb +9 -0
  120. data/spec/lib/mavenlink/user_spec.rb +138 -0
  121. data/spec/lib/mavenlink/workspace_group_spec.rb +25 -0
  122. data/spec/lib/mavenlink/workspace_spec.rb +431 -0
  123. data/spec/lib/mavenlink_spec.rb +43 -0
  124. data/spec/spec_helper.rb +31 -0
  125. data/spec/support/shared_examples.rb +148 -0
  126. metadata +267 -0
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mavenlink::Response, stub_requests: true do
4
+ let(:response_data) {
5
+ {
6
+ 'count' => 2,
7
+ 'results' => [{'key' => 'workspaces', 'id' => '7'}, {'key' => 'users', 'id' => '9'}],
8
+ 'workspaces' => {
9
+ '7' => {'title' => 'My new project'},
10
+ '9' => {'title' => 'My second project'},
11
+ },
12
+ 'users' => {
13
+ '1' => {'title' => 'My second project'},
14
+ '9' => {'title' => 'My new project'},
15
+ }
16
+ }
17
+ }
18
+
19
+ subject(:response) { described_class.new(response_data) }
20
+
21
+ describe '#results' do
22
+ specify do
23
+ expect(response.results).to have(2).records
24
+ end
25
+
26
+ it 'checks for client' do
27
+ expect(response).to respond_to (:client)
28
+ expect(response.client).to be_a Mavenlink::Client
29
+ end
30
+
31
+ it 'returns records in a proper order' do
32
+ expect(response.results[0]).to be_a Mavenlink::Workspace
33
+ expect(response.results[1]).to be_a Mavenlink::User
34
+ end
35
+
36
+ end
37
+
38
+ describe '#client' do
39
+ specify 'default client' do
40
+ expect(response.client).to be_a Mavenlink::Client
41
+ end
42
+
43
+ context 'custom client set' do
44
+ let(:client) { Mavenlink::Client.new(oauth_token: 'new one') }
45
+ subject(:response) { described_class.new(response_data, client) }
46
+
47
+ its(:client) { should eq(client) }
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,9 @@
1
+ require "spec_helper"
2
+
3
+ describe Mavenlink::Role, stub_requests: true do
4
+ it_should_behave_like 'model', 'roles'
5
+
6
+ describe 'validations' do
7
+ it { should validate_presence_of :name }
8
+ end
9
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mavenlink::Settings do
4
+ describe '.[]' do
5
+ before do
6
+ described_class[:new_for_test][:config_var] = 'config value'
7
+ end
8
+
9
+ it 'stores settings' do
10
+ expect(described_class[:new_for_test][:config_var]).to eq('config value')
11
+ end
12
+
13
+ it 'does not override other namespaces' do
14
+ expect(described_class[:another_for_test][:config_var]).to be_nil
15
+ end
16
+
17
+ describe 'default values' do
18
+ it 'does not force framework to perform any validations' do
19
+ expect(described_class[:checking_default_value][:perform_validations]).to eq(false)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,7 @@
1
+ require "spec_helper"
2
+
3
+ describe Mavenlink::SkillCategory do
4
+ describe "associations" do
5
+ it { should respond_to :skills }
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ require "spec_helper"
2
+
3
+ describe Mavenlink::SkillMembership do
4
+ describe "associations" do
5
+ it { should respond_to :skill }
6
+ it { should respond_to :user }
7
+ it { should respond_to :creator }
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ require "spec_helper"
2
+
3
+ describe Mavenlink::Skill do
4
+ describe "associations" do
5
+ it { should respond_to :skill_category }
6
+ it { should respond_to :roles }
7
+ end
8
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mavenlink::Specificators::Association do
4
+ subject { model.new }
5
+
6
+ before { described_class.apply(model) }
7
+
8
+ let(:model) do
9
+ Class.new Mavenlink::Model do
10
+ def self.specification
11
+ {'associations' => {'children' => {}, 'parents' => {}}}
12
+ end
13
+ end
14
+ end
15
+
16
+ it { should respond_to :children }
17
+ it { should respond_to :parents }
18
+
19
+ describe 'real model' do
20
+ subject { Mavenlink::Workspace.new }
21
+
22
+ it { should respond_to :primary_counterpart }
23
+ it { should respond_to :participants }
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mavenlink::Specificators::Attribute do
4
+ subject { model.new }
5
+
6
+ before { described_class.apply(model) }
7
+
8
+ let(:model) do
9
+ Class.new Mavenlink::Model do
10
+ def self.available_attributes
11
+ %w(one two)
12
+ end
13
+ end
14
+ end
15
+
16
+ it { should respond_to :one }
17
+ it { should respond_to :two }
18
+
19
+ describe 'real model' do
20
+ subject { Mavenlink::Workspace.new }
21
+
22
+ it { should respond_to :title }
23
+ it { should respond_to :description }
24
+ end
25
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mavenlink::Specificators::Validation do
4
+ subject { model.new }
5
+
6
+ before { described_class.apply(model) }
7
+
8
+ let(:model) do
9
+ Class.new Mavenlink::Model do
10
+ attr_accessor :name
11
+
12
+ def self.specification
13
+ {'validations' => {'name' => {'presence' => true}}}
14
+ end
15
+
16
+ def self.model_name
17
+ ActiveModel::Name.new(self, nil, 'temp')
18
+ end
19
+ end
20
+ end
21
+
22
+ it { should validate_presence_of :name }
23
+
24
+ describe 'real model' do
25
+ let(:client) { Object.new }
26
+
27
+ context 'new record' do
28
+ subject { Mavenlink::Workspace.new({}, nil, client) }
29
+
30
+ it { should validate_presence_of :title }
31
+ end
32
+
33
+ context 'persisted record' do
34
+ subject { Mavenlink::Workspace.new({ id: 12 }, nil, client) }
35
+
36
+ it { should validate_presence_of :title }
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mavenlink::StoryAllocationDay, stub_requests: true do
4
+ it_should_behave_like 'model', 'story_allocation_days'
5
+
6
+ describe 'validations' do
7
+ it { should validate_presence_of :assignment_id }
8
+ it { should validate_presence_of :date }
9
+ it { should validate_presence_of :minutes }
10
+ end
11
+
12
+ describe 'associations' do
13
+ it { should respond_to :assignment }
14
+ it { should respond_to :story }
15
+ it { should respond_to :workspace }
16
+ end
17
+
18
+ let(:response) {
19
+ {
20
+ 'count' => 1,
21
+ 'results' => [{'key' => 'story_allocation_days', 'id' => '7'}],
22
+ 'story_allocation_days' => {
23
+ '7' => {'current' => true, 'id' => '7'}
24
+ }
25
+ }
26
+ }
27
+
28
+ before do
29
+ stub_request :get, "/api/v1/story_allocation_days?only=7", response
30
+ stub_request :get, "/api/v1/story_allocation_days?only=8", {'count' => 0, 'results' => []}
31
+ stub_request :post, "/api/v1/story_allocation_days", response
32
+ stub_request :delete, "/api/v1/story_allocation_days/4", {}
33
+ end
34
+
35
+ describe '#save' do
36
+ context 'new record' do
37
+ subject { described_class.new }
38
+
39
+ context 'invalid record' do
40
+ specify do
41
+ expect(subject.save).to be_false
42
+ end
43
+ end
44
+
45
+ context 'valid record' do
46
+ subject { described_class.new(assignment_id: '1', date: 'today', minutes: '0', current: false) }
47
+
48
+ specify do
49
+ expect(subject.save).to be_true
50
+ end
51
+
52
+ it 'reloads record fields taking it from response' do
53
+ expect { subject.save }.to change { subject.current }.from(false).to(true)
54
+ end
55
+ end
56
+ end
57
+ end
58
+
59
+ describe '#destroy' do
60
+ specify do
61
+ expect(described_class.new(id: '4').destroy).to be_blank
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mavenlink::StoryDependency, stub_requests: true do
4
+ it_should_behave_like 'model', 'story_dependencies'
5
+
6
+ describe 'associations' do
7
+ it { should respond_to :source }
8
+ it { should respond_to :target }
9
+ end
10
+
11
+ describe 'validations' do
12
+ it { should validate_presence_of :source_id }
13
+ it { should validate_presence_of :target_id }
14
+ it { should validate_presence_of(:workspace_id).on(:create) }
15
+ end
16
+ end
@@ -0,0 +1,69 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mavenlink::Story, stub_requests: true do
4
+ it_should_behave_like 'model', 'stories'
5
+
6
+ describe 'validations' do
7
+ it { should validate_presence_of :title }
8
+ it { should validate_presence_of :story_type }
9
+ it { should validate_presence_of :workspace_id }
10
+ it { should ensure_inclusion_of(:story_type).in_array(%w(task deliverable milestone)) }
11
+ end
12
+
13
+ describe 'associations' do
14
+ it { should respond_to :workspace }
15
+ it { should respond_to :parent }
16
+ it { should respond_to :assignees }
17
+ it { should respond_to :sub_stories }
18
+ it { should respond_to :descendants }
19
+ it { should respond_to :custom_field_values }
20
+ it { should respond_to :external_references }
21
+ end
22
+
23
+ let(:response) {
24
+ {
25
+ 'count' => 1,
26
+ 'results' => [{'key' => 'stories', 'id' => '7'}],
27
+ 'stories' => {
28
+ '7' => {'title' => 'My new record', 'id' => '7'}
29
+ }
30
+ }
31
+ }
32
+
33
+ before do
34
+ stub_request :get, "/api/v1/stories?only=7", response
35
+ stub_request :get, "/api/v1/stories?only=8", {'count' => 0, 'results' => []}
36
+ stub_request :post, "/api/v1/stories", response
37
+ stub_request :delete, "/api/v1/stories/4", {}
38
+ end
39
+
40
+ describe '#save' do
41
+ context 'new record' do
42
+ subject { described_class.new }
43
+
44
+ context 'invalid record' do
45
+ specify do
46
+ expect(subject.save).to be_false
47
+ end
48
+ end
49
+
50
+ context 'valid record' do
51
+ subject { described_class.new(title: 'the record', story_type: 'task', workspace_id: '1') }
52
+
53
+ specify do
54
+ expect(subject.save).to be_true
55
+ end
56
+
57
+ it 'reloads record fields taking it from response' do
58
+ expect { subject.save }.to change { subject.title }.from('the record').to('My new record')
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ describe '#destroy' do
65
+ specify do
66
+ expect(described_class.new(id: '4').destroy).to be_blank
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,13 @@
1
+ require "spec_helper"
2
+
3
+ describe Mavenlink::TimeAdjustment, stub_requests: true do
4
+ it_should_behave_like "model", "time_adjustments"
5
+
6
+ describe "associations" do
7
+ it { should respond_to :story }
8
+ it { should respond_to :workspace }
9
+ it { should respond_to :user }
10
+ it { should respond_to :creator }
11
+ it { should respond_to :active_invoice }
12
+ end
13
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mavenlink::TimeEntry, stub_requests: true do
4
+ it_should_behave_like 'model', 'time_entries'
5
+
6
+ describe 'validations' do
7
+ it { should validate_presence_of :workspace_id }
8
+ it { should validate_presence_of :date_performed }
9
+ it { should validate_presence_of :time_in_minutes }
10
+ end
11
+
12
+ describe 'associations' do
13
+ it { should respond_to :workspace }
14
+ it { should respond_to :user }
15
+ it { should respond_to :story }
16
+ end
17
+
18
+ it 'should respond to expected attributes' do
19
+ should respond_to(:created_at, :updated_at, :date_performed, :story_id,
20
+ :time_in_minutes, :billable, :notes, :rate_in_cents,
21
+ :currency, :currency_symbol, :currency_base_unit,
22
+ :user_can_edit, :workspace_id, :user_id, :approved,
23
+ :role_id, :external_reference, :location)
24
+ end
25
+
26
+ describe '.create_attributes' do
27
+ let(:subject) { described_class.create_attributes }
28
+
29
+ it 'includes expected attributes' do
30
+ should match_array(%w(workspace_id date_performed time_in_minutes billable cost_rate_in_cents
31
+ notes rate_in_cents story_id user_id external_reference location))
32
+ end
33
+ end
34
+
35
+ describe '.update_attributes' do
36
+ let(:subject) { described_class.update_attributes }
37
+
38
+ it 'includes expected attributes' do
39
+ should match_array(%w(date_performed time_in_minutes billable notes cost_rate_in_cents
40
+ rate_in_cents story_id user_id external_reference))
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,9 @@
1
+ require "spec_helper"
2
+
3
+ describe Mavenlink::TimeOffEntry, stub_requests: true do
4
+ it_should_behave_like "model", "time_off_entries"
5
+
6
+ describe "association" do
7
+ it { should respond_to :user }
8
+ end
9
+ end
@@ -0,0 +1,138 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mavenlink::User, stub_requests: true do
4
+ subject { described_class.send(:new) }
5
+
6
+ let(:collection_name) { 'users' }
7
+
8
+ let(:model) { described_class }
9
+
10
+ let(:response) {
11
+ {
12
+ 'count' => 1,
13
+ 'results' => [{'key' => collection_name, 'id' => '7'}],
14
+ collection_name => {
15
+ '7' => {'title' => 'My new record', 'id' => '7'}
16
+ }
17
+ }
18
+ }
19
+
20
+ before do
21
+ stub_request :get, "/api/v1/#{collection_name}?only=7", response
22
+ stub_request :get, "/api/v1/#{collection_name}?only=8", {'count' => 0, 'results' => []}
23
+ stub_request :post, "/api/v1/#{collection_name}", response
24
+ stub_request :delete, "/api/v1/#{collection_name}/4", {}
25
+ end
26
+
27
+ describe "associations" do
28
+ it { should respond_to :external_references }
29
+ end
30
+
31
+ describe 'class methods' do
32
+ subject { model }
33
+ its(:collection_name) { should == collection_name }
34
+
35
+ describe '.scoped' do
36
+ subject { model.scoped }
37
+
38
+ it { should be_a Mavenlink::Request }
39
+ its(:collection_name) { should == collection_name }
40
+ end
41
+
42
+ describe '.find' do
43
+ specify do
44
+ expect(model.find(7)).to be_a model
45
+ end
46
+
47
+ specify do
48
+ expect(model.find(7).id).to eq('7')
49
+ end
50
+
51
+ specify do
52
+ expect(model.find(8)).to be_nil
53
+ end
54
+ end
55
+
56
+ describe '.models' do
57
+ specify do
58
+ expect(model.models).to be_empty
59
+ end
60
+
61
+ specify do
62
+ expect(Mavenlink::Model.models).to include({collection_name => model})
63
+ end
64
+ end
65
+
66
+ describe '.specification' do
67
+ specify do
68
+ expect(model.specification).to be_a Hash
69
+ end
70
+
71
+ specify do
72
+ expect(model.specification).not_to be_empty
73
+ end
74
+ end
75
+
76
+ describe '.attributes' do
77
+ specify do
78
+ expect(model.attributes).to be_an Array
79
+ end
80
+
81
+ specify do
82
+ expect(model.attributes).not_to be_empty
83
+ end
84
+ end
85
+
86
+ describe '.available_attributes' do
87
+ specify do
88
+ expect(model.available_attributes).to be_an Array
89
+ end
90
+
91
+ specify do
92
+ expect(model.available_attributes).not_to be_empty
93
+ end
94
+ end
95
+
96
+ describe '.wrap' do
97
+ context 'existing record' do
98
+ let(:brainstem_record) do
99
+ BrainstemAdaptor::Record.new(collection_name, '7', Mavenlink::Response.new(response))
100
+ end
101
+
102
+ specify do
103
+ expect(model.wrap(brainstem_record)).not_to be_a_new_record
104
+ end
105
+
106
+ specify do
107
+ expect(model.wrap(brainstem_record)).to be_a model
108
+ end
109
+ end
110
+ end
111
+ end
112
+
113
+ describe '#initialize' do
114
+ it 'accepts attributes' do
115
+ expect(model.send(:new, any_custom_key: 'value set')).to include(any_custom_key: 'value set')
116
+ end
117
+ end
118
+
119
+ describe '#persisted?' do
120
+ specify do
121
+ expect(model.send(:new)).not_to be_persisted
122
+ end
123
+
124
+ specify do
125
+ expect(model.send(:new, id: 1)).to be_persisted
126
+ end
127
+ end
128
+
129
+ describe '#new_record?' do
130
+ specify do
131
+ expect(model.send(:new)).to be_new_record
132
+ end
133
+
134
+ specify do
135
+ expect(model.send(:new, id: 1)).not_to be_new_record
136
+ end
137
+ end
138
+ end