caperoma 0.1.0 → 4.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 (85) hide show
  1. checksums.yaml +5 -5
  2. data/.ruby-version +1 -0
  3. data/Capefile +48 -0
  4. data/Capefile.template +48 -0
  5. data/Capefile.test +20 -0
  6. data/Gemfile +25 -10
  7. data/Gemfile.lock +196 -77
  8. data/HELP +321 -0
  9. data/README.md +528 -0
  10. data/Rakefile +73 -18
  11. data/VERSION +1 -1
  12. data/bin/caperoma +47 -11
  13. data/caperoma.gemspec +144 -45
  14. data/config/crontab +10 -0
  15. data/config/schedule.rb +21 -0
  16. data/lib/caperoma.rb +409 -9
  17. data/lib/caperoma/models/account.rb +47 -0
  18. data/lib/caperoma/models/application_record.rb +5 -0
  19. data/lib/caperoma/models/branch.rb +6 -0
  20. data/lib/caperoma/models/project.rb +14 -0
  21. data/lib/caperoma/models/property.rb +5 -0
  22. data/lib/caperoma/models/report.rb +177 -0
  23. data/lib/caperoma/models/report_recipient.rb +6 -0
  24. data/lib/caperoma/models/reports/daily_report.rb +23 -0
  25. data/lib/caperoma/models/reports/retrospective_report.rb +19 -0
  26. data/lib/caperoma/models/reports/three_day_report.rb +19 -0
  27. data/lib/caperoma/models/task.rb +368 -0
  28. data/lib/caperoma/models/tasks/bug.rb +36 -0
  29. data/lib/caperoma/models/tasks/chore.rb +40 -0
  30. data/lib/caperoma/models/tasks/feature.rb +27 -0
  31. data/lib/caperoma/models/tasks/fix.rb +56 -0
  32. data/lib/caperoma/models/tasks/meeting.rb +40 -0
  33. data/lib/caperoma/models/tasks/modules/git.rb +65 -0
  34. data/lib/caperoma/models/tasks/task_with_commit.rb +40 -0
  35. data/lib/caperoma/models/tasks/task_with_separate_branch.rb +42 -0
  36. data/lib/caperoma/services/airbrake_email_processor.rb +47 -0
  37. data/lib/caperoma/services/pivotal_fetcher.rb +108 -0
  38. data/lib/caperoma/version.rb +9 -0
  39. data/spec/caperoma_spec.rb +3 -21
  40. data/spec/factories/accounts.rb +10 -0
  41. data/spec/factories/branches.rb +9 -0
  42. data/spec/factories/projects.rb +8 -0
  43. data/spec/factories/report_recipients.rb +7 -0
  44. data/spec/factories/reports.rb +16 -0
  45. data/spec/factories/tasks.rb +37 -0
  46. data/spec/features/bug_spec.rb +60 -0
  47. data/spec/features/chore_spec.rb +60 -0
  48. data/spec/features/command_unknown_spec.rb +14 -0
  49. data/spec/features/config_spec.rb +161 -0
  50. data/spec/features/feature_spec.rb +60 -0
  51. data/spec/features/finish_spec.rb +18 -0
  52. data/spec/features/fix_spec.rb +60 -0
  53. data/spec/features/meeting_spec.rb +22 -0
  54. data/spec/features/projects_spec.rb +17 -0
  55. data/spec/features/report_recipientss_spec.rb +117 -0
  56. data/spec/features/reports_spec.rb +65 -0
  57. data/spec/features/status_spec.rb +33 -0
  58. data/spec/features/version_spec.rb +11 -0
  59. data/spec/models/account_spec.rb +51 -0
  60. data/spec/models/branch_spec.rb +8 -0
  61. data/spec/models/bug_spec.rb +33 -0
  62. data/spec/models/chore_spec.rb +33 -0
  63. data/spec/models/daily_report_spec.rb +38 -0
  64. data/spec/models/feature_spec.rb +33 -0
  65. data/spec/models/fix_spec.rb +55 -0
  66. data/spec/models/meeting_spec.rb +33 -0
  67. data/spec/models/project_spec.rb +11 -0
  68. data/spec/models/report_recipient_spec.rb +22 -0
  69. data/spec/models/report_spec.rb +16 -0
  70. data/spec/models/retrospective_report_spec.rb +38 -0
  71. data/spec/models/task_spec.rb +613 -0
  72. data/spec/models/task_with_commit_spec.rb +105 -0
  73. data/spec/models/task_with_separate_branch_spec.rb +97 -0
  74. data/spec/models/three_day_report_spec.rb +49 -0
  75. data/spec/spec_helper.rb +26 -16
  76. data/spec/support/capefile_generator.rb +36 -0
  77. data/spec/support/database_cleaner.rb +21 -0
  78. data/spec/support/stubs.rb +178 -9
  79. metadata +283 -42
  80. data/.document +0 -5
  81. data/README.rdoc +0 -26
  82. data/lib/caperoma/credentials.rb +0 -13
  83. data/lib/caperoma/jira_client.rb +0 -57
  84. data/spec/caperoma/credentials_spec.rb +0 -25
  85. data/spec/caperoma/jira_spec.rb +0 -35
@@ -0,0 +1,105 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+
5
+ RSpec.describe TaskWithCommit, type: :model do
6
+ describe 'inheritence' do
7
+ it { expect(subject).to be_a_kind_of Task }
8
+ end
9
+
10
+ describe 'relations' do
11
+ it { expect(subject).to belong_to :branch }
12
+ end
13
+
14
+ describe 'methods' do
15
+ describe '#finish' do
16
+ let!(:task) { create :task_with_commit }
17
+
18
+ it 'should commit with generated message' do
19
+ expect_any_instance_of(TaskWithCommit).to receive(:commit_message).and_return 'commit msg'
20
+ expect_any_instance_of(TaskWithCommit).to receive(:commit_rubocop_message).and_return 'rubocop commit msg'
21
+
22
+ expect(task).to receive(:git_commit).with('commit msg')
23
+ expect(task).to receive(:git_commit).with('rubocop commit msg')
24
+ expect(task).to receive(:git_push)
25
+
26
+ task.finish(nil)
27
+ end
28
+ end
29
+
30
+ describe '#pause' do
31
+ let!(:task) { create :task_with_commit }
32
+
33
+ it 'should commit with generated message' do
34
+ expect_any_instance_of(TaskWithCommit).to receive(:commit_message).and_return 'commit msg'
35
+ expect_any_instance_of(TaskWithCommit).to receive(:commit_rubocop_message).and_return 'rubocop commit msg'
36
+
37
+ expect(task).to receive(:git_commit).with('commit msg')
38
+ expect(task).to receive(:git_commit).with('rubocop commit msg')
39
+ expect(task).to receive(:git_push)
40
+
41
+ task.pause(nil)
42
+ end
43
+ end
44
+
45
+ describe '#abort' do
46
+ let!(:task) { create :task_with_commit }
47
+
48
+ it 'should not commit' do
49
+ expect_any_instance_of(TaskWithCommit).not_to receive(:commit_message)
50
+ expect_any_instance_of(TaskWithCommit).not_to receive(:commit_rubocop_message)
51
+
52
+ expect(task).not_to receive(:git_commit).with('commit msg')
53
+ expect(task).not_to receive(:git_push)
54
+
55
+ task.abort(nil)
56
+ end
57
+ end
58
+ end
59
+
60
+ describe 'private methods' do
61
+ let!(:task) { create :task_with_commit, title: 'Hello World', jira_key: jira_key, pivotal_id: pivotal_id }
62
+
63
+ describe '#commit_message' do
64
+ context 'neither jira nor pt id' do
65
+ let(:jira_key) { nil }
66
+ let(:pivotal_id) { nil }
67
+
68
+ it 'should generate only title, no jira or pt ids' do
69
+ result = task.send(:commit_message)
70
+ expect(result).to eq 'Hello World'
71
+ end
72
+ end
73
+
74
+ context 'jira id but no pt id' do
75
+ let(:jira_key) { 'RUC-123' }
76
+ let(:pivotal_id) { nil }
77
+
78
+ it 'should generate commit msg with jira key only' do
79
+ result = task.send(:commit_message)
80
+ expect(result).to eq '[RUC-123] Hello World'
81
+ end
82
+ end
83
+
84
+ context 'no jira id, but pt id' do
85
+ let(:jira_key) { nil }
86
+ let(:pivotal_id) { 12_345_678 }
87
+
88
+ it 'should generate commit msg with pt id only' do
89
+ result = task.send(:commit_message)
90
+ expect(result).to eq '[#12345678] Hello World'
91
+ end
92
+ end
93
+
94
+ context 'both jira id and pt id' do
95
+ let(:jira_key) { 'RUC-123' }
96
+ let(:pivotal_id) { 12_345_678 }
97
+
98
+ it 'should append both jira and pivotal ids' do
99
+ result = task.send(:commit_message)
100
+ expect(result).to eq '[RUC-123][#12345678] Hello World'
101
+ end
102
+ end
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,97 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+
5
+ RSpec.describe TaskWithSeparateBranch, type: :model do
6
+ describe 'methods' do
7
+ describe '#finish' do
8
+ let(:task) { create :task_with_separate_branch, title: 'title' }
9
+
10
+ it 'should commit with generated message' do
11
+ allow_any_instance_of(TaskWithSeparateBranch).to receive(:description_for_pull_request).and_return 'pivotal-url'
12
+ allow_any_instance_of(TaskWithSeparateBranch).to receive(:git_current_branch).and_return 'parent-branch'
13
+
14
+ expect(task).to receive(:git_pull_request).with('parent-branch', 'title', 'pivotal-url')
15
+ expect(task).to receive(:git_checkout).with('parent-branch')
16
+
17
+ task.finish(nil)
18
+ end
19
+ end
20
+
21
+ describe '#pause' do
22
+ let(:task) { create :task_with_separate_branch, title: 'title' }
23
+
24
+ it 'should commit with generated message' do
25
+ allow_any_instance_of(TaskWithSeparateBranch).to receive(:description_for_pull_request).and_return 'pivotal-url'
26
+ expect(task).not_to receive(:git_pull_request).with('parent-branch', 'title', 'pivotal-url')
27
+ expect(task).not_to receive(:git_checkout).with('parent-branch')
28
+
29
+ task.pause(nil)
30
+ end
31
+ end
32
+
33
+ describe '#abort' do
34
+ let(:task) { create :task_with_separate_branch, title: 'title' }
35
+
36
+ it 'should commit with generated message' do
37
+ allow_any_instance_of(TaskWithSeparateBranch).to receive(:description_for_pull_request).and_return 'pivotal-url'
38
+ allow_any_instance_of(TaskWithSeparateBranch).to receive(:git_current_branch).and_return 'parent-branch'
39
+
40
+ expect(task).not_to receive(:git_pull_request).with('parent-branch', 'title', 'pivotal-url')
41
+ expect(task).to receive(:git_checkout).with('parent-branch')
42
+
43
+ task.abort(nil)
44
+ end
45
+ end
46
+ end
47
+
48
+ describe 'observers' do
49
+ describe '::update_parent_branch' do
50
+ let(:task) { build :task_with_separate_branch }
51
+
52
+ it 'should get latest version of remote branch before switching' do
53
+ expect(task).to receive(:git_rebase_to_upstream)
54
+ task.save!
55
+ end
56
+ end
57
+
58
+ describe '::remember_parent_branch' do
59
+ let(:task) { build :task_with_separate_branch }
60
+
61
+ it 'should save branch to send pull request to' do
62
+ expect_any_instance_of(TaskWithSeparateBranch).to receive(:git_current_branch).and_return 'parent-branch'
63
+ task.save!
64
+ expect(task.reload.parent_branch).to eq 'parent-branch'
65
+ end
66
+ end
67
+
68
+ describe '::new_git_branch' do
69
+ it 'should make a new branch' do
70
+ expect_any_instance_of(TaskWithSeparateBranch).to receive(:branch_name).and_return 'branch-name'
71
+ expect_any_instance_of(TaskWithSeparateBranch).to receive(:git_branch).with('branch-name')
72
+
73
+ create :task_with_separate_branch
74
+ end
75
+ end
76
+ end
77
+
78
+ describe 'private methods' do
79
+ let!(:task) { create :task_with_separate_branch }
80
+
81
+ before { expect(task).to receive(:jira_key).and_return 'RUC-123' }
82
+
83
+ describe '#branch_name' do
84
+ it 'should generate branch name' do
85
+ expect(task).to receive(:title).and_return 'Hello World'
86
+ result = task.send(:branch_name)
87
+ expect(result).to eq 'ruc-123-hello-world'
88
+ end
89
+
90
+ it 'should cut the long titles' do
91
+ expect(task).to receive(:title).and_return 'Hello World And Welcome To My Really Awesome Project'
92
+ result = task.send(:branch_name)
93
+ expect(result).to eq 'ruc-123-hello-world-and-welcome-t'
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+
5
+ RSpec.describe ThreeDayReport, type: :model do
6
+ describe 'relations' do
7
+ it { expect(subject).to have_many :tasks }
8
+ end
9
+
10
+ describe 'callbacks' do
11
+ describe '::asskgn_unreported_tasks' do
12
+ let!(:daily_report1) { create :daily_report }
13
+ let!(:three_day_report1) { create :three_day_report }
14
+
15
+ let!(:task1) { create :task, daily_report: daily_report1, three_day_report: nil, finished_at: Time.now }
16
+ let!(:task2) { create :task, daily_report: daily_report1, three_day_report: three_day_report1, finished_at: Time.now }
17
+ let!(:task3) { create :task, daily_report: nil, three_day_report: nil, finished_at: Time.now }
18
+ let!(:task4) { create :task, daily_report: nil, three_day_report: nil, finished_at: nil }
19
+
20
+ specify do
21
+ new_report = create :three_day_report
22
+ expect(new_report.tasks).to match_array [task1, task3]
23
+ end
24
+ end
25
+ end
26
+
27
+ describe 'message format' do
28
+ describe 'subject' do
29
+ let(:report) { create :three_day_report }
30
+
31
+ specify do
32
+ Timecop.freeze(Time.parse('06/02/2015 15:06')) do
33
+ expect(report.send(:report_subject)).to eq 'Three Day Report (Feb 4 - Feb 6)'
34
+ end
35
+ end
36
+ end
37
+
38
+ describe 'message body', :unstub_puts do
39
+ let(:report) { create :three_day_report }
40
+ let!(:task1) { create :task, jira_key: 'DOV-2', pivotal_id: 2345678, three_day_report: nil, finished_at: 2.days.ago }
41
+ let!(:task2) { create :task, jira_key: 'MOB-8', pivotal_id: 2345674, three_day_report: nil, finished_at: 1.day.ago }
42
+
43
+ specify do
44
+ expect(report.send(:report_body)).to match /table/
45
+ end
46
+
47
+ end
48
+ end
49
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,30 +1,40 @@
1
- require 'simplecov'
1
+ # frozen_string_literal: true
2
2
 
3
- module SimpleCov::Configuration
4
- def clean_filters
5
- @filters = []
6
- end
7
- end
8
-
9
- SimpleCov.configure do
10
- clean_filters
11
- load_adapter 'test_frameworks'
12
- end
3
+ ENV['CAPEROMA_TEST'] = 'true'
13
4
 
14
- ENV["COVERAGE"] && SimpleCov.start do
15
- add_filter "/.rvm/"
16
- end
17
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib', 'models'))
18
7
  $LOAD_PATH.unshift(File.dirname(__FILE__))
19
8
 
20
- require 'rspec'
21
9
  require 'caperoma'
10
+ require 'rspec'
11
+ require 'shoulda/matchers'
12
+ require 'factory_girl'
13
+ require 'database_cleaner'
14
+ require 'timecop'
22
15
 
23
16
  # Requires supporting files with custom matchers and macros, etc,
24
17
  # in ./support/ and its subdirectories.
25
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
18
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
19
+ Dir["#{File.dirname(__FILE__)}/factories/*.rb"].each { |f| require f }
26
20
 
27
21
  RSpec.configure do |config|
22
+ config.include FactoryGirl::Syntax::Methods
23
+
28
24
  config.color = true
29
25
  config.tty = true
26
+ config.filter_run focus: true
27
+ config.filter_run_excluding :pending
28
+ config.run_all_when_everything_filtered = true
29
+
30
+ config.include(Shoulda::Matchers::ActiveModel, type: :model)
31
+ end
32
+
33
+ Shoulda::Matchers.configure do |config|
34
+ config.integrate do |with|
35
+ with.test_framework :rspec
36
+ with.library :active_record
37
+ end
30
38
  end
39
+
40
+ I18n.enforce_available_locales = false
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+ require 'yaml'
3
+
4
+ CAPEFILE_SAMPLE_DATA = {
5
+ 'github_repo' => 'owner/repo',
6
+ 'jira_url' => 'https://owner.atlassian.net/',
7
+ 'jira_project_id' => 10001,
8
+ 'jira_issue_type_ids' => {
9
+ 'feature' => 10101,
10
+ 'bug' => 10103,
11
+ 'chore' => 10100,
12
+ 'fix' => 10101,
13
+ 'meeting' => 10100,
14
+ },
15
+ 'jira_transition_ids' => {
16
+ 'todo' => 11,
17
+ 'in_progress' => 21,
18
+ 'done' => 31,
19
+ },
20
+ 'pivotal_tracker_project_id' => 2374972,
21
+ 'create_features_in_pivotal' => true,
22
+ 'create_bugs_in_pivotal' => true,
23
+ 'create_chores_in_pivotal' => true,
24
+ 'create_fixes_in_pivotal_as_chores' => false,
25
+ 'create_meetings_in_pivotal_as_chores' => false
26
+ }
27
+
28
+ def create_capefile(jira_project_id)
29
+ CAPEFILE_SAMPLE_DATA['jira_project_id'] = jira_project_id
30
+ yaml = CAPEFILE_SAMPLE_DATA.to_yaml
31
+ File.write 'Capefile.test', yaml
32
+ end
33
+
34
+ def remove_capefile
35
+ File.delete 'Capefile.test'
36
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.configure do |config|
4
+ config.before(:suite) do
5
+ DatabaseCleaner.clean_with :truncation
6
+ end
7
+
8
+ config.before(:each) do
9
+ DatabaseCleaner.strategy = if ENV['spec_type'] == 'feature'
10
+ :truncation
11
+ else
12
+ :transaction
13
+ end
14
+
15
+ DatabaseCleaner.start
16
+ end
17
+
18
+ config.after(:each) do
19
+ DatabaseCleaner.clean
20
+ end
21
+ end
@@ -1,9 +1,178 @@
1
- RSpec.configure do |config|
2
- config.before do |example|
3
- if example.metadata[:expect_db_write].nil?
4
- allow(SDBM).to receive(:open).with('jira_credentials').and_return SDBM.open 'test'
5
- else
6
- expect(SDBM).to receive(:open).with('jira_credentials').and_return SDBM.open 'test'
7
- end
8
- end
9
- end
1
+ # frozen_string_literal: true
2
+
3
+ PROJECTS_LIST = [
4
+ {
5
+ 'self' => 'http://www.example.com/jira/rest/api/2/project/EX',
6
+ 'id' => '123',
7
+ 'key' => 'EX',
8
+ 'name' => 'Dummy',
9
+ 'avatarUrls' => {
10
+ '24x24' => 'http://www.example.com/jira/secure/projectavatar?size=small&pid=10000',
11
+ '16x16' => 'http://www.example.com/jira/secure/projectavatar?size=xsmall&pid=10000',
12
+ '32x32' => 'http://www.example.com/jira/secure/projectavatar?size=medium&pid=10000',
13
+ '48x48' => 'http://www.example.com/jira/secure/projectavatar?size=large&pid=10000'
14
+ },
15
+ 'projectCategory' => {
16
+ 'self' => 'http://www.example.com/jira/rest/api/2/projectCategory/10000',
17
+ 'id' => '10000',
18
+ 'name' => 'FIRST',
19
+ 'description' => 'First Project Category'
20
+ }
21
+ }
22
+ ].freeze
23
+
24
+ JIRA_ISSUE_CREATION = {
25
+ 'update' => {
26
+ 'worklog' => [{
27
+ 'add' => {
28
+ 'started' => '2011-07-05T11:05:00.000+0000',
29
+ 'timeSpent' => '60m'
30
+ }
31
+ }]
32
+ },
33
+ 'fields' => {
34
+ 'project' => { 'id' => '10000' },
35
+ 'summary' => 'awesome issue',
36
+ 'issuetype' => { 'id' => '10000' },
37
+ 'assignee' => { 'name' => 'homer' },
38
+ 'description' => 'description',
39
+ 'components' => [{ 'id' => '10000' }]
40
+ }
41
+ }.freeze
42
+
43
+ JIRA_ISSUE_CREATION_RESPONSE = Jbuilder.encode do |j|
44
+ j.id '10000'
45
+ j.key 'TST-24'
46
+ j.self 'http://www.example.com/jira/rest/api/2/issue/10000'
47
+ end
48
+
49
+ PIVOTAL_ISSUE_CREATION_RESPONSE = Jbuilder.encode do |j|
50
+ j.kind 'story'
51
+ j.id '12345678'
52
+ j.created_at '2019-07-03T18:38:59Z'
53
+ j.updated_at '2019-07-04T12:31:04Z'
54
+ j.estimate 2
55
+ j.story_type 'feature'
56
+ j.name 'Feature name'
57
+ j.description 'Feature description'
58
+ j.current_state 'unstarted'
59
+ j.requested_by_id '23456789'
60
+ j.url 'https://www.pivotaltracker.com/story/show/12345678'
61
+ j.project_id 34_567_890
62
+ j.owner_ids ['23456789']
63
+ j.labels []
64
+ j.owned_by_id '234567890'
65
+ end
66
+
67
+ RSpec.configure do |config|
68
+ config.before do |example|
69
+ # if example.metadata[:unstab_capefile].blank?
70
+ # Caperoma::Capefile::JIRA_URL = '123'
71
+ # end
72
+
73
+ # if example.metadata[:unstub_git].blank?
74
+ # allow_any_instance_of(Feature).to receive(:git_branch)
75
+ # allow_any_instance_of(Feature).to receive(:git_commit)
76
+ # allow_any_instance_of(Feature).to receive(:git_push)
77
+ # allow_any_instance_of(Feature).to receive(:git_last_commit_name).and_return 'some commit'
78
+ # allow_any_instance_of(Feature).to receive(:git_current_branch).and_return 'parent-branch'
79
+ # allow_any_instance_of(Feature).to receive(:git_pull_request)
80
+ # allow_any_instance_of(Feature).to receive(:git_checkout)
81
+
82
+ # allow_any_instance_of(Bug).to receive(:git_branch)
83
+ # allow_any_instance_of(Bug).to receive(:git_commit)
84
+ # allow_any_instance_of(Bug).to receive(:git_push)
85
+ # allow_any_instance_of(Bug).to receive(:git_last_commit_name).and_return 'some commit'
86
+ # allow_any_instance_of(Bug).to receive(:git_current_branch).and_return 'parent-branch'
87
+ # allow_any_instance_of(Bug).to receive(:git_pull_request)
88
+ # allow_any_instance_of(Bug).to receive(:git_checkout)
89
+
90
+ # allow_any_instance_of(Chore).to receive(:git_branch)
91
+ # allow_any_instance_of(Chore).to receive(:git_commit)
92
+ # allow_any_instance_of(Chore).to receive(:git_push)
93
+ # allow_any_instance_of(Chore).to receive(:git_last_commit_name).and_return 'some commit'
94
+ # allow_any_instance_of(Chore).to receive(:git_current_branch).and_return 'parent-branch'
95
+ # allow_any_instance_of(Chore).to receive(:git_pull_request)
96
+ # allow_any_instance_of(Chore).to receive(:git_checkout)
97
+
98
+ # allow_any_instance_of(Fix).to receive(:git_branch)
99
+ # allow_any_instance_of(Fix).to receive(:git_commit)
100
+ # allow_any_instance_of(Fix).to receive(:git_push)
101
+ # allow_any_instance_of(Fix).to receive(:git_last_commit_name).and_return 'some commit'
102
+ # allow_any_instance_of(Fix).to receive(:git_current_branch).and_return 'parent-branch'
103
+ # allow_any_instance_of(Fix).to receive(:git_pull_request)
104
+ # allow_any_instance_of(Fix).to receive(:git_checkout)
105
+
106
+ # allow_any_instance_of(Meeting).to receive(:git_branch)
107
+ # allow_any_instance_of(Meeting).to receive(:git_commit)
108
+ # allow_any_instance_of(Meeting).to receive(:git_push)
109
+ # allow_any_instance_of(Meeting).to receive(:git_last_commit_name).and_return 'some commit'
110
+ # allow_any_instance_of(Meeting).to receive(:git_current_branch).and_return 'parent-branch'
111
+ # allow_any_instance_of(Meeting).to receive(:git_pull_request)
112
+ # allow_any_instance_of(Meeting).to receive(:git_checkout)
113
+
114
+ # allow_any_instance_of(Task).to receive(:git_branch)
115
+ # allow_any_instance_of(Task).to receive(:git_commit)
116
+ # allow_any_instance_of(Task).to receive(:git_push)
117
+ # allow_any_instance_of(Task).to receive(:git_last_commit_name).and_return 'some commit'
118
+ # allow_any_instance_of(Task).to receive(:git_current_branch).and_return 'parent-branch'
119
+ # allow_any_instance_of(Task).to receive(:git_pull_request)
120
+ # allow_any_instance_of(Task).to receive(:git_checkout)
121
+
122
+ # allow_any_instance_of(TaskWithSeparateBranch).to receive(:git_branch)
123
+ # allow_any_instance_of(TaskWithSeparateBranch).to receive(:git_commit)
124
+ # allow_any_instance_of(TaskWithSeparateBranch).to receive(:git_push)
125
+ # allow_any_instance_of(TaskWithSeparateBranch).to receive(:git_last_commit_name).and_return 'some commit'
126
+ # allow_any_instance_of(TaskWithSeparateBranch).to receive(:git_current_branch).and_return 'parent-branch'
127
+ # allow_any_instance_of(TaskWithSeparateBranch).to receive(:git_pull_request)
128
+ # allow_any_instance_of(TaskWithSeparateBranch).to receive(:git_checkout)
129
+
130
+ # allow_any_instance_of(TaskWithCommit).to receive(:git_branch)
131
+ # allow_any_instance_of(TaskWithCommit).to receive(:git_commit)
132
+ # allow_any_instance_of(TaskWithCommit).to receive(:git_push)
133
+ # allow_any_instance_of(TaskWithCommit).to receive(:git_last_commit_name).and_return 'some commit'
134
+ # allow_any_instance_of(TaskWithCommit).to receive(:git_current_branch).and_return 'parent-branch'
135
+ # allow_any_instance_of(TaskWithCommit).to receive(:git_pull_request)
136
+ # allow_any_instance_of(TaskWithCommit).to receive(:git_checkout)
137
+ # end
138
+
139
+ if example.metadata[:unstub_reports].blank?
140
+ allow_any_instance_of(Report).to receive(:send_email)
141
+ end
142
+
143
+ if example.metadata[:unstab_api_calls].blank?
144
+ faraday = spy('faraday')
145
+ allow(Faraday).to receive(:new).and_return faraday
146
+ allow(Faraday).to receive(:default_adapter)
147
+ allow(faraday).to receive(:get)
148
+ allow(faraday).to receive(:post)
149
+ allow(faraday).to receive(:put)
150
+ end
151
+
152
+ allow(STDOUT).to receive(:puts) if example.metadata[:unstub_puts].blank?
153
+
154
+ if example.metadata[:unstub_time_now].blank?
155
+ allow(Time).to receive(:now).and_return Time.parse('5 April 2014')
156
+ end
157
+
158
+ if example.metadata[:unstub_jira_creation].blank?
159
+ allow_any_instance_of(Task).to receive :create_issue_on_jira
160
+ end
161
+
162
+ if example.metadata[:unstub_jira_starting].blank?
163
+ allow_any_instance_of(Task).to receive :start_issue_on_jira
164
+ end
165
+
166
+ if example.metadata[:unstub_pivotal_creation].blank?
167
+ allow_any_instance_of(Task).to receive :create_issue_on_pivotal
168
+ end
169
+
170
+ if example.metadata[:unstub_pivotal_starting].blank?
171
+ allow_any_instance_of(Task).to receive :start_issue_on_pivotal
172
+ end
173
+
174
+ if example.metadata[:unstub_key_output].blank?
175
+ allow_any_instance_of(Task).to receive :output_jira_key
176
+ end
177
+ end
178
+ end