geet 0.27.1 → 0.27.3

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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +79 -58
  3. data/Gemfile +9 -9
  4. data/Rakefile +2 -2
  5. data/bin/geet +7 -7
  6. data/geet.gemspec +19 -19
  7. data/lib/geet/commandline/commands.rb +16 -15
  8. data/lib/geet/commandline/configuration.rb +97 -93
  9. data/lib/geet/commandline/editor.rb +13 -7
  10. data/lib/geet/git/repository.rb +75 -6
  11. data/lib/geet/github/abstract_issue.rb +7 -7
  12. data/lib/geet/github/api_interface.rb +23 -23
  13. data/lib/geet/github/gist.rb +8 -8
  14. data/lib/geet/github/issue.rb +6 -6
  15. data/lib/geet/github/label.rb +5 -5
  16. data/lib/geet/github/milestone.rb +10 -10
  17. data/lib/geet/github/pr.rb +25 -25
  18. data/lib/geet/github/remote_repository.rb +1 -1
  19. data/lib/geet/github/user.rb +5 -5
  20. data/lib/geet/gitlab/api_interface.rb +13 -13
  21. data/lib/geet/gitlab/issue.rb +3 -3
  22. data/lib/geet/gitlab/label.rb +4 -4
  23. data/lib/geet/gitlab/milestone.rb +4 -4
  24. data/lib/geet/gitlab/pr.rb +4 -4
  25. data/lib/geet/gitlab/user.rb +2 -2
  26. data/lib/geet/helpers/json_helper.rb +1 -1
  27. data/lib/geet/helpers/os_helper.rb +5 -5
  28. data/lib/geet/helpers/services_workflow_helper.rb +4 -4
  29. data/lib/geet/services/abstract_create_issue.rb +3 -3
  30. data/lib/geet/services/add_upstream_repo.rb +1 -1
  31. data/lib/geet/services/close_milestones.rb +9 -2
  32. data/lib/geet/services/comment_pr.rb +11 -0
  33. data/lib/geet/services/create_gist.rb +18 -4
  34. data/lib/geet/services/create_issue.rb +14 -8
  35. data/lib/geet/services/create_label.rb +22 -3
  36. data/lib/geet/services/create_milestone.rb +7 -1
  37. data/lib/geet/services/create_pr.rb +98 -23
  38. data/lib/geet/services/list_issues.rb +4 -3
  39. data/lib/geet/services/list_labels.rb +7 -0
  40. data/lib/geet/services/list_milestones.rb +35 -6
  41. data/lib/geet/services/list_prs.rb +7 -0
  42. data/lib/geet/services/merge_pr.rb +20 -2
  43. data/lib/geet/services/open_pr.rb +2 -2
  44. data/lib/geet/services/open_repo.rb +7 -1
  45. data/lib/geet/shared/repo_permissions.rb +4 -4
  46. data/lib/geet/shared/selection.rb +2 -2
  47. data/lib/geet/utils/attributes_selection_manager.rb +30 -10
  48. data/lib/geet/utils/git_client.rb +74 -33
  49. data/lib/geet/utils/manual_list_selection.rb +23 -11
  50. data/lib/geet/utils/string_matching_selection.rb +22 -6
  51. data/lib/geet/version.rb +2 -1
  52. data/lib/geet.rb +2 -2
  53. data/spec/integration/comment_pr_spec.rb +10 -10
  54. data/spec/integration/create_gist_spec.rb +12 -12
  55. data/spec/integration/create_issue_spec.rb +21 -21
  56. data/spec/integration/create_label_spec.rb +33 -33
  57. data/spec/integration/create_milestone_spec.rb +9 -9
  58. data/spec/integration/create_pr_spec.rb +120 -134
  59. data/spec/integration/list_issues_spec.rb +25 -25
  60. data/spec/integration/list_labels_spec.rb +15 -15
  61. data/spec/integration/list_milestones_spec.rb +15 -15
  62. data/spec/integration/list_prs_spec.rb +10 -10
  63. data/spec/integration/merge_pr_spec.rb +18 -18
  64. data/spec/integration/open_pr_spec.rb +18 -20
  65. data/spec/integration/open_repo_spec.rb +18 -18
  66. data/spec/spec_helper.rb +10 -10
  67. data/spec/unit/github/pr_spec.rb +91 -91
  68. metadata +2 -3
  69. data/.rubocop_todo.yml +0 -466
@@ -1,18 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
- require_relative '../../lib/geet/git/repository'
6
- require_relative '../../lib/geet/services/list_issues'
5
+ require_relative "../../lib/geet/git/repository"
6
+ require_relative "../../lib/geet/services/list_issues"
7
7
 
8
8
  describe Geet::Services::ListIssues do
9
9
  let(:git_client) { Geet::Utils::GitClient.new }
10
10
  let(:repository) { Geet::Git::Repository.new(git_client: git_client) }
11
11
  let(:upstream_repository) { Geet::Git::Repository.new(upstream: true, git_client: git_client) }
12
12
 
13
- context 'with github.com' do
14
- it 'should list the default issues' do
15
- allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo')
13
+ context "with github.com" do
14
+ it "should list the default issues" do
15
+ allow(git_client).to receive(:remote).with(no_args).and_return("git@github.com:donaldduck/testrepo")
16
16
 
17
17
  expected_output = <<~STR
18
18
  5. Title 2 (https://github.com/donaldduck/testrepo/issues/5)
@@ -22,7 +22,7 @@ describe Geet::Services::ListIssues do
22
22
 
23
23
  actual_output = StringIO.new
24
24
 
25
- service_result = VCR.use_cassette('github_com/list_issues') do
25
+ service_result = VCR.use_cassette("github_com/list_issues") do
26
26
  described_class.new(repository, out: actual_output).execute
27
27
  end
28
28
 
@@ -32,9 +32,9 @@ describe Geet::Services::ListIssues do
32
32
  expect(actual_issue_numbers).to eql(expected_issue_numbers)
33
33
  end
34
34
 
35
- context 'with assignee filtering' do
36
- it 'should list the issues' do
37
- allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_gh')
35
+ context "with assignee filtering" do
36
+ it "should list the issues" do
37
+ allow(git_client).to receive(:remote).with(no_args).and_return("git@github.com:donaldduck/testrepo_gh")
38
38
 
39
39
  expected_output = <<~STR
40
40
  Finding collaborators...
@@ -45,8 +45,8 @@ describe Geet::Services::ListIssues do
45
45
 
46
46
  actual_output = StringIO.new
47
47
 
48
- service_result = VCR.use_cassette('github_com/list_issues_with_assignee') do
49
- described_class.new(repository, out: actual_output).execute(assignee: 'donald-fr')
48
+ service_result = VCR.use_cassette("github_com/list_issues_with_assignee") do
49
+ described_class.new(repository, out: actual_output).execute(assignee: "donald-fr")
50
50
  end
51
51
 
52
52
  actual_issue_numbers = service_result.map(&:number)
@@ -56,9 +56,9 @@ describe Geet::Services::ListIssues do
56
56
  end
57
57
  end
58
58
 
59
- it 'should list the upstream issues' do
60
- allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_2f')
61
- allow(git_client).to receive(:remote).with(name: 'upstream').and_return('git@github.com:donald-fr/testrepo_u')
59
+ it "should list the upstream issues" do
60
+ allow(git_client).to receive(:remote).with(no_args).and_return("git@github.com:donaldduck/testrepo_2f")
61
+ allow(git_client).to receive(:remote).with(name: "upstream").and_return("git@github.com:donald-fr/testrepo_u")
62
62
 
63
63
  expected_output = <<~STR
64
64
  2. Title 2 U (https://github.com/donald-fr/testrepo_u/issues/2)
@@ -68,7 +68,7 @@ describe Geet::Services::ListIssues do
68
68
 
69
69
  actual_output = StringIO.new
70
70
 
71
- service_result = VCR.use_cassette('github_com/list_issues_upstream') do
71
+ service_result = VCR.use_cassette("github_com/list_issues_upstream") do
72
72
  described_class.new(upstream_repository, out: actual_output).execute
73
73
  end
74
74
 
@@ -79,9 +79,9 @@ describe Geet::Services::ListIssues do
79
79
  end
80
80
  end
81
81
 
82
- context 'with gitlab.com' do
83
- it 'should list the issues' do
84
- allow(git_client).to receive(:remote).with(no_args).and_return('git@gitlab.com:donaldduck/testproject')
82
+ context "with gitlab.com" do
83
+ it "should list the issues" do
84
+ allow(git_client).to receive(:remote).with(no_args).and_return("git@gitlab.com:donaldduck/testproject")
85
85
 
86
86
  expected_output = <<~STR
87
87
  2. I like more pizza (https://gitlab.com/donaldduck/testproject/issues/2)
@@ -91,7 +91,7 @@ describe Geet::Services::ListIssues do
91
91
 
92
92
  actual_output = StringIO.new
93
93
 
94
- service_result = VCR.use_cassette('gitlab_com/list_issues') do
94
+ service_result = VCR.use_cassette("gitlab_com/list_issues") do
95
95
  described_class.new(repository, out: actual_output).execute
96
96
  end
97
97
 
@@ -101,9 +101,9 @@ describe Geet::Services::ListIssues do
101
101
  expect(actual_issue_numbers).to eql(expected_issue_numbers)
102
102
  end
103
103
 
104
- context 'with assignee filtering' do
105
- it 'should list the issues' do
106
- allow(git_client).to receive(:remote).with(no_args).and_return('git@gitlab.com:donaldduck/testproject')
104
+ context "with assignee filtering" do
105
+ it "should list the issues" do
106
+ allow(git_client).to receive(:remote).with(no_args).and_return("git@gitlab.com:donaldduck/testproject")
107
107
 
108
108
  expected_output = <<~STR
109
109
  Finding collaborators...
@@ -113,8 +113,8 @@ describe Geet::Services::ListIssues do
113
113
 
114
114
  actual_output = StringIO.new
115
115
 
116
- service_result = VCR.use_cassette('gitlab_com/list_issues_with_assignee') do
117
- described_class.new(repository, out: actual_output).execute(assignee: 'donald-fr')
116
+ service_result = VCR.use_cassette("gitlab_com/list_issues_with_assignee") do
117
+ described_class.new(repository, out: actual_output).execute(assignee: "donald-fr")
118
118
  end
119
119
 
120
120
  actual_issue_numbers = service_result.map(&:number)
@@ -1,18 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
- require_relative '../../lib/geet/git/repository'
6
- require_relative '../../lib/geet/services/list_labels'
5
+ require_relative "../../lib/geet/git/repository"
6
+ require_relative "../../lib/geet/services/list_labels"
7
7
 
8
8
  describe Geet::Services::ListLabels do
9
9
  let(:git_client) { Geet::Utils::GitClient.new }
10
10
  let(:repository) { Geet::Git::Repository.new(git_client: git_client) }
11
11
  let(:upstream_repository) { Geet::Git::Repository.new(upstream: true, git_client: git_client) }
12
12
 
13
- context 'with github.com' do
14
- it 'should list the labels' do
15
- allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/geet')
13
+ context "with github.com" do
14
+ it "should list the labels" do
15
+ allow(git_client).to receive(:remote).with(no_args).and_return("git@github.com:donaldduck/geet")
16
16
 
17
17
  expected_output = <<~STR
18
18
  - bug (#ee0701)
@@ -23,7 +23,7 @@ describe Geet::Services::ListLabels do
23
23
  expected_label_names = %w[bug enhancement technical_debt top_priority]
24
24
 
25
25
  actual_output = StringIO.new
26
- actual_labels = VCR.use_cassette('github.com/list_labels') do
26
+ actual_labels = VCR.use_cassette("github.com/list_labels") do
27
27
  described_class.new(repository, out: actual_output).execute
28
28
  end
29
29
 
@@ -33,9 +33,9 @@ describe Geet::Services::ListLabels do
33
33
  expect(actual_label_names).to eql(expected_label_names)
34
34
  end
35
35
 
36
- it 'should list the upstream labels' do
37
- allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/geet')
38
- allow(git_client).to receive(:remote).with(name: 'upstream').and_return('git@github.com:donaldduck-fr/testrepo_u')
36
+ it "should list the upstream labels" do
37
+ allow(git_client).to receive(:remote).with(no_args).and_return("git@github.com:donaldduck/geet")
38
+ allow(git_client).to receive(:remote).with(name: "upstream").and_return("git@github.com:donaldduck-fr/testrepo_u")
39
39
 
40
40
  expected_output = <<~STR
41
41
  - bug (#ee0701)
@@ -44,7 +44,7 @@ describe Geet::Services::ListLabels do
44
44
  expected_label_names = %w[bug enhancement]
45
45
 
46
46
  actual_output = StringIO.new
47
- actual_labels = VCR.use_cassette('github.com/list_labels_upstream') do
47
+ actual_labels = VCR.use_cassette("github.com/list_labels_upstream") do
48
48
  described_class.new(upstream_repository, out: actual_output).execute
49
49
  end
50
50
 
@@ -55,9 +55,9 @@ describe Geet::Services::ListLabels do
55
55
  end
56
56
  end
57
57
 
58
- context 'with gitlab.com' do
59
- it 'should list the labels' do
60
- allow(git_client).to receive(:remote).with(no_args).and_return('git@gitlab.com:donaldduck/testproject')
58
+ context "with gitlab.com" do
59
+ it "should list the labels" do
60
+ allow(git_client).to receive(:remote).with(no_args).and_return("git@gitlab.com:donaldduck/testproject")
61
61
 
62
62
  expected_output = <<~STR
63
63
  - bug (#d9534f)
@@ -72,7 +72,7 @@ describe Geet::Services::ListLabels do
72
72
  expected_label_names = %w[bug confirmed critical discussion documentation enhancement suggestion support]
73
73
 
74
74
  actual_output = StringIO.new
75
- actual_labels = VCR.use_cassette('gitlab.com/list_labels') do
75
+ actual_labels = VCR.use_cassette("gitlab.com/list_labels") do
76
76
  described_class.new(repository, out: actual_output).execute
77
77
  end
78
78
 
@@ -1,18 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
- require_relative '../../lib/geet/git/repository'
6
- require_relative '../../lib/geet/services/list_milestones'
5
+ require_relative "../../lib/geet/git/repository"
6
+ require_relative "../../lib/geet/services/list_milestones"
7
7
 
8
8
  describe Geet::Services::ListMilestones do
9
9
  let(:git_client) { Geet::Utils::GitClient.new }
10
10
  let(:repository) { Geet::Git::Repository.new(git_client: git_client) }
11
11
  let(:upstream_repository) { Geet::Git::Repository.new(upstream: true, git_client: git_client) }
12
12
 
13
- context 'with github.com' do
14
- it 'should list the milestones' do
15
- allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/geet')
13
+ context "with github.com" do
14
+ it "should list the milestones" do
15
+ allow(git_client).to receive(:remote).with(no_args).and_return("git@github.com:donaldduck/geet")
16
16
 
17
17
  expected_output = <<~STR
18
18
  Finding milestones...
@@ -39,7 +39,7 @@ describe Geet::Services::ListMilestones do
39
39
 
40
40
  actual_output = StringIO.new
41
41
 
42
- service_result = VCR.use_cassette('github_com/list_milestones') do
42
+ service_result = VCR.use_cassette("github_com/list_milestones") do
43
43
  described_class.new(repository, out: actual_output).execute
44
44
  end
45
45
 
@@ -49,9 +49,9 @@ describe Geet::Services::ListMilestones do
49
49
  expect(actual_milestone_numbers).to eql(expected_milestone_numbers)
50
50
  end
51
51
 
52
- it 'should list the upstream milestones' do
53
- allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donald-fr/testrepo_downstream')
54
- allow(git_client).to receive(:remote).with(name: 'upstream').and_return('git@github.com:donaldduck/testrepo_upstream')
52
+ it "should list the upstream milestones" do
53
+ allow(git_client).to receive(:remote).with(no_args).and_return("git@github.com:donald-fr/testrepo_downstream")
54
+ allow(git_client).to receive(:remote).with(name: "upstream").and_return("git@github.com:donaldduck/testrepo_upstream")
55
55
 
56
56
  expected_output = <<~STR
57
57
  Finding milestones...
@@ -67,7 +67,7 @@ describe Geet::Services::ListMilestones do
67
67
 
68
68
  actual_output = StringIO.new
69
69
 
70
- service_result = VCR.use_cassette('list_milestones_upstream') do
70
+ service_result = VCR.use_cassette("list_milestones_upstream") do
71
71
  described_class.new(upstream_repository, out: actual_output).execute
72
72
  end
73
73
 
@@ -78,9 +78,9 @@ describe Geet::Services::ListMilestones do
78
78
  end
79
79
  end # context 'with github.com'
80
80
 
81
- context 'with gitlab.com' do
82
- it 'should list the milestones' do
83
- allow(git_client).to receive(:remote).with(no_args).and_return('git@gitlab.com:donaldduck/testproject')
81
+ context "with gitlab.com" do
82
+ it "should list the milestones" do
83
+ allow(git_client).to receive(:remote).with(no_args).and_return("git@gitlab.com:donaldduck/testproject")
84
84
 
85
85
  expected_output = <<~STR
86
86
  Finding milestones...
@@ -95,7 +95,7 @@ describe Geet::Services::ListMilestones do
95
95
 
96
96
  actual_output = StringIO.new
97
97
 
98
- service_result = VCR.use_cassette('gitlab_com/list_milestones') do
98
+ service_result = VCR.use_cassette("gitlab_com/list_milestones") do
99
99
  described_class.new(repository, out: actual_output).execute
100
100
  end
101
101
 
@@ -1,17 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
- require_relative '../../lib/geet/git/repository'
6
- require_relative '../../lib/geet/services/list_prs'
5
+ require_relative "../../lib/geet/git/repository"
6
+ require_relative "../../lib/geet/services/list_prs"
7
7
 
8
8
  describe Geet::Services::ListPrs do
9
9
  let(:git_client) { Geet::Utils::GitClient.new }
10
10
  let(:repository) { Geet::Git::Repository.new(git_client: git_client) }
11
11
  let(:upstream_repository) { Geet::Git::Repository.new(upstream: true, git_client: git_client) }
12
12
 
13
- it 'should list the PRs' do
14
- allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donald-fr/testrepo_downstream')
13
+ it "should list the PRs" do
14
+ allow(git_client).to receive(:remote).with(no_args).and_return("git@github.com:donald-fr/testrepo_downstream")
15
15
 
16
16
  expected_output = <<~STR
17
17
  2. Add testfile3 (downstream) (https://github.com/donald-fr/testrepo_downstream/pull/2)
@@ -21,7 +21,7 @@ describe Geet::Services::ListPrs do
21
21
 
22
22
  actual_output = StringIO.new
23
23
 
24
- service_result = VCR.use_cassette('list_prs') do
24
+ service_result = VCR.use_cassette("list_prs") do
25
25
  described_class.new(repository, out: actual_output).execute
26
26
  end
27
27
 
@@ -31,9 +31,9 @@ describe Geet::Services::ListPrs do
31
31
  expect(actual_pr_numbers).to eql(expected_pr_numbers)
32
32
  end
33
33
 
34
- it 'should list the upstream PRs' do
35
- allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donald-fr/testrepo_downstream')
36
- allow(git_client).to receive(:remote).with(name: 'upstream').and_return('git@github.com:donaldduck/testrepo_upstream')
34
+ it "should list the upstream PRs" do
35
+ allow(git_client).to receive(:remote).with(no_args).and_return("git@github.com:donald-fr/testrepo_downstream")
36
+ allow(git_client).to receive(:remote).with(name: "upstream").and_return("git@github.com:donaldduck/testrepo_upstream")
37
37
 
38
38
  expected_output = <<~STR
39
39
  2. Add testfile3 (upstream) (https://github.com/donaldduck/testrepo_upstream/pull/2)
@@ -43,7 +43,7 @@ describe Geet::Services::ListPrs do
43
43
 
44
44
  actual_output = StringIO.new
45
45
 
46
- service_result = VCR.use_cassette('list_prs_upstream') do
46
+ service_result = VCR.use_cassette("list_prs_upstream") do
47
47
  described_class.new(upstream_repository, out: actual_output).execute
48
48
  end
49
49
 
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
- require_relative '../../lib/geet/git/repository'
6
- require_relative '../../lib/geet/services/merge_pr'
5
+ require_relative "../../lib/geet/git/repository"
6
+ require_relative "../../lib/geet/services/merge_pr"
7
7
 
8
8
  # Currently disabled: it requires updates following the addition of the automatic removal of the local
9
9
  # branch.
@@ -13,24 +13,24 @@ require_relative '../../lib/geet/services/merge_pr'
13
13
  describe Geet::Services::MergePr do
14
14
  let(:git_client) { Geet::Utils::GitClient.new }
15
15
  let(:repository) { Geet::Git::Repository.new(git_client: git_client) }
16
- let(:owner) { 'donaldduck' }
17
- let(:branch) { 'mybranch' }
18
- let(:main_branch) { 'main' }
16
+ let(:owner) { "donaldduck" }
17
+ let(:branch) { "mybranch" }
18
+ let(:main_branch) { "main" }
19
19
 
20
20
  before :each do
21
21
  expect(git_client).to receive(:fetch).twice
22
22
  expect(git_client).to receive(:push)
23
- expect(git_client).to receive(:cherry).with('HEAD', head: :main_branch).and_return([])
23
+ expect(git_client).to receive(:cherry).with("HEAD", head: :main_branch).and_return([])
24
24
  expect(git_client).to receive(:remote_branch_gone?).and_return(true)
25
25
  expect(git_client).to receive(:checkout).with(main_branch)
26
26
  expect(git_client).to receive(:rebase)
27
- expect(git_client).to receive(:delete_branch).with('mybranch', force: false)
27
+ expect(git_client).to receive(:delete_branch).with("mybranch", force: false)
28
28
  end
29
29
 
30
- context 'with github.com' do
31
- let(:repository_name) { 'testrepo_upstream' }
30
+ context "with github.com" do
31
+ let(:repository_name) { "testrepo_upstream" }
32
32
 
33
- it 'should merge the PR for the current branch' do
33
+ it "should merge the PR for the current branch" do
34
34
  allow(git_client).to receive(:current_branch).and_return(branch)
35
35
  allow(git_client).to receive(:main_branch).and_return(main_branch)
36
36
  allow(git_client).to receive(:remote).with(no_args).and_return("git@github.com:#{owner}/#{repository_name}")
@@ -47,7 +47,7 @@ describe Geet::Services::MergePr do
47
47
 
48
48
  actual_output = StringIO.new
49
49
 
50
- service_result = VCR.use_cassette('github_com/merge_pr') do
50
+ service_result = VCR.use_cassette("github_com/merge_pr") do
51
51
  described_class.new(repository, out: actual_output, git_client: git_client).execute
52
52
  end
53
53
 
@@ -57,7 +57,7 @@ describe Geet::Services::MergePr do
57
57
  expect(actual_pr_number).to eql(expected_pr_number)
58
58
  end
59
59
 
60
- it 'should merge the PR for the current branch, with branch deletion' do
60
+ it "should merge the PR for the current branch, with branch deletion" do
61
61
  allow(git_client).to receive(:current_branch).and_return(branch)
62
62
  allow(git_client).to receive(:main_branch).and_return(main_branch)
63
63
  allow(git_client).to receive(:remote).with(no_args).and_return("git@github.com:#{owner}/#{repository_name}")
@@ -75,7 +75,7 @@ describe Geet::Services::MergePr do
75
75
 
76
76
  actual_output = StringIO.new
77
77
 
78
- service_result = VCR.use_cassette('github_com/merge_pr_with_branch_deletion') do
78
+ service_result = VCR.use_cassette("github_com/merge_pr_with_branch_deletion") do
79
79
  described_class.new(repository, out: actual_output, git_client: git_client).execute(delete_branch: true)
80
80
  end
81
81
 
@@ -86,10 +86,10 @@ describe Geet::Services::MergePr do
86
86
  end
87
87
  end # context 'with github.com'
88
88
 
89
- context 'with gitlab.com' do
90
- let(:repository_name) { 'testproject' }
89
+ context "with gitlab.com" do
90
+ let(:repository_name) { "testproject" }
91
91
 
92
- it 'should merge the PR for the current branch' do
92
+ it "should merge the PR for the current branch" do
93
93
  allow(git_client).to receive(:current_branch).and_return(branch)
94
94
  allow(git_client).to receive(:main_branch).and_return(main_branch)
95
95
  allow(git_client).to receive(:remote).with(no_args).and_return("git@gitlab.com:#{owner}/#{repository_name}")
@@ -106,7 +106,7 @@ describe Geet::Services::MergePr do
106
106
 
107
107
  actual_output = StringIO.new
108
108
 
109
- service_result = VCR.use_cassette('gitlab_com/merge_pr') do
109
+ service_result = VCR.use_cassette("gitlab_com/merge_pr") do
110
110
  described_class.new(repository, out: actual_output, git_client: git_client).execute
111
111
  end
112
112
 
@@ -1,20 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
- require_relative '../../lib/geet/git/repository'
6
- require_relative '../../lib/geet/services/open_pr'
5
+ require_relative "../../lib/geet/git/repository"
6
+ require_relative "../../lib/geet/services/open_pr"
7
7
 
8
8
  describe Geet::Services::OpenPr do
9
9
  let(:git_client) { Geet::Utils::GitClient.new }
10
10
  let(:repository) { Geet::Git::Repository.new(git_client: git_client) }
11
- let(:owner) { 'donaldduck' }
12
- let(:branch) { 'mybranch' }
11
+ let(:owner) { "donaldduck" }
12
+ let(:branch) { "mybranch" }
13
13
 
14
- context 'with github.com' do
15
- let(:repository_name) { 'testrepo_upstream' }
14
+ context "with github.com" do
15
+ let(:repository_name) { "testrepo_upstream" }
16
16
 
17
- it 'should open the PR for the current branch' do
17
+ it "should open the PR for the current branch" do
18
18
  allow(git_client).to receive(:current_branch).and_return(branch)
19
19
  allow(git_client).to receive(:remote).with(no_args).and_return("git@github.com:#{owner}/#{repository_name}")
20
20
 
@@ -23,21 +23,19 @@ describe Geet::Services::OpenPr do
23
23
  Finding PR with head (#{owner}:#{branch})...
24
24
  STR
25
25
 
26
- actual_output = StringIO.new
27
- service_instance = described_class.new(repository, out: actual_output, git_client: git_client)
26
+ expect {
27
+ service_instance = described_class.new(repository, git_client: git_client)
28
28
 
29
- expect(service_instance).to receive(:open_file_with_default_application).with("https://github.com/#{owner}/#{repository_name}/pull/#{expected_pr_number}") do
30
- # do nothing; just don't open the browser
31
- end
29
+ expect(service_instance).to receive(:open_file_with_default_application).with("https://github.com/#{owner}/#{repository_name}/pull/#{expected_pr_number}") do
30
+ # do nothing; just don't open the browser
31
+ end
32
32
 
33
- service_result = VCR.use_cassette('github_com/open_pr') do
34
- service_instance.execute
35
- end
33
+ service_result = VCR.use_cassette("github_com/open_pr") do
34
+ service_instance.execute
35
+ end
36
36
 
37
- actual_pr_number = service_result.number
38
-
39
- expect(actual_output.string).to eql(expected_output)
40
- expect(actual_pr_number).to eql(expected_pr_number)
37
+ expect(service_result.number).to eql(expected_pr_number)
38
+ }.to output(expected_output).to_stdout
41
39
  end
42
40
 
43
41
  end # context 'with github.com'
@@ -1,24 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
- require_relative '../../lib/geet/git/repository'
6
- require_relative '../../lib/geet/services/open_repo'
5
+ require_relative "../../lib/geet/git/repository"
6
+ require_relative "../../lib/geet/services/open_repo"
7
7
 
8
8
  module Geet
9
9
  describe Services::OpenRepo do
10
10
  let(:git_client) { Utils::GitClient.new }
11
11
  let(:repository) { Git::Repository.new(git_client: git_client) }
12
12
 
13
- OWNER = 'donaldduck'
14
- REPOSITORY_NAME = 'testrepo'
13
+ OWNER = "donaldduck"
14
+ REPOSITORY_NAME = "testrepo"
15
15
 
16
16
  REMOTE_URLS = {
17
- 'git' => "git@github.com:#{OWNER}/#{REPOSITORY_NAME}",
18
- 'https' => "https://github.com/#{OWNER}/#{REPOSITORY_NAME}",
17
+ "git" => "git@github.com:#{OWNER}/#{REPOSITORY_NAME}",
18
+ "https" => "https://github.com/#{OWNER}/#{REPOSITORY_NAME}",
19
19
  }
20
20
 
21
- context 'should open the PR for the current branch' do
21
+ context "should open the PR for the current branch" do
22
22
  REMOTE_URLS.each do |protocol, remote_url|
23
23
  it "with #{protocol} protocol" do
24
24
  allow(git_client).to receive(:remote).with(no_args).and_return(remote_url)
@@ -26,19 +26,19 @@ module Geet
26
26
  expected_url = "https://github.com/#{OWNER}/#{REPOSITORY_NAME}"
27
27
  expected_output = ""
28
28
 
29
- actual_output = StringIO.new
30
- service_instance = described_class.new(repository, out: actual_output, git_client: git_client)
29
+ expect {
30
+ service_instance = described_class.new(repository, git_client: git_client)
31
31
 
32
- expect(service_instance).to receive(:open_file_with_default_application).with(expected_url) do
33
- # do nothing; just don't open the browser
34
- end
32
+ expect(service_instance).to receive(:open_file_with_default_application).with(expected_url) do
33
+ # do nothing; just don't open the browser
34
+ end
35
35
 
36
- execution_result = VCR.use_cassette('github_com/open_repo') do
37
- service_instance.execute
38
- end
36
+ execution_result = VCR.use_cassette("github_com/open_repo") do
37
+ service_instance.execute
38
+ end
39
39
 
40
- expect(actual_output.string).to eql(expected_output)
41
- expect(execution_result).to eql(expected_url)
40
+ expect(execution_result).to eql(expected_url)
41
+ }.to output(expected_output).to_stdout
42
42
  end
43
43
  end
44
44
  end # context 'should open the PR for the current branch'
data/spec/spec_helper.rb CHANGED
@@ -2,29 +2,29 @@
2
2
 
3
3
  # User-defined
4
4
 
5
- require 'vcr'
6
- require 'base64'
7
- require 'rspec/sorbet'
5
+ require "vcr"
6
+ require "base64"
7
+ require "rspec/sorbet"
8
8
 
9
- require_relative '../lib/geet'
9
+ require_relative "../lib/geet"
10
10
 
11
11
  RSpec::Sorbet.allow_doubles!
12
12
 
13
13
  VCR.configure do |config|
14
- config.cassette_library_dir = 'spec/vcr_cassettes'
14
+ config.cassette_library_dir = "spec/vcr_cassettes"
15
15
  config.hook_into :webmock
16
16
  config.default_cassette_options = {match_requests_on: [:method, :uri, :body], allow_unused_http_interactions: false}
17
17
 
18
18
  # See https://github.com/vcr/vcr/issues/201
19
- config.filter_sensitive_data('<GITHUB_CREDENTIALS>') do
20
- user = ''
21
- api_token = ENV.fetch('GITHUB_API_TOKEN')
19
+ config.filter_sensitive_data("<GITHUB_CREDENTIALS>") do
20
+ user = ""
21
+ api_token = ENV.fetch("GITHUB_API_TOKEN")
22
22
 
23
23
  Base64.strict_encode64("#{user}:#{api_token}")
24
24
  end
25
25
 
26
- config.filter_sensitive_data('<GITLAB_CREDENTIALS>') do
27
- ENV.fetch('GITLAB_API_TOKEN')
26
+ config.filter_sensitive_data("<GITLAB_CREDENTIALS>") do
27
+ ENV.fetch("GITLAB_API_TOKEN")
28
28
  end
29
29
  end
30
30