ruby_tfs 0.0.1 → 0.0.2
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.
- data/README.md +3 -0
- data/lib/tfs/builds.rb +5 -1
- data/lib/tfs/queryable.rb +2 -0
- data/ruby_tfs.gemspec +1 -1
- data/spec/fixtures/cassettes/builds.yml +46 -0
- data/spec/fixtures/cassettes/project_changesets.yml +398 -0
- data/spec/fixtures/cassettes/project_workitems.yml +793 -0
- data/spec/fixtures/cassettes/project_workitems_queries.yml +439 -308
- data/spec/spec_helper.rb +3 -1
- data/spec/tfs/builds_spec.rb +4 -0
- data/spec/tfs/client_spec.rb +24 -1
- data/spec/tfs/query_engine_spec.rb +54 -5
- metadata +6 -2
data/spec/spec_helper.rb
CHANGED
@@ -3,13 +3,15 @@ require 'vcr'
|
|
3
3
|
require 'simplecov'
|
4
4
|
require 'pry'
|
5
5
|
|
6
|
-
require_relative "../lib/tfs"
|
7
6
|
|
8
7
|
SimpleCov.start do
|
9
8
|
add_filter "spec/"
|
10
9
|
add_filter ".gems/"
|
11
10
|
end
|
12
11
|
|
12
|
+
require_relative "../lib/tfs"
|
13
|
+
|
14
|
+
|
13
15
|
VCR.configure do |config|
|
14
16
|
config.cassette_library_dir = 'spec/fixtures/cassettes'
|
15
17
|
config.hook_into :webmock
|
data/spec/tfs/builds_spec.rb
CHANGED
@@ -23,6 +23,10 @@ describe TFS::Builds do
|
|
23
23
|
results.count.should == 0
|
24
24
|
end
|
25
25
|
|
26
|
+
it "can get a specific build" do
|
27
|
+
expect { TFS::Builds.find('rubytfs_demo', 'rubytfs', 1) }.to raise_error(TFS::Queryable::RecordNotFound)
|
28
|
+
end
|
29
|
+
|
26
30
|
it "can query in the raw" do
|
27
31
|
results = TFS::Builds.odata_query("Status eq 'Succeeded'").limit(5).run
|
28
32
|
results.each do |build|
|
data/spec/tfs/client_spec.rb
CHANGED
@@ -39,16 +39,39 @@ describe TFS::Client do
|
|
39
39
|
project.size.should == 1
|
40
40
|
project.first.Name.should == "rubytfs"
|
41
41
|
end
|
42
|
+
|
43
|
+
it "can execute queries" do
|
44
|
+
client.projects("rubytfs")
|
45
|
+
projects = client.run
|
46
|
+
|
47
|
+
projects.size.should == 1
|
48
|
+
projects.first.Name.should == "rubytfs"
|
49
|
+
end
|
50
|
+
|
42
51
|
end
|
43
52
|
|
44
53
|
context "sub queries" do
|
45
|
-
use_vcr_cassette "
|
54
|
+
use_vcr_cassette "project_changesets"
|
46
55
|
|
47
56
|
before do
|
48
57
|
client.connect
|
49
58
|
end
|
50
59
|
|
51
60
|
it "can traverse/filter by sub items (children)" do
|
61
|
+
changesets = client.projects('rubytfs').changesets.run
|
62
|
+
changesets.count.should == 2
|
63
|
+
changesets.first.should be_a Changeset
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context "special cases" do
|
68
|
+
use_vcr_cassette "project_workitems"
|
69
|
+
|
70
|
+
before do
|
71
|
+
client.connect
|
72
|
+
end
|
73
|
+
|
74
|
+
it "can traverse special case classes" do
|
52
75
|
work_items = client.projects('rubytfs').workitems.run
|
53
76
|
work_items.count.should == 19
|
54
77
|
work_items.first.should be_a WorkItem
|
@@ -5,15 +5,20 @@ describe TFS::QueryEngine do
|
|
5
5
|
class TFS::Builds; end
|
6
6
|
let(:native_query) { flexmock(:queryable) }
|
7
7
|
let(:conn) { flexmock(:connection, "Builds" => native_query) }
|
8
|
+
let(:query) { TFS::QueryEngine.new(TFS::Builds, conn) }
|
8
9
|
|
9
10
|
it "raises an error if we try to create a query for a bad object" do
|
10
11
|
expect { TFS::QueryEngine.new(String, conn) }.to raise_error(TypeError, /String is not/)
|
11
12
|
expect { TFS::QueryEngine.new(TFS::Builds, conn) }.to_not raise_error
|
12
13
|
end
|
13
14
|
|
14
|
-
it "can
|
15
|
-
|
15
|
+
it "can query in the raw" do
|
16
|
+
native_query.should_receive(:filter).with("Sup my homies")
|
17
|
+
|
18
|
+
query.raw.filter("Sup my homies")
|
19
|
+
end
|
16
20
|
|
21
|
+
it "can chain queries" do
|
17
22
|
native_query.should_receive(:top).with(10).and_return(native_query).once
|
18
23
|
native_query.should_receive(:order_by).with("Reason").and_return(native_query).once
|
19
24
|
|
@@ -21,17 +26,61 @@ describe TFS::QueryEngine do
|
|
21
26
|
end
|
22
27
|
|
23
28
|
it "can include other results" do
|
24
|
-
query = TFS::QueryEngine.new(TFS::Builds, conn)
|
25
29
|
native_query.should_receive(:expand).with('Changesets').and_return(native_query).once
|
26
30
|
|
27
31
|
query.include(TFS::Changesets)
|
28
32
|
end
|
29
33
|
|
30
34
|
it "raises error if expand by invalid class" do
|
31
|
-
query = TFS::QueryEngine.new(TFS::Builds, conn)
|
32
|
-
|
33
35
|
expect { query.include('String') }.to raise_error(TypeError)
|
34
36
|
|
35
37
|
native_query.should_not have_received(:expand)
|
36
38
|
end
|
39
|
+
|
40
|
+
it "can cause pagination" do
|
41
|
+
native_query.should_receive(:skip).with(10)
|
42
|
+
query.page(10)
|
43
|
+
end
|
44
|
+
|
45
|
+
context "with real odata" do
|
46
|
+
let(:query) { TFS::QueryEngine.new(TFS::Builds, TFS.client) }
|
47
|
+
|
48
|
+
it "can send count" do
|
49
|
+
native_query.should_receive(:filter).pass_thru
|
50
|
+
native_query.should_receive(:count)
|
51
|
+
|
52
|
+
query.where("Something eq test").count
|
53
|
+
end
|
54
|
+
|
55
|
+
it "can print the proposed query" do
|
56
|
+
native_query.should_receive(:filter).pass_thru
|
57
|
+
native_query.should_receive(:skip).with(10).pass_thru
|
58
|
+
|
59
|
+
query_string = query.where("Something eq 'test'").page(10).to_query
|
60
|
+
query_string.should == "/Builds('')?$filter=Something+eq+%27test%27&$skip=10"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context "normalize" do
|
65
|
+
it "strings" do
|
66
|
+
val = query.send :normalize, ["hello world"]
|
67
|
+
val.should == "'hello world'"
|
68
|
+
end
|
69
|
+
|
70
|
+
it "arrays" do
|
71
|
+
val = query.send :normalize, [["twitter", "facebook"]]
|
72
|
+
val.should == "'twitter','facebook'"
|
73
|
+
end
|
74
|
+
|
75
|
+
it "hashes" do
|
76
|
+
val = query.send :normalize, [{coke: "jack", salt: "vinegar", "something" => "fake"}]
|
77
|
+
val.should == "Coke='jack',Salt='vinegar',Something='fake'"
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'anything else' do
|
81
|
+
val = query.send :normalize, [1]
|
82
|
+
val.should == 1
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
37
86
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_tfs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -67,6 +67,8 @@ files:
|
|
67
67
|
- spec/fixtures/cassettes/builds.yml
|
68
68
|
- spec/fixtures/cassettes/changeset_queries.yml
|
69
69
|
- spec/fixtures/cassettes/changesets.yml
|
70
|
+
- spec/fixtures/cassettes/project_changesets.yml
|
71
|
+
- spec/fixtures/cassettes/project_workitems.yml
|
70
72
|
- spec/fixtures/cassettes/project_workitems_queries.yml
|
71
73
|
- spec/fixtures/cassettes/projects.yml
|
72
74
|
- spec/fixtures/cassettes/workitems.yml
|
@@ -93,7 +95,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
95
|
version: '0'
|
94
96
|
segments:
|
95
97
|
- 0
|
96
|
-
hash:
|
98
|
+
hash: 1497286173893304256
|
97
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
100
|
none: false
|
99
101
|
requirements:
|
@@ -110,6 +112,8 @@ test_files:
|
|
110
112
|
- spec/fixtures/cassettes/builds.yml
|
111
113
|
- spec/fixtures/cassettes/changeset_queries.yml
|
112
114
|
- spec/fixtures/cassettes/changesets.yml
|
115
|
+
- spec/fixtures/cassettes/project_changesets.yml
|
116
|
+
- spec/fixtures/cassettes/project_workitems.yml
|
113
117
|
- spec/fixtures/cassettes/project_workitems_queries.yml
|
114
118
|
- spec/fixtures/cassettes/projects.yml
|
115
119
|
- spec/fixtures/cassettes/workitems.yml
|