pra 1.6.0 → 1.7.0

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.
@@ -1,161 +0,0 @@
1
- require_relative "../../../lib/pra/stash_pull_source"
2
-
3
- describe Pra::StashPullSource do
4
- describe "#pull_requests" do
5
- it "gets all the repositories" do
6
- subject.should_receive(:repositories).and_return([])
7
- subject.pull_requests
8
- end
9
-
10
- it "gets the pull requests for each repository" do
11
- config = {
12
- "protocol" => "https",
13
- "host" => "my.stash.instance",
14
- "username" => "foo",
15
- "password" => "bar",
16
- "repositories" => [
17
- { "project_slug" => "CAP", "repository_slug" => "capture_api" }
18
- ]
19
- }
20
- pull_source = Pra::StashPullSource.new(config)
21
- pull_source.should_receive(:get_repo_pull_requests).with({ "project_slug" => "CAP", "repository_slug" => "capture_api" }).and_return([])
22
- pull_source.pull_requests
23
- end
24
-
25
- it "returns the collection of all of the pull requests for the configured repos" do
26
- config = {
27
- "protocol" => "https",
28
- "host" => "my.stash.instance",
29
- "username" => "foo",
30
- "password" => "bar",
31
- "repositories" => [
32
- { "project_slug" => "CAP", "repository_slug" => "capture_api" },
33
- { "project_slug" => "CAP", "repository_slug" => "capture_crawler_api" }
34
- ]
35
- }
36
- pull_request_one = double('pull request one')
37
- pull_request_two = double('pull request two')
38
- pull_source = Pra::StashPullSource.new(config)
39
- pull_source.stub(:get_repo_pull_requests).with({ "project_slug" => "CAP", "repository_slug" => "capture_api" }).and_return([pull_request_one])
40
- pull_source.stub(:get_repo_pull_requests).with({ "project_slug" => "CAP", "repository_slug" => "capture_crawler_api" }).and_return([pull_request_two])
41
- pull_source.pull_requests.should eq([pull_request_one, pull_request_two])
42
- end
43
- end
44
-
45
- describe "#repositories" do
46
- it "returns the repositories segment of the config" do
47
- config = {
48
- "protocol" => "https",
49
- "host" => "my.stash.instance",
50
- "username" => "foo",
51
- "password" => "bar",
52
- "repositories" => [
53
- { "project_slug" => "CAP", "repository_slug" => "capture_api" }
54
- ]
55
- }
56
- pull_source = Pra::StashPullSource.new(config)
57
- pull_source.repositories.should eq([{ "project_slug" => "CAP", "repository_slug" => "capture_api" }])
58
- end
59
- end
60
-
61
- describe "#get_repo_pull_requests" do
62
- it "requests the pull requests for the given repo" do
63
- config = {
64
- "protocol" => "https",
65
- "host" => "my.stash.instance",
66
- "username" => "foo",
67
- "password" => "bar",
68
- "repositories" => [
69
- { "project_slug" => "CAP", "repository_slug" => "capture_api" }
70
- ]
71
- }
72
- pull_source = Pra::StashPullSource.new(config)
73
- pull_source.stub(:rest_api_pull_request_resource).with({ "project_slug" => "CAP", "repository_slug" => "capture_api" }).and_return('{ "values": [] }')
74
- pull_source.get_repo_pull_requests({ "project_slug" => "CAP", "repository_slug" => "capture_api" })
75
- end
76
- end
77
-
78
- describe "#rest_api_pull_request_url" do
79
- context "when config is for a user repository" do
80
- let(:config) do
81
- {
82
- "protocol" => "https",
83
- "host" => "my.stash.instance",
84
- "username" => "foo",
85
- "password" => "bar",
86
- "repositories" => [
87
- { "user_slug" => "andrew.deponte", "repository_slug" => "capture_api" }
88
- ]
89
- }
90
- end
91
-
92
- it "returns the user pull request url compiled from the config options" do
93
- pull_source = Pra::StashPullSource.new(config)
94
- expect(pull_source.rest_api_pull_request_url({ "user_slug" => "andrew.deponte", "repository_slug" => "capture_api" })).to eq("https://my.stash.instance/rest/api/1.0/users/andrew.deponte/repos/capture_api/pull-requests")
95
- end
96
- end
97
-
98
- context "when config is for a project repository" do
99
- let(:config) do
100
- {
101
- "protocol" => "https",
102
- "host" => "my.stash.instance",
103
- "username" => "foo",
104
- "password" => "bar",
105
- "repositories" => [
106
- { "project_slug" => "CAP", "repository_slug" => "capture_api" }
107
- ]
108
- }
109
- end
110
-
111
- it "returns the project pull request url compiled from the config options" do
112
- pull_source = Pra::StashPullSource.new(config)
113
- pull_source.rest_api_pull_request_url({ "project_slug" => "CAP", "repository_slug" => "capture_api" }).should eq("https://my.stash.instance/rest/api/1.0/projects/CAP/repos/capture_api/pull-requests")
114
- end
115
- end
116
- end
117
-
118
- describe "#rest_api_pull_request_resource" do
119
- let(:config) do
120
- {
121
- "protocol" => "https",
122
- "host" => "my.stash.instance",
123
- "username" => "foo",
124
- "password" => "bar",
125
- "repositories" => [
126
- { "project_slug" => "CAP", "repository_slug" => "capture_api" }
127
- ]
128
- }
129
- end
130
-
131
- let(:repo_config) { {"project_slug" => "CAP", "repository_slug" => "capture_api"} }
132
-
133
- subject { Pra::StashPullSource.new(config) }
134
-
135
- it "creates a Faraday connection" do
136
- expect(Faraday).to receive(:new).and_return(double.as_null_object)
137
- subject.rest_api_pull_request_resource(repo_config)
138
- end
139
-
140
- it "set the http basic auth credentials" do
141
- conn = double('faraday connection').as_null_object
142
- allow(Faraday).to receive(:new).and_return(conn)
143
- expect(conn).to receive(:basic_auth).with("foo", "bar")
144
- subject.rest_api_pull_request_resource(repo_config)
145
- end
146
-
147
- it "makes request using faraday connection" do
148
- conn = double('faraday connection').as_null_object
149
- allow(Faraday).to receive(:new).and_return(conn)
150
- expect(conn).to receive(:get)
151
- subject.rest_api_pull_request_resource(repo_config)
152
- end
153
-
154
- it "returns the responses body" do
155
- conn = double('faraday connection').as_null_object
156
- allow(Faraday).to receive(:new).and_return(conn)
157
- expect(conn).to receive(:get).and_return(double('response', body: 'hoopytbody'))
158
- expect(subject.rest_api_pull_request_resource(repo_config)).to eq('hoopytbody')
159
- end
160
- end
161
- end
@@ -1,13 +0,0 @@
1
- require_relative '../../../lib/pra/window_system_factory'
2
-
3
- describe Pra::WindowSystemFactory do
4
- describe ".build" do
5
- it "constructs a CursesWindowSystem given a curses window system id 'curses'" do
6
- expect(subject.build('curses')).to be_a(Pra::CursesWindowSystem)
7
- end
8
-
9
- it "raises an exception when given an window system id it doesn't understand" do
10
- expect{ subject.build('some_unknown_window_system_id') }.to raise_error(Pra::WindowSystemFactory::UnknownWindowSystemId)
11
- end
12
- end
13
- end
@@ -1,33 +0,0 @@
1
- require_relative "../../../lib/pra/window_system"
2
-
3
- describe Pra::WindowSystem do
4
- describe "#setup" do
5
- it "raises a message stating that the pure virtual method has not been implemented" do
6
- expect { subject.setup }.to raise_error(Pra::WindowSystem::PureVirtualMethodNotImplemented)
7
- end
8
- end
9
-
10
- describe "#fetching_pull_requests" do
11
- it "raises a message stating that the pure virtual method has not been implemented" do
12
- expect { subject.fetching_pull_requests }.to raise_error(Pra::WindowSystem::PureVirtualMethodNotImplemented)
13
- end
14
- end
15
-
16
- describe "#fetch_failed" do
17
- it "raises a message stating that the pure virtual method has not been implemented" do
18
- expect { subject.fetch_failed }.to raise_error(Pra::WindowSystem::PureVirtualMethodNotImplemented)
19
- end
20
- end
21
-
22
- describe "#refresh_pull_requests" do
23
- it "raises a message stating that the pure virtual method has not been implemented" do
24
- expect { subject.refresh_pull_requests(double('pull requests')) }.to raise_error(Pra::WindowSystem::PureVirtualMethodNotImplemented)
25
- end
26
- end
27
-
28
- describe "#run_loop" do
29
- it "raises a message stating that the pure virtual method has not been implemented" do
30
- expect { subject.run_loop }.to raise_error(Pra::WindowSystem::PureVirtualMethodNotImplemented)
31
- end
32
- end
33
- end
data/spec/spec_helper.rb DELETED
File without changes