startling 0.0.8 → 0.0.9

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f8ebd457be41e100906ba33b538480973d89730b
4
- data.tar.gz: dfba30c257a91102ca69b3b75ec5b4a74aecc234
3
+ metadata.gz: a8af8796ba134784e1a43a9cc6afe4206089989b
4
+ data.tar.gz: cd4fd0ad6d0a46f235acad5d66c1721cafb3cac0
5
5
  SHA512:
6
- metadata.gz: 26f56b3a79cd2fd4e2ef22bc61266b2cae468248e221a75b982a3bdb57ba7d12e3818eeb8448bad34dd5002efe9aa24613ba2073c6aba45584db1bd6896f32ee
7
- data.tar.gz: 2b6378cc90dd4ad98a3af97af04ac3b2317cb831e3dbccb3ebc6ab041ca3fbc3354b2fd08b09c0b182cfc2938f6939509d3c5a38cfe61a4ffd2108c311e5662d
6
+ metadata.gz: f9d77f0b239694944fca9d5cfbeb415d370c81952c23a262adecfbb7fac3839378c2ccdb10f695db4297dccf083f32ddd83fdbf35013067b7a26d8a327317b87
7
+ data.tar.gz: a13542fc2890aa0f63a873b1c6d69a72e0eb7e469105012f7e4c68cb4ad0cc3a98963587f66ddbfebbc3511b84a65c9b139fb00ff7630da204f134fa6f8306f9
@@ -2,6 +2,7 @@ require 'cgi'
2
2
  require 'json'
3
3
  require 'highline/import'
4
4
  require 'shellwords'
5
+ require_relative "story"
5
6
  require_relative "commands/base"
6
7
  require_relative 'commands/check_for_local_mods'
7
8
  require_relative 'commands/create_pull_request'
@@ -1,21 +1,36 @@
1
+ require 'highline/import'
1
2
  require_relative "pull_request_handler_base"
2
3
 
3
4
  module Startling
4
5
  module Handlers
5
6
  class DefaultPullRequestHandler < PullRequestHandlerBase
6
7
  def title
7
- title = ask("Please input a pull request title: ")
8
+ title = get_title
8
9
  abort "Title must be specified." if title.empty?
9
10
  title
10
11
  end
11
12
 
12
13
  def body
13
- Startling.pull_request_body
14
+ (story) ? story.pull_request_body_text : Startling.pull_request_body
14
15
  end
15
16
 
16
17
  def commit_message
17
18
  Startling.pull_request_commit_message
18
19
  end
20
+
21
+ private
22
+
23
+ def get_title
24
+ if story
25
+ story.pull_request_title
26
+ else
27
+ title = ask("Please input a pull request title: ")
28
+ end
29
+ end
30
+
31
+ def story
32
+ @story ||= @args.fetch(:story)
33
+ end
19
34
  end
20
35
  end
21
36
  end
@@ -0,0 +1,11 @@
1
+ module Startling
2
+ class Story
3
+ def pull_request_title
4
+ raise NotImplementedError
5
+ end
6
+
7
+ def pull_request_body_text
8
+ raise NotImplementedError
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module Startling
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+ require 'startling/handlers/default_pull_request_handler'
3
+
4
+ describe Startling::Handlers::DefaultPullRequestHandler do
5
+ let(:args) { { story: nil } }
6
+ subject { Startling::Handlers::DefaultPullRequestHandler.new(args) }
7
+
8
+ it 'returns the commit message for empty commit' do
9
+ commit_message = 'Commit message'
10
+
11
+ allow(Startling).to receive(:pull_request_commit_message) { commit_message }
12
+
13
+ expect(subject.commit_message).to eq(commit_message)
14
+ end
15
+
16
+ context 'with story' do
17
+ let(:story) {
18
+ double(:story,
19
+ pull_request_title: 'Story title',
20
+ pull_request_body_text: 'Story url'
21
+ )
22
+ }
23
+ let(:args) { { story: story } }
24
+
25
+ it 'returns the story pull request title' do
26
+ expect(subject.title).to eq(story.pull_request_title)
27
+ end
28
+
29
+ it 'returns the story pull request body' do
30
+ expect(subject.body).to eq(story.pull_request_body_text)
31
+ end
32
+ end
33
+
34
+ context 'without story' do
35
+ it 'prompts for pull request title' do
36
+ title = 'Entered title'
37
+
38
+ allow_any_instance_of(Startling::Handlers::DefaultPullRequestHandler)
39
+ .to receive(:ask) { title }
40
+
41
+ expect(subject.title).to eq(title)
42
+ end
43
+
44
+ it 'returns the pull request body from configuration' do
45
+ body = 'Configured body'
46
+
47
+ allow(Startling).to receive(:pull_request_body) { body }
48
+
49
+ expect(subject.body).to eq(body)
50
+ end
51
+ end
52
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: startling
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Jensen
@@ -246,6 +246,7 @@ files:
246
246
  - lib/startling/handlers/pull_request_handler_base.rb
247
247
  - lib/startling/markdown.rb
248
248
  - lib/startling/shell.rb
249
+ - lib/startling/story.rb
249
250
  - lib/startling/time_format_helpers.rb
250
251
  - lib/startling/version.rb
251
252
  - lib/startling/work.rb
@@ -258,6 +259,7 @@ files:
258
259
  - spec/startling/configuration_spec.rb
259
260
  - spec/startling/git_local_spec.rb
260
261
  - spec/startling/github/pull_request_spec.rb
262
+ - spec/startling/handlers/default_pull_request_handler_spec.rb
261
263
  - spec/startling/time_format_helpers_spec.rb
262
264
  - spec/startling_configuration_spec.rb
263
265
  - spec/startling_spec.rb
@@ -300,6 +302,7 @@ test_files:
300
302
  - spec/startling/configuration_spec.rb
301
303
  - spec/startling/git_local_spec.rb
302
304
  - spec/startling/github/pull_request_spec.rb
305
+ - spec/startling/handlers/default_pull_request_handler_spec.rb
303
306
  - spec/startling/time_format_helpers_spec.rb
304
307
  - spec/startling_configuration_spec.rb
305
308
  - spec/startling_spec.rb