abak-flow 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,55 +0,0 @@
1
- # coding: utf-8
2
- require "spec_helper"
3
-
4
- describe Abak::Flow::Branch do
5
- let(:develop) { double("Branch", full: "develop") }
6
- let(:master) { double("Branch", full: "master") }
7
- let(:hotfix) { double("Branch", full: "hotfix/PR-2011") }
8
- let(:feature) { double("Branch", full: "feature/JP-515") }
9
- let(:noname) { double("Branch", full: "my_own/what_i_want/branch_name") }
10
-
11
- describe "#name" do
12
- it { described_class.new(feature).name.should eq "feature/JP-515" }
13
- it { described_class.new(develop).name.should eq "develop" }
14
- end
15
-
16
- describe "#prefix" do
17
- it { described_class.new(develop).prefix.should be_nil }
18
- it { described_class.new(hotfix).prefix.should eq "hotfix" }
19
- it { described_class.new(feature).prefix.should eq "feature" }
20
- it { described_class.new(noname).prefix.should eq "my_own/what_i_want" }
21
- end
22
-
23
- describe "#task" do
24
- it { described_class.new(develop).task.should be_nil }
25
- it { described_class.new(feature).task.should eq "JP-515" }
26
- it { described_class.new(noname).task.should eq "branch_name" }
27
- end
28
-
29
- describe "#hotfix?" do
30
- it { described_class.new(develop).hotfix?.should eq false }
31
- it { described_class.new(noname).hotfix?.should eq false }
32
- it { described_class.new(feature).hotfix?.should eq false }
33
- it { described_class.new(hotfix).hotfix?.should eq true }
34
- end
35
-
36
- describe "#feature?" do
37
- it { described_class.new(master).feature?.should eq false }
38
- it { described_class.new(noname).feature?.should eq false }
39
- it { described_class.new(hotfix).feature?.should eq false }
40
- it { described_class.new(feature).feature?.should eq true }
41
- end
42
-
43
- describe "#task?" do
44
- it { described_class.new(develop).task?.should eq false }
45
- it { described_class.new(noname).task?.should eq false }
46
- it { described_class.new(hotfix).task?.should eq true }
47
- it { described_class.new(feature).task?.should eq true }
48
- end
49
-
50
- describe "#tracker_task" do
51
- it { described_class.new(develop).tracker_task.should be_nil }
52
- it { described_class.new(feature).tracker_task.should eq "JP-515" }
53
- it { described_class.new(noname).tracker_task.should be_nil }
54
- end
55
- end
@@ -1,20 +0,0 @@
1
- # coding: utf-8
2
- require "spec_helper"
3
-
4
- describe Abak::Flow::Branches do
5
- describe "Interface" do
6
- subject { described_class }
7
-
8
- it { should respond_to :current_branch }
9
- end
10
-
11
- describe "#current_branch" do
12
- let(:branch) { double("Branch") }
13
- let(:git) { double("Git", current_branch: "my_branch", branches: {"my_branch" => branch}) }
14
-
15
- before { described_class.stub(:git).and_return git }
16
- subject { described_class.current_branch }
17
-
18
- it { should be_kind_of Abak::Flow::Branch }
19
- end
20
- end
@@ -1,73 +0,0 @@
1
- # coding: utf-8
2
- require "spec_helper"
3
-
4
- describe Abak::Flow::Configuration do
5
- let(:oauth_user) { "Admin" }
6
- let(:oauth_token) { "0123456789" }
7
- let(:proxy_server) { "http://www.super-proxy.net:4080/" }
8
- let(:environment) { "http://www.linux-proxy.net:6666/" }
9
- let(:instance) { described_class.clone.instance }
10
-
11
- let(:git) do
12
- double("Git Config", config: {
13
- "abak-flow.oauth-user" => oauth_user,
14
- "abak-flow.oauth-token" => oauth_token,
15
- "abak-flow.proxy-server" => proxy_server,
16
- "abak-flow.locale" => "ru"
17
- })
18
- end
19
-
20
- context "when all config elements missing" do
21
- let(:git) { double("Git Config", config: {}) }
22
-
23
- before do
24
- described_class.any_instance.stub(:environment_http_proxy).and_return nil
25
- described_class.any_instance.stub(:git).and_return git
26
- described_class.any_instance.stub(:setup_locale)
27
- end
28
-
29
- subject { instance.params }
30
-
31
- its(:oauth_user) { should be_nil }
32
- its(:oauth_token) { should be_nil }
33
- its(:proxy_server) { should be_nil }
34
- its(:locale) { should eq "en" }
35
- end
36
-
37
- context "when all config elements exists" do
38
- before do
39
- described_class.any_instance.stub(:environment_http_proxy).and_return nil
40
- described_class.any_instance.stub(:git).and_return git
41
- described_class.any_instance.stub(:setup_locale)
42
- end
43
-
44
- subject { instance.params }
45
-
46
- its(:oauth_user) { should eq "Admin" }
47
- its(:oauth_token) { should eq "0123456789" }
48
- its(:locale) { should eq "ru" }
49
- its(:proxy_server) { should eq "http://www.super-proxy.net:4080/" }
50
- end
51
-
52
- context "when various proxy server set" do
53
- before do
54
- described_class.any_instance.stub(:git).and_return git
55
- described_class.any_instance.stub(:setup_locale)
56
- end
57
-
58
- subject { instance.params.proxy_server }
59
-
60
- context "when ENV and git config setup proxy server" do
61
- before { described_class.any_instance.stub(:environment_http_proxy).and_return environment }
62
-
63
- it { should eq "http://www.super-proxy.net:4080/" }
64
- end
65
-
66
- context "when only ENV setup proxy server" do
67
- before { described_class.any_instance.stub(:environment_http_proxy).and_return environment }
68
- before { git.stub(:config).and_return({}) }
69
-
70
- it { should eq "http://www.linux-proxy.net:6666/" }
71
- end
72
- end
73
- end
@@ -1,12 +0,0 @@
1
- # coding: utf-8
2
- require "spec_helper"
3
-
4
- describe Abak::Flow::Git do
5
- subject { described_class.clone.instance }
6
-
7
- describe "Interface" do
8
- it { should respond_to :git }
9
- it { should respond_to :command }
10
- it { should respond_to :command_lines }
11
- end
12
- end
@@ -1,15 +0,0 @@
1
- # coding: utf-8
2
- require "spec_helper"
3
-
4
- describe Abak::Flow::GithubClient do
5
- let(:instance) { described_class.clone.instance }
6
-
7
- describe "#connection" do
8
- let(:options) { {login: "login", password: "password"} }
9
-
10
- before { described_class.any_instance.stub(:connection_options).and_return options }
11
- after { instance.connection }
12
-
13
- it { Octokit::Client.should_receive(:new).with({login: "login", password: "password"}) }
14
- end
15
- end
@@ -1,146 +0,0 @@
1
- # coding: utf-8
2
- require "spec_helper"
3
-
4
- describe Abak::Flow::Messages do
5
- let(:messages) { Abak::Flow::Messages.new "my_scope" }
6
- subject { messages }
7
-
8
- describe "Interface" do
9
- it { should respond_to :each }
10
- it { should respond_to :push }
11
- it { should respond_to :<< }
12
- it { should respond_to :to_s }
13
- it { should respond_to :header }
14
- it { should respond_to :print }
15
- it { should respond_to :pretty_print }
16
- it { should respond_to :pp }
17
- it { should respond_to :empty? }
18
- it { should respond_to :translate }
19
- it { should respond_to :t }
20
- end
21
-
22
- describe "Public methods" do
23
- describe "#header" do
24
- before { I18n.should_receive(:t).with(:header, scope: "my_scope").and_return "+HEADER+" }
25
- subject { messages.header}
26
-
27
- it { should eq "+HEADER+" }
28
- end
29
-
30
- describe "#push" do
31
- context "when no elements pushed" do
32
- its(:elements) { should be_empty }
33
- end
34
-
35
- context "when push only one element" do
36
- before { messages.push :hello }
37
-
38
- its(:elements) { should eq [:hello] }
39
- end
40
-
41
- context "when push more than one element" do
42
- before { messages.push :hello }
43
- before { messages.push :world }
44
-
45
- its(:elements) { should eq [:hello, :world] }
46
- end
47
- end
48
-
49
- describe "#each" do
50
- context "when no block given" do
51
- it { expect { messages.each }.to raise_error ArgumentError }
52
- end
53
-
54
- context "when block given" do
55
- before do
56
- messages.push :hello
57
- messages.push :linux
58
-
59
- I18n.should_receive(:t).with(:linux, scope: "my_scope").and_return "linux_t"
60
- I18n.should_receive(:t).with(:hello, scope: "my_scope").and_return "hello_t"
61
- end
62
-
63
- it { expect { |b| messages.each(&b) }.to yield_successive_args("hello_t", "linux_t") }
64
- end
65
- end
66
-
67
- describe "#to_s" do
68
- subject { messages.to_s }
69
-
70
- context "when messages are empty" do
71
- it { should be_empty }
72
- end
73
-
74
- context "when messages are not empty" do
75
- before do
76
- messages.push :hello
77
- messages.push :linux
78
-
79
- I18n.should_receive(:t).with(:linux, scope: "my_scope").and_return "linux_t"
80
- I18n.should_receive(:t).with(:hello, scope: "my_scope").and_return "hello_t"
81
- end
82
-
83
- it { should include "hello_t" }
84
- it { should include "linux_t" }
85
- end
86
- end
87
-
88
- describe "#pretty_print" do
89
- subject { messages.pp }
90
-
91
- context "when messages are empty" do
92
- it { should be_empty }
93
- end
94
-
95
- context "when messages are not empty" do
96
- before do
97
- messages.push :hello
98
- messages.push :linux
99
-
100
- I18n.should_receive(:t).with(:header, scope: "my_scope").and_return "+HEADER+"
101
- I18n.should_receive(:t).with(:linux, scope: "my_scope").and_return "linux_t"
102
- I18n.should_receive(:t).with(:hello, scope: "my_scope").and_return "hello_t"
103
- end
104
-
105
- it { should include "hello_t" }
106
- it { should include "linux_t" }
107
- it { should include "+HEADER+" }
108
- end
109
- end
110
-
111
- describe "#translate" do
112
- context "when translate from current scope" do
113
- before { I18n.should_receive(:t).with(:word, scope: "my_scope").and_return "WORD" }
114
- subject { messages.t :word }
115
-
116
- it { should eq "WORD" }
117
- end
118
-
119
- context "when translate from different scope" do
120
- before { I18n.should_receive(:t).with(:hello, scope: "diff_scope").and_return "HELLO" }
121
- subject { messages.t :hello, {scope: "diff_scope"} }
122
-
123
- it { should eq "HELLO" }
124
- end
125
- end
126
-
127
- describe "#purge!" do
128
- context "when message have elements" do
129
- before { messages.push :hello }
130
- before { messages.push :linux }
131
- before { messages.purge! }
132
-
133
- subject { messages }
134
-
135
- it { should be_empty }
136
- end
137
-
138
- context "when message have no elements" do
139
- before { messages.purge! }
140
- subject { messages }
141
-
142
- it { should be_empty }
143
- end
144
- end
145
- end
146
- end
@@ -1,52 +0,0 @@
1
- # coding: utf-8
2
- require "spec_helper"
3
-
4
- describe Abak::Flow::Project do
5
- let(:origin) { double("Origin", name: "origin", url: "git@github.com:Strech/abak-flow.git") }
6
- let(:upstream) { double("Upstream", name: "upstream", url: "http://github.com/Godlike/abak-flow-new.git") }
7
- let(:git) { double("Git", remotes: [origin, upstream]) }
8
- let(:instance) { Abak::Flow::Project.clone.instance }
9
-
10
- context "when initialize project with two remote repositories" do
11
- before { Abak::Flow::Project.any_instance.stub(:git).and_return git }
12
-
13
- subject { instance.remotes }
14
-
15
- it { should have_key :origin }
16
- it { should have_key :upstream }
17
- end
18
-
19
- context "when initialize project with some wrong repositories" do
20
- let(:wrong) { double("Wrong", name: "wrong", url: "git@wrong-site.com:Me/wrong-flow.git") }
21
- let(:git) { double("Git", remotes: [origin, wrong]) }
22
-
23
- before { Abak::Flow::Project.any_instance.stub(:git).and_return git }
24
-
25
- subject { instance.remotes }
26
-
27
- it { should have_key :origin }
28
- it { should_not have_key :upstream }
29
- end
30
-
31
- describe "#Remote" do
32
- before { Abak::Flow::Project.any_instance.stub(:git).and_return git }
33
-
34
- describe "#origin" do
35
- subject { instance.remotes[:origin] }
36
-
37
- its(:owner) { should eq "Strech" }
38
- its(:project) { should eq "abak-flow" }
39
- its(:repo) { should eq origin }
40
- its(:to_s) { should eq "Strech/abak-flow" }
41
- end
42
-
43
- describe "#upstream" do
44
- subject { instance.remotes[:upstream] }
45
-
46
- its(:owner) { should eq "Godlike" }
47
- its(:project) { should eq "abak-flow-new" }
48
- its(:repo) { should eq upstream }
49
- its(:to_s) { should eq "Godlike/abak-flow-new" }
50
- end
51
- end
52
- end