startling 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CODE_OF_CONDUCT.md +49 -0
- data/README.md +153 -32
- data/bin/console +10 -0
- data/bin/setup +6 -0
- data/{bin → exe}/start +0 -0
- data/{bin → exe}/wip +0 -0
- data/lib/generators/startling/configuration_generator.rb +4 -3
- data/lib/startling/configuration.rb +15 -0
- data/lib/startling/version.rb +1 -1
- data/startling.gemspec +10 -11
- metadata +32 -62
- data/spec/spec_helper.rb +0 -19
- data/spec/startling/command_spec.rb +0 -85
- data/spec/startling/commands/base_spec.rb +0 -32
- data/spec/startling/commands/create_branch_spec.rb +0 -105
- data/spec/startling/commands/create_pull_request_spec.rb +0 -46
- data/spec/startling/configuration_spec.rb +0 -189
- data/spec/startling/git_local_spec.rb +0 -22
- data/spec/startling/github/pull_request_spec.rb +0 -49
- data/spec/startling/handlers/default_pull_request_handler_spec.rb +0 -52
- data/spec/startling/time_format_helpers_spec.rb +0 -42
- data/spec/startling_configuration_spec.rb +0 -16
- data/spec/startling_spec.rb +0 -124
- data/spec/support/dotenv.rb +0 -2
- data/spec/support/tokens.rb +0 -5
- data/spec/support/vcr.rb +0 -13
- data/spec/vcr_cassettes/bin_start_starts_stories.yml +0 -564
- data/spec/vcr_cassettes/bin_start_starts_stories_pr_body.yml +0 -644
data/spec/spec_helper.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
-
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
-
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
-
# loaded once.
|
5
|
-
#
|
6
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
-
RSpec.configure do |config|
|
8
|
-
config.run_all_when_everything_filtered = true
|
9
|
-
config.filter_run :focus
|
10
|
-
|
11
|
-
# Run specs in random order to surface order dependencies. If you find an
|
12
|
-
# order dependency and want to debug it, you can fix the order by providing
|
13
|
-
# the seed, which is printed after each run.
|
14
|
-
# --seed 1234
|
15
|
-
config.order = 'random'
|
16
|
-
end
|
17
|
-
|
18
|
-
require 'pry'
|
19
|
-
Dir['./spec/support/**/*.rb'].map {|f| require f}
|
@@ -1,85 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
require 'startling/command'
|
4
|
-
|
5
|
-
describe Startling::Command do
|
6
|
-
let(:command) { Startling::Command.new }
|
7
|
-
|
8
|
-
describe '#execute' do
|
9
|
-
before do
|
10
|
-
allow(Startling::Commands::CheckForLocalMods).to receive(Startling::Command::RUN)
|
11
|
-
|
12
|
-
allow(Startling)
|
13
|
-
.to receive_message_chain(:hook_commands, :before_story_start) { [] }
|
14
|
-
|
15
|
-
allow(Startling)
|
16
|
-
.to receive_message_chain(:hook_commands, :after_story_start) { [] }
|
17
|
-
|
18
|
-
allow(Startling)
|
19
|
-
.to receive_message_chain(:hook_commands, :before_pull_request) { [] }
|
20
|
-
|
21
|
-
allow(Startling)
|
22
|
-
.to receive_message_chain(:hook_commands, :after_pull_request) { [] }
|
23
|
-
|
24
|
-
allow(Startling).to receive(:story_handler) { nil }
|
25
|
-
|
26
|
-
allow(Startling::Commands::CreatePullRequest).to receive(Startling::Command::RUN)
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'should check for local modifications' do
|
30
|
-
expect(Startling::Commands::CheckForLocalMods).to receive(Startling::Command::RUN)
|
31
|
-
|
32
|
-
command.execute
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'should run before story start commands' do
|
36
|
-
allow(Startling)
|
37
|
-
.to receive_message_chain(:hook_commands, :before_story_start) { [:create_branch] }
|
38
|
-
|
39
|
-
expect(Startling::Commands::CreateBranch).to receive(Startling::Command::RUN)
|
40
|
-
|
41
|
-
command.execute
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'should start the story if a story handler is defined' do
|
45
|
-
allow(Startling).to receive(:story_handler) { Startling::Commands::CreateBranch }
|
46
|
-
|
47
|
-
expect(Startling::Commands::CreateBranch).to receive(Startling::Command::RUN)
|
48
|
-
|
49
|
-
command.execute
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'should run after story start commands' do
|
53
|
-
allow(Startling)
|
54
|
-
.to receive_message_chain(:hook_commands, :after_story_start) { [:create_branch] }
|
55
|
-
|
56
|
-
expect(Startling::Commands::CreateBranch).to receive(Startling::Command::RUN)
|
57
|
-
|
58
|
-
command.execute
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'should run before pull request commands' do
|
62
|
-
allow(Startling)
|
63
|
-
.to receive_message_chain(:hook_commands, :before_pull_request) { [:create_branch] }
|
64
|
-
|
65
|
-
expect(Startling::Commands::CreateBranch).to receive(Startling::Command::RUN)
|
66
|
-
|
67
|
-
command.execute
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'should create the pull request' do
|
71
|
-
expect(Startling::Commands::CreatePullRequest).to receive(Startling::Command::RUN)
|
72
|
-
|
73
|
-
command.execute
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'should run after pull request commands' do
|
77
|
-
allow(Startling)
|
78
|
-
.to receive_message_chain(:hook_commands, :after_pull_request) { [:create_branch] }
|
79
|
-
|
80
|
-
expect(Startling::Commands::CreateBranch).to receive(Startling::Command::RUN)
|
81
|
-
|
82
|
-
command.execute
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
require 'startling/commands/base'
|
4
|
-
|
5
|
-
describe Startling::Commands::Base do
|
6
|
-
it "should assigns key/values passed in as attributes" do
|
7
|
-
base = Startling::Commands::Base.new(foo: 'bar', baz: 'qux')
|
8
|
-
expect(base.foo).to eq 'bar'
|
9
|
-
expect(base.baz).to eq 'qux'
|
10
|
-
end
|
11
|
-
|
12
|
-
describe '#execute' do
|
13
|
-
subject { Startling::Commands::Base.new }
|
14
|
-
it 'should throws NotImplementedError' do
|
15
|
-
expect{ subject.execute }.to raise_error(NotImplementedError)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '#run' do
|
20
|
-
subject { Startling::Commands::Base.run(foo: 'bar')}
|
21
|
-
|
22
|
-
it 'should assign attributes and call execute' do
|
23
|
-
base = double :base_command
|
24
|
-
allow(Startling::Commands::Base).to receive(:new).and_return(base)
|
25
|
-
|
26
|
-
expect(Startling::Commands::Base).to receive(:new).with(foo: 'bar')
|
27
|
-
expect(base).to receive(:execute)
|
28
|
-
|
29
|
-
subject
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,105 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
require 'startling/commands/create_branch'
|
4
|
-
|
5
|
-
describe Startling::Commands::CreateBranch do
|
6
|
-
let(:git) { double('GitLocal') }
|
7
|
-
let(:attrs) { { args: [], git: git } }
|
8
|
-
let(:create_branch) { Startling::Commands::CreateBranch.new(attrs) }
|
9
|
-
|
10
|
-
describe '#execute' do
|
11
|
-
let(:branch_name) { 'my-branch' }
|
12
|
-
let(:attrs) { { args: [1, branch_name], git: git } }
|
13
|
-
|
14
|
-
before do
|
15
|
-
allow(create_branch).to receive(:valid_branch_name?) { true }
|
16
|
-
allow(git).to receive(:current_branch) { 'current-branch' }
|
17
|
-
allow(create_branch).to receive(:create_branch)
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'returns an error if the branch name is invalid' do
|
21
|
-
allow(create_branch).to receive(:valid_branch_name?) { false }
|
22
|
-
|
23
|
-
expect { create_branch.execute }.to raise_exception(SystemExit)
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'creates the branch if it is not the current branch' do
|
27
|
-
allow(git).to receive(:current_branch) { 'current-branch' }
|
28
|
-
|
29
|
-
expect(create_branch).to receive(:create_branch)
|
30
|
-
create_branch.execute
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'does not create the branch if it is the current branch' do
|
34
|
-
allow(git).to receive(:current_branch) { branch_name }
|
35
|
-
|
36
|
-
expect(create_branch).not_to receive(:create_branch)
|
37
|
-
create_branch.execute
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'returns the branch name' do
|
41
|
-
expect(create_branch.execute).to eq(branch_name)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe '#branch_name' do
|
46
|
-
subject { create_branch.branch_name }
|
47
|
-
|
48
|
-
context 'when branch command line option is set' do
|
49
|
-
let(:attrs) { { args: [1, 'test everything'] } }
|
50
|
-
|
51
|
-
it 'returns the command line option' do
|
52
|
-
expect(subject).to eq('test-everything')
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context 'when branch command line option is not set' do
|
57
|
-
let(:default_branch) { 'master' }
|
58
|
-
|
59
|
-
before do
|
60
|
-
allow(create_branch).to receive(:default_branch) { default_branch }
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'returns the branch entered through the prompt' do
|
64
|
-
allow_any_instance_of(Startling::Commands::CreateBranch).to receive(:ask) { 'entered branch' }
|
65
|
-
|
66
|
-
expect(subject).to eq('entered-branch')
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'returns the current branch when no branch is entered through the prompt' do
|
70
|
-
allow_any_instance_of(Startling::Commands::CreateBranch).to receive(:ask) { '' }
|
71
|
-
allow(git).to receive(:current_branch) { 'current-branch' }
|
72
|
-
|
73
|
-
expect(subject).to eq('current-branch')
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe '#valid_branch_name?' do
|
79
|
-
let(:branch_name) { 'validate-me' }
|
80
|
-
let(:attrs) { { args: [1, branch_name] } }
|
81
|
-
|
82
|
-
subject { create_branch.valid_branch_name? }
|
83
|
-
|
84
|
-
before do
|
85
|
-
allow(create_branch).to receive(:default_branch) { 'master' }
|
86
|
-
allow(Startling).to receive(:validate_branch_name) { nil }
|
87
|
-
end
|
88
|
-
|
89
|
-
it 'succeeds if branch passes validation' do
|
90
|
-
expect(subject).to be_truthy
|
91
|
-
end
|
92
|
-
|
93
|
-
it 'fails if the branch is the default branch' do
|
94
|
-
allow(create_branch).to receive(:default_branch) { branch_name }
|
95
|
-
|
96
|
-
expect(subject).to be_falsey
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'fails if the custom validation Proc fails' do
|
100
|
-
allow(Startling).to receive(:validate_branch_name) { -> (branch_name) { /feature\/.*/ =~ branch_name } }
|
101
|
-
|
102
|
-
expect(subject).to be_falsey
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
require 'startling/commands/create_pull_request'
|
4
|
-
|
5
|
-
describe Startling::Commands::CreatePullRequest do
|
6
|
-
let(:git) { double('GitLocal') }
|
7
|
-
let(:attrs) { { git: git } }
|
8
|
-
let(:create_pull_request) { Startling::Commands::CreatePullRequest.new(attrs) }
|
9
|
-
|
10
|
-
describe '#open_pull_request' do
|
11
|
-
let(:commit_message) { 'test' }
|
12
|
-
let(:pull_request_handler) do
|
13
|
-
double(:pull_request_handler,
|
14
|
-
commit_message: commit_message,
|
15
|
-
title: 'title',
|
16
|
-
body: 'body'
|
17
|
-
)
|
18
|
-
end
|
19
|
-
|
20
|
-
let(:pull_request) { double(:pull_request, url: 'pull request URL') }
|
21
|
-
let(:repo) { double(:repo, open_pull_request: pull_request) }
|
22
|
-
|
23
|
-
before do
|
24
|
-
allow(create_pull_request).to receive(:pull_request_handler) { pull_request_handler }
|
25
|
-
allow(create_pull_request).to receive(:repo) { repo }
|
26
|
-
|
27
|
-
allow(git).to receive(:current_branch_has_no_commits?) { false }
|
28
|
-
allow(git).to receive(:create_empty_commit)
|
29
|
-
allow(git).to receive(:push_origin_head)
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should create an empty commit when the branch has no commits' do
|
33
|
-
allow(git).to receive(:current_branch_has_no_commits?) { true }
|
34
|
-
|
35
|
-
expect(git).to receive(:create_empty_commit).with(commit_message)
|
36
|
-
create_pull_request.open_pull_request
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should not create an empty commit when the branch has commits' do
|
40
|
-
allow(git).to receive(:current_branch_has_no_commits?) { false }
|
41
|
-
|
42
|
-
expect(git).not_to receive(:create_empty_commit)
|
43
|
-
create_pull_request.open_pull_request
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,189 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'startling'
|
3
|
-
|
4
|
-
module Startling
|
5
|
-
describe Configuration do
|
6
|
-
let(:configuration) { Configuration.new }
|
7
|
-
let(:current_repo) { 'current' }
|
8
|
-
|
9
|
-
before do
|
10
|
-
allow_any_instance_of(GitLocal).to receive(:repo_name) { current_repo }
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "Default settings" do
|
14
|
-
it "sets the default cache_dir to pwd" do
|
15
|
-
expect(configuration.cache_dir).to eql(Dir.pwd)
|
16
|
-
end
|
17
|
-
|
18
|
-
it "sets the default root_dir to pwd" do
|
19
|
-
expect(configuration.root_dir).to eql(Dir.pwd)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "sets the default wip limit to WIP_LIMIT" do
|
23
|
-
expect(configuration.wip_limit)
|
24
|
-
.to eql(Configuration::DEFAULT_WIP_LIMIT)
|
25
|
-
end
|
26
|
-
|
27
|
-
it "sets the WIP labels to empty" do
|
28
|
-
expect(configuration.wip_labels).to eql([])
|
29
|
-
end
|
30
|
-
|
31
|
-
it "sets the default repos to the current repo" do
|
32
|
-
expect(configuration.repos).to eql([current_repo])
|
33
|
-
end
|
34
|
-
|
35
|
-
it "sets the default story handler to nil" do
|
36
|
-
expect(configuration.story_handler).to eql(nil)
|
37
|
-
end
|
38
|
-
|
39
|
-
it "sets the default branch name validator to nil" do
|
40
|
-
expect(configuration.validate_branch_name).to eql(nil)
|
41
|
-
end
|
42
|
-
|
43
|
-
it "sets the default pull request handler to nil" do
|
44
|
-
expect(configuration.pull_request_handler).to eql(nil)
|
45
|
-
end
|
46
|
-
|
47
|
-
it "sets the default pull request body" do
|
48
|
-
expect(configuration.pull_request_body)
|
49
|
-
.to eql(Configuration::DEFAULT_BODY)
|
50
|
-
end
|
51
|
-
|
52
|
-
it "sets the default pull request commit message" do
|
53
|
-
expect(configuration.pull_request_commit_message)
|
54
|
-
.to eql(Configuration::DEFAULT_COMMIT_MESSAGE)
|
55
|
-
end
|
56
|
-
|
57
|
-
it "sets the default pull request labels" do
|
58
|
-
expect(configuration.pull_request_labels).to eql([])
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
describe "#cache_dir" do
|
63
|
-
it "can set the value" do
|
64
|
-
configuration.cache_dir = "new dir"
|
65
|
-
expect(configuration.cache_dir).to eql("new dir")
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe "#root_dir" do
|
70
|
-
it "can set the value" do
|
71
|
-
configuration.root_dir = "new dir"
|
72
|
-
expect(configuration.root_dir).to eql("new dir")
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
describe "#wip_limit" do
|
77
|
-
it "can set the value" do
|
78
|
-
configuration.wip_limit = 6
|
79
|
-
expect(configuration.wip_limit).to eql(6)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe "#wip_labels" do
|
84
|
-
it "can set the value" do
|
85
|
-
configuration.wip_labels = ['WIP']
|
86
|
-
expect(configuration.wip_labels).to eql(['WIP'])
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
describe "#repos" do
|
91
|
-
it "can set the value" do
|
92
|
-
configuration.repos << "repo path"
|
93
|
-
expect(configuration.repos).to eql([current_repo, "repo path"])
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe "#story_handler" do
|
98
|
-
it "can set the value" do
|
99
|
-
configuration.story_handler = :pivotal_start
|
100
|
-
expect(configuration.story_handler).to eql(:pivotal_start)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
describe "#validate_branch_name" do
|
105
|
-
it "can set the value" do
|
106
|
-
validate_branch_name = -> (branch_name) { /feature\/.*/ =~ branch_name }
|
107
|
-
configuration.validate_branch_name = validate_branch_name
|
108
|
-
expect(configuration.validate_branch_name).to eql(validate_branch_name)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
describe "#pull_request_handler" do
|
113
|
-
it "can set the value" do
|
114
|
-
configuration.pull_request_handler = :custom
|
115
|
-
expect(configuration.pull_request_handler).to eql(:custom)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
describe "#pull_request_body" do
|
120
|
-
it "can set the value" do
|
121
|
-
configuration.pull_request_body = "Startling Body"
|
122
|
-
expect(configuration.pull_request_body).to eql("Startling Body")
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
describe "#pull_request_commit_message" do
|
127
|
-
it "can set the value" do
|
128
|
-
configuration.pull_request_commit_message = "The Commit"
|
129
|
-
expect(configuration.pull_request_commit_message).to eql("The Commit")
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
describe "#pull_request_labels" do
|
134
|
-
it "can set the value" do
|
135
|
-
configuration.pull_request_labels = ["WIP", "REVIEW"]
|
136
|
-
expect(configuration.pull_request_labels).to eql(["WIP", "REVIEW"])
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
describe ".load_configuration" do
|
141
|
-
let(:git) { double(GitLocal) }
|
142
|
-
let(:config_files) {
|
143
|
-
{
|
144
|
-
caps: "Startlingfile.rb",
|
145
|
-
lower: "startlingfile.rb"
|
146
|
-
}
|
147
|
-
}
|
148
|
-
let(:caps_config_file) { "Startlingfile.rb" }
|
149
|
-
let(:lower_config_file) { "startlingfile.rb" }
|
150
|
-
|
151
|
-
before do
|
152
|
-
allow(Startling::GitLocal).to receive(:new) { git }
|
153
|
-
allow(git).to receive(:project_root) { Dir.pwd }
|
154
|
-
end
|
155
|
-
|
156
|
-
after do
|
157
|
-
config_files.each do |_, v|
|
158
|
-
delete_config_file(v)
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
context "when no configuration file exists" do
|
163
|
-
it "uses default configuration" do
|
164
|
-
expect(Configuration.load_configuration).to eql(nil)
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
context "when a configuration file exists" do
|
169
|
-
it "loads configuration from Startlingfile.rb" do
|
170
|
-
create_config_file(config_files[:caps])
|
171
|
-
expect(Configuration.load_configuration).to eql(config_files[:caps])
|
172
|
-
end
|
173
|
-
|
174
|
-
it "loads configuration from startlingfile.rb" do
|
175
|
-
create_config_file(config_files[:lower])
|
176
|
-
expect(Configuration.load_configuration).to eql(config_files[:lower])
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
def create_config_file(config_file)
|
182
|
-
File.open(config_file, "w")
|
183
|
-
end
|
184
|
-
|
185
|
-
def delete_config_file(config_file)
|
186
|
-
File.delete(config_file) if File.exists? config_file
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|