easy-auto 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +39 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +27 -0
- data/LICENSE.txt +22 -0
- data/README.md +55 -0
- data/Rakefile +11 -0
- data/bin/create-branch +8 -0
- data/bin/create-repo +5 -0
- data/bin/easy-authorize +5 -0
- data/bin/easy-setup +5 -0
- data/bin/pull-request +5 -0
- data/easy-auto.gemspec +25 -0
- data/lib/easy_auto.rb +13 -0
- data/lib/easy_auto/authorize.rb +49 -0
- data/lib/easy_auto/client_wrapper.rb +21 -0
- data/lib/easy_auto/config_manager.rb +60 -0
- data/lib/easy_auto/config_manager_wrapper.rb +9 -0
- data/lib/easy_auto/create_branch.rb +53 -0
- data/lib/easy_auto/create_repo.rb +75 -0
- data/lib/easy_auto/easy_setup.rb +58 -0
- data/lib/easy_auto/easy_utilities.rb +14 -0
- data/lib/easy_auto/git.rb +57 -0
- data/lib/easy_auto/git_wrapper.rb +9 -0
- data/lib/easy_auto/pull_request.rb +68 -0
- data/lib/easy_auto/set_upstream.rb +16 -0
- data/lib/easy_auto/system_helper.rb +29 -0
- data/lib/easy_auto/version.rb +3 -0
- data/test/lib/easy_auto/authorize_test.rb +17 -0
- data/test/lib/easy_auto/create_branch_test.rb +74 -0
- data/test/lib/easy_auto/create_repo_test.rb +51 -0
- data/test/lib/easy_auto/easy_setup_test.rb +32 -0
- data/test/lib/easy_auto/easy_utilities_test.rb +20 -0
- data/test/lib/easy_auto/git_test.rb +69 -0
- data/test/lib/easy_auto/git_wrapper_test.rb +20 -0
- data/test/lib/easy_auto/pull_request_test.rb +78 -0
- data/test/lib/easy_auto/set_upstream_test.rb +41 -0
- data/test/lib/easy_auto/version_test.rb +7 -0
- data/test/test_helper.rb +3 -0
- data/todo.md +3 -0
- metadata +141 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
|
3
|
+
SetupMock = Class.new(EasyAuto::EasySetup) do
|
4
|
+
def initialize os
|
5
|
+
@os = os
|
6
|
+
end
|
7
|
+
|
8
|
+
def os
|
9
|
+
@os
|
10
|
+
end
|
11
|
+
|
12
|
+
def system_exit; end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe EasyAuto::EasySetup do
|
16
|
+
describe 'checking user os' do
|
17
|
+
it 'should reject non-osx/linux machines' do
|
18
|
+
subject = SetupMock.new 'not-unix'
|
19
|
+
-> { subject.os_check }.must_output "Sorry, your OS isn't supported.\n"
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should accept linux machines' do
|
23
|
+
subject = SetupMock.new 'Linux'
|
24
|
+
-> { subject.os_check }.must_output "You have an acceptable os!\n"
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should accept linux machines' do
|
28
|
+
subject = SetupMock.new 'Darwin'
|
29
|
+
-> { subject.os_check }.must_output "You have an acceptable os!\n"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
|
3
|
+
module EasyAuto
|
4
|
+
UtilitiesMock = Class.new do
|
5
|
+
include EasyUtilities
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe EasyAuto::EasyUtilities do
|
10
|
+
|
11
|
+
subject { EasyAuto::UtilitiesMock.new }
|
12
|
+
|
13
|
+
it "should give the class access to :hidden_input" do
|
14
|
+
subject.must_respond_to :hidden_input
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should give the class access to :ask" do
|
18
|
+
subject.must_respond_to :ask
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
|
3
|
+
GitMock = Class.new(EasyAuto::Git) do
|
4
|
+
def self.perform command
|
5
|
+
mock.send "git #{command}"
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.mock
|
9
|
+
@mock
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.mock=(mock)
|
13
|
+
@mock = mock
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe EasyAuto::Git do
|
18
|
+
|
19
|
+
subject { GitMock }
|
20
|
+
|
21
|
+
before do
|
22
|
+
@mock = MiniTest::Mock.new
|
23
|
+
subject.mock = @mock
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'responds to :cli_send (use extend!)' do
|
27
|
+
subject.must_respond_to :cli_send
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#delete_local_and_remote_branch' do
|
31
|
+
it 'uses the right git commands to delete the local and remote branch' do
|
32
|
+
@mock.expect :send, true, ["git checkout master"]
|
33
|
+
@mock.expect :send, true, ["git branch -D test-123"]
|
34
|
+
@mock.expect :send, true, ["git push origin :test-123"]
|
35
|
+
subject.delete_local_and_remote_branch 'test-123'
|
36
|
+
@mock.verify
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#create_and_switch_to' do
|
41
|
+
it 'with one argument' do
|
42
|
+
@mock.expect :send, true, ["git checkout -b test-123 "]
|
43
|
+
subject.create_and_switch_to 'test-123'
|
44
|
+
@mock.verify
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'with two arguments' do
|
48
|
+
@mock.expect :send, true, ["git checkout -b test-123 other-branch"]
|
49
|
+
subject.create_and_switch_to 'test-123', 'other-branch'
|
50
|
+
@mock.verify
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '#current_branch_name' do
|
55
|
+
it 'uses the right git commands' do
|
56
|
+
@mock.expect :send, true, ["git rev-parse --abbrev-ref HEAD"]
|
57
|
+
subject.current_branch_name
|
58
|
+
@mock.verify
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#remote_branch' do
|
63
|
+
it 'uses the right git commands' do
|
64
|
+
@mock.expect :send, true, ["git rev-parse --abbrev-ref --symbolic-full-name @{u}"]
|
65
|
+
subject.remote_branch
|
66
|
+
@mock.verify
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
|
3
|
+
module EasyAuto
|
4
|
+
GitMock = Class.new do
|
5
|
+
include GitWrapper
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe EasyAuto::GitWrapper do
|
10
|
+
|
11
|
+
subject { EasyAuto::GitMock.new }
|
12
|
+
|
13
|
+
it "should give the class access to :git" do
|
14
|
+
subject.must_respond_to :git
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should return the EasyAuto::Git class" do
|
18
|
+
subject.git.must_equal EasyAuto::Git
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
|
3
|
+
module EasyAuto::ClientWrapper
|
4
|
+
def client
|
5
|
+
OpenStruct.new login: 'sample-user'
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
class PRMock < EasyAuto::PullRequest
|
10
|
+
def initialize mock
|
11
|
+
@mock = mock
|
12
|
+
end
|
13
|
+
|
14
|
+
def remote_paths
|
15
|
+
"origin\tgit@github.com:repo_owner/easy-auto.git (fetch)\norigin\tgit@github.com:repo_owner/easy-auto.git (push)"
|
16
|
+
end
|
17
|
+
|
18
|
+
def head
|
19
|
+
'awesome-new-feature'
|
20
|
+
end
|
21
|
+
|
22
|
+
def cli_send browser_open_command
|
23
|
+
@mock.call browser_open_command
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe EasyAuto::PullRequest do
|
28
|
+
before do
|
29
|
+
@mock = MiniTest::Mock.new
|
30
|
+
end
|
31
|
+
|
32
|
+
subject { PRMock.new @mock }
|
33
|
+
|
34
|
+
it 'states what branch is requesting to be merged into what branch' do
|
35
|
+
repo_owner = 'repo_owner'
|
36
|
+
repo_name = 'easy-auto'
|
37
|
+
pr_branch = 'awesome-new-feature'
|
38
|
+
-> { subject.state_merge_intent }.must_output "Preparing pull request:\n#{repo_owner}/#{repo_name}/#{pr_branch} -> #{repo_owner}/#{repo_name}/master\n"
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'requires the git wrapper' do
|
42
|
+
subject.must_respond_to :git
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'requires the client wrapper' do
|
46
|
+
subject.must_respond_to :client
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'returns the git class' do
|
50
|
+
subject.git.must_be_same_as EasyAuto::Git
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'finds the right username' do
|
54
|
+
subject.username.must_equal 'sample-user'
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'returns a string for repo_name' do
|
58
|
+
subject.repo_name.must_be_instance_of String
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'returns the first match' do
|
62
|
+
subject.repo_name.must_equal 'easy-auto'
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'finds the repo name from #remote_paths' do
|
66
|
+
subject.repo_owner.must_equal 'repo_owner'
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'returns the right repo_path' do
|
70
|
+
subject.repo_path.must_equal 'repo_owner/easy-auto'
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'opens the right web address' do
|
74
|
+
pr_number = 10
|
75
|
+
@mock.expect :call, true, ["open 'https://github.com/#{subject.repo_path}/pull/#{pr_number}'"]
|
76
|
+
subject.open_in_browser pr_number
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
|
3
|
+
describe EasyAuto::SetUpstream do
|
4
|
+
|
5
|
+
subject { EasyAuto::SetUpstream.new 'test-123' }
|
6
|
+
let(:git) { subject.git }
|
7
|
+
|
8
|
+
it 'requires the git wrapper' do
|
9
|
+
subject.must_respond_to :git
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'returns the git class' do
|
13
|
+
git.must_be_same_as EasyAuto::Git
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
SUMock = Class.new(EasyAuto::SetUpstream) do
|
18
|
+
def initialize mock, upstream_branch
|
19
|
+
@mock = mock
|
20
|
+
@upstream_branch = upstream_branch
|
21
|
+
end
|
22
|
+
|
23
|
+
def set
|
24
|
+
@mock.perform "push --set-upstream origin #{upstream_branch}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe SUMock do
|
29
|
+
before do
|
30
|
+
@mock = MiniTest::Mock.new
|
31
|
+
end
|
32
|
+
|
33
|
+
subject { SUMock.new @mock, 'test-123' }
|
34
|
+
|
35
|
+
it 'should correctly set the upstream branch' do
|
36
|
+
upstream_branch = 'test-123'
|
37
|
+
@mock.expect :perform, true, ["push --set-upstream origin #{upstream_branch}"]
|
38
|
+
subject.set
|
39
|
+
@mock.verify
|
40
|
+
end
|
41
|
+
end
|
data/test/test_helper.rb
ADDED
data/todo.md
ADDED
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: easy-auto
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stuart Nelson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: octokit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
description: Easy access to git commands
|
56
|
+
email:
|
57
|
+
- stuartnelson3@gmail.com
|
58
|
+
executables:
|
59
|
+
- create-branch
|
60
|
+
- create-repo
|
61
|
+
- easy-authorize
|
62
|
+
- easy-setup
|
63
|
+
- pull-request
|
64
|
+
extensions: []
|
65
|
+
extra_rdoc_files: []
|
66
|
+
files:
|
67
|
+
- .gitignore
|
68
|
+
- Gemfile
|
69
|
+
- Gemfile.lock
|
70
|
+
- LICENSE.txt
|
71
|
+
- README.md
|
72
|
+
- Rakefile
|
73
|
+
- bin/create-branch
|
74
|
+
- bin/create-repo
|
75
|
+
- bin/easy-authorize
|
76
|
+
- bin/easy-setup
|
77
|
+
- bin/pull-request
|
78
|
+
- easy-auto.gemspec
|
79
|
+
- lib/easy_auto.rb
|
80
|
+
- lib/easy_auto/authorize.rb
|
81
|
+
- lib/easy_auto/client_wrapper.rb
|
82
|
+
- lib/easy_auto/config_manager.rb
|
83
|
+
- lib/easy_auto/config_manager_wrapper.rb
|
84
|
+
- lib/easy_auto/create_branch.rb
|
85
|
+
- lib/easy_auto/create_repo.rb
|
86
|
+
- lib/easy_auto/easy_setup.rb
|
87
|
+
- lib/easy_auto/easy_utilities.rb
|
88
|
+
- lib/easy_auto/git.rb
|
89
|
+
- lib/easy_auto/git_wrapper.rb
|
90
|
+
- lib/easy_auto/pull_request.rb
|
91
|
+
- lib/easy_auto/set_upstream.rb
|
92
|
+
- lib/easy_auto/system_helper.rb
|
93
|
+
- lib/easy_auto/version.rb
|
94
|
+
- test/lib/easy_auto/authorize_test.rb
|
95
|
+
- test/lib/easy_auto/create_branch_test.rb
|
96
|
+
- test/lib/easy_auto/create_repo_test.rb
|
97
|
+
- test/lib/easy_auto/easy_setup_test.rb
|
98
|
+
- test/lib/easy_auto/easy_utilities_test.rb
|
99
|
+
- test/lib/easy_auto/git_test.rb
|
100
|
+
- test/lib/easy_auto/git_wrapper_test.rb
|
101
|
+
- test/lib/easy_auto/pull_request_test.rb
|
102
|
+
- test/lib/easy_auto/set_upstream_test.rb
|
103
|
+
- test/lib/easy_auto/version_test.rb
|
104
|
+
- test/test_helper.rb
|
105
|
+
- todo.md
|
106
|
+
homepage: https://github.com/stuartnelson3/easy-auto
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
metadata: {}
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options: []
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - '>='
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 2.0.7
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: Use the command line to simplify interacting with git
|
130
|
+
test_files:
|
131
|
+
- test/lib/easy_auto/authorize_test.rb
|
132
|
+
- test/lib/easy_auto/create_branch_test.rb
|
133
|
+
- test/lib/easy_auto/create_repo_test.rb
|
134
|
+
- test/lib/easy_auto/easy_setup_test.rb
|
135
|
+
- test/lib/easy_auto/easy_utilities_test.rb
|
136
|
+
- test/lib/easy_auto/git_test.rb
|
137
|
+
- test/lib/easy_auto/git_wrapper_test.rb
|
138
|
+
- test/lib/easy_auto/pull_request_test.rb
|
139
|
+
- test/lib/easy_auto/set_upstream_test.rb
|
140
|
+
- test/lib/easy_auto/version_test.rb
|
141
|
+
- test/test_helper.rb
|