abak-flow 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -67,7 +67,7 @@ module Abak::Flow
67
67
  return I18n.t("commands.publish.nothing") if
68
68
  tasks_from_commit_message.empty? && !tracker_task?
69
69
 
70
- [tasks_from_commit_message, task].flatten.uniq
70
+ [tasks_from_commit_message, task].flatten.compact.uniq
71
71
  .map { |x| "http://jira.railsc.ru/browse/#{x}" } * "\n"
72
72
  end
73
73
 
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+ require "ansi/code"
2
3
 
3
4
  module Abak::Flow
4
5
  module Commands
@@ -1,6 +1,7 @@
1
1
  # coding: utf-8
2
2
  require "commander/blank"
3
3
  require "commander/command"
4
+ require "ansi/code"
4
5
 
5
6
  module Abak::Flow
6
7
  module Commands
@@ -1,5 +1,5 @@
1
1
  module Abak
2
2
  module Flow
3
- VERSION = "1.0.8"
3
+ VERSION = "1.0.9"
4
4
  end
5
5
  end
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+ require "ansi/code"
2
3
 
3
4
  module Abak::Flow
4
5
  class Visitor
@@ -48,7 +49,7 @@ module Abak::Flow
48
49
  def on_fail(options = Hash.new, &block)
49
50
  return if ready?
50
51
 
51
- say ANSI.red I18n.t("commands.#{@command}.fail")
52
+ say ANSI.red { I18n.t("commands.#{@command}.fail") }
52
53
  say ANSI.yellow { output }
53
54
 
54
55
  exit(options[:exit]) if options.key?(:exit)
@@ -212,12 +212,11 @@ describe Abak::Flow::Branch do
212
212
 
213
213
  before { git_feature.stub(:gcommit).and_return gcommit }
214
214
 
215
- it { expect(feature.extract_body).to include "http://jira.railsc.ru/browse/JP-515" }
216
- it { expect(feature.extract_body).to include "http://jira.railsc.ru/browse/PC4-200" }
215
+ it { expect(feature.extract_body).to eq "http://jira.railsc.ru/browse/PC4-200\nhttp://jira.railsc.ru/browse/JP-515" }
217
216
  end
218
217
 
219
218
  context "when branch is task equals to commit message" do
220
- let(:gcommit) { double("Git commit", contents: "Fix JP-515") }
219
+ let(:gcommit) { double("Git commit", contents: "[Fix JP-515]") }
221
220
 
222
221
  before { git_feature.stub(:gcommit).and_return gcommit }
223
222
 
@@ -225,13 +224,14 @@ describe Abak::Flow::Branch do
225
224
  end
226
225
 
227
226
  context "when branch is not task" do
228
- let(:gcommit) { double("Git commit", contents: "Fix PC4-200, PC5-111\n\nCloses PC2-1122") }
227
+ let(:gcommit) do
228
+ double("Git commit",
229
+ contents: "tree 077f77484213cd706ec6958dc7836d1c8d6aafe6\nparent 266a68fec47942a53a119c78ce74994372107d44\nauthor Strech (Sergey Fedorov) <strech_ftf@mail.ru> 1393176082 +0600\ncommitter Strech (Sergey Fedorov) <strech_ftf@mail.ru> 1393176094 +0600\n\nFIXME: Created example\n\nCloses PC4-12547")
230
+ end
229
231
 
230
232
  before { git_master.stub(:gcommit).and_return gcommit }
231
233
 
232
- it { expect(master.extract_body).to include "http://jira.railsc.ru/browse/PC4-200" }
233
- it { expect(master.extract_body).to include "http://jira.railsc.ru/browse/PC2-1122" }
234
- it { expect(master.extract_body).not_to include "PC5-111" }
234
+ it { expect(master.extract_body).to eq "http://jira.railsc.ru/browse/PC4-12547" }
235
235
  end
236
236
  end
237
237
  end
@@ -5,17 +5,13 @@ describe Abak::Flow::Commands::Checkup do
5
5
  let(:command) { described_class.new }
6
6
  let(:options) { double("Options") }
7
7
  let(:run) { command.run(Array.new, options) }
8
- let(:ansi) { double("ANSI") }
9
8
  let(:manager) do
10
9
  double("Manager", configuration: configuration,
11
10
  repository: repository)
12
11
  end
13
12
 
14
13
  before do
15
- stub_const('ANSI', ansi)
16
- ansi.stub(green: "Success")
17
- ansi.stub(red: "Fail")
18
- ansi.stub(yellow: "Warning")
14
+ I18n.stub(:t) { |args| args }
19
15
 
20
16
  Abak::Flow::Manager.stub(instance: manager)
21
17
  Abak::Flow::Visitor.any_instance.stub(:say) { |args| args }
@@ -26,7 +22,7 @@ describe Abak::Flow::Commands::Checkup do
26
22
  let(:repository) { double("Repository", ready?: true, errors: Array.new) }
27
23
  let(:configuration) { double("Configuration", ready?: true, errors: Array.new) }
28
24
 
29
- it { expect(run).to eq "Success" }
25
+ it { expect(run).to include "commands.checkup.success" }
30
26
  end
31
27
 
32
28
  context "when errors occurred" do
@@ -5,20 +5,19 @@ describe Abak::Flow::Commands::Compare do
5
5
  let(:command) { described_class.new }
6
6
  let(:options) { double("Options") }
7
7
  let(:run) { command.run(Array.new, options) }
8
- let(:ansi) { double("ANSI") }
9
8
  let(:git) { double("Git") }
9
+ let(:github) { double("Github", web_endpoint: "github.com") }
10
+ let(:master) { double("Master branch", name: "master", full: "master", to_s: "master") }
11
+ let(:develop) { double("Develop branch", name: "develop", full: "develop", to_s: "develop") }
12
+ let(:noname) { double("Noname branch", name: "noname", full: "noname", to_s: "noname") }
10
13
  let(:manager) do
11
14
  double("Manager", configuration: configuration,
12
- repository: repository, git: git)
15
+ repository: repository, git: git, github: github)
13
16
  end
14
17
 
15
18
  before do
16
- stub_const('ANSI', ansi)
17
- ansi.stub(green: "Success")
18
- ansi.stub(red: "Fail")
19
- ansi.stub(yellow: "Warning")
20
-
21
19
  git.stub(:branch) { |x| x }
20
+ I18n.stub(:t) { |args| args }
22
21
 
23
22
  Abak::Flow::Manager.stub(instance: manager)
24
23
  Abak::Flow::Visitor.any_instance.stub(:say) { |args| args }
@@ -34,14 +33,12 @@ describe Abak::Flow::Commands::Compare do
34
33
  end
35
34
 
36
35
  context "when no errors occurred" do
37
- let(:repository) { double("Repository", ready?: true, errors: Array.new, origin: origin) }
36
+ let(:repository) { double("Repository", ready?: true, errors: Array.new, origin: origin, upstream: upstream) }
38
37
  let(:configuration) { double("Configuration", ready?: true, errors: Array.new) }
39
- let(:origin) { double("Origin", repo: "origin-repo/flow") }
38
+ let(:origin) { double("Origin", repo: "origin-repo/flow", to_s: "origin-repo/flow") }
39
+ let(:upstream) { double("Upstream", owner: "User") }
40
40
 
41
41
  context "when only head/base is given" do
42
- let(:current_branch) { double("Current branch", name: "cur-br-name", full: "cur-br-name") }
43
- let(:master) { double("Master branch", name: "master", full: "master") }
44
-
45
42
  before do
46
43
  options.stub(head: master)
47
44
  options.stub(base: nil)
@@ -53,36 +50,26 @@ describe Abak::Flow::Commands::Compare do
53
50
  git.stub(current_branch: master)
54
51
  master.stub(current: true)
55
52
 
56
- expect(ansi).to receive(:white)
57
- expect(ansi).to receive(:green)
53
+ expect(git).to receive(:push).with("origin-repo/flow", master)
58
54
  end
59
55
 
60
- after { run }
61
-
62
- it { expect(git).to receive(:push).with("origin-repo/flow", master) }
56
+ it { expect(run).to include "github.com/origin-repo/flow/compare/User:master...master" }
63
57
  end
64
58
 
65
59
  context "when current branch is not master" do
66
60
  before do
67
- Abak::Flow::Branch.any_instance.stub(extract_base_name: current_branch)
68
- git.stub(current_branch: current_branch)
61
+ Abak::Flow::Branch.any_instance.stub(extract_base_name: noname)
62
+ git.stub(current_branch: noname)
69
63
  master.stub(current: false)
70
64
  end
71
65
 
72
66
  after { run }
73
67
 
74
- it do
75
- expect(ansi).to receive(:yellow)
76
- expect(ansi).to receive(:green)
77
- end
68
+ it { expect(run).to include "github.com/origin-repo/flow/compare/User:noname...master" }
78
69
  end
79
70
  end
80
71
 
81
72
  context "when head and base are given" do
82
- let(:current_branch) { double("Current branch") }
83
- let(:master) { double("Master branch", name: "master", full: "master") }
84
- let(:develop) { double("Develop branch", name: "develop", full: "develop") }
85
-
86
73
  before do
87
74
  options.stub(head: master)
88
75
  options.stub(base: develop)
@@ -90,16 +77,11 @@ describe Abak::Flow::Commands::Compare do
90
77
 
91
78
  context "when current branch is not head" do
92
79
  before do
93
- git.stub(current_branch: current_branch)
80
+ git.stub(current_branch: noname)
94
81
  master.stub(current: false)
95
82
  end
96
83
 
97
- after { run }
98
-
99
- it do
100
- expect(ansi).to receive(:yellow)
101
- expect(ansi).to receive(:green)
102
- end
84
+ it { expect(run).to include "github.com/origin-repo/flow/compare/User:develop...master" }
103
85
  end
104
86
 
105
87
  context "when current branch is head" do
@@ -107,13 +89,10 @@ describe Abak::Flow::Commands::Compare do
107
89
  git.stub(current_branch: master)
108
90
  master.stub(current: true)
109
91
 
110
- expect(ansi).to receive(:white)
111
- expect(ansi).to receive(:green)
92
+ expect(git).to receive(:push).with("origin-repo/flow", master)
112
93
  end
113
94
 
114
- after { run }
115
-
116
- it { expect(git).to receive(:push).with("origin-repo/flow", master) }
95
+ it { expect(run).to include "github.com/origin-repo/flow/compare/User:develop...master" }
117
96
  end
118
97
  end
119
98
  end
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: abak-flow
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.8
5
+ version: 1.0.9
6
6
  platform: ruby
7
7
  authors:
8
8
  - Strech (aka Sergey Fedorov)
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-24 00:00:00.000000000 Z
12
+ date: 2014-02-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: octokit