hq-engine 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
data/lib/hq/engine/rule-error.rb
CHANGED
@@ -6,10 +6,15 @@ class RuleError < RuntimeError
|
|
6
6
|
attr_accessor :file
|
7
7
|
attr_accessor :line
|
8
8
|
attr_accessor :column
|
9
|
-
attr_accessor :
|
9
|
+
attr_accessor :error
|
10
10
|
|
11
|
-
def
|
12
|
-
|
11
|
+
def initialize file, line, column, error
|
12
|
+
super "%s:%s:%s %s" % [
|
13
|
+
@file = file,
|
14
|
+
@line = line,
|
15
|
+
@column = column,
|
16
|
+
@error = error,
|
17
|
+
]
|
13
18
|
end
|
14
19
|
|
15
20
|
end
|
@@ -57,11 +57,12 @@ class Session
|
|
57
57
|
|
58
58
|
arguments = reply["arguments"]
|
59
59
|
|
60
|
-
exception =
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
60
|
+
exception =
|
61
|
+
RuleError.new \
|
62
|
+
arguments["file"],
|
63
|
+
arguments["line"],
|
64
|
+
arguments["column"],
|
65
|
+
arguments["error"]
|
65
66
|
|
66
67
|
raise exception
|
67
68
|
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require "hq/engine/subprocess-rule-provider/session"
|
2
|
+
|
3
|
+
module HQ
|
4
|
+
module Engine
|
5
|
+
class SubProcessRuleProvider
|
6
|
+
|
7
|
+
describe Session do
|
8
|
+
|
9
|
+
context "#compile_xquery" do
|
10
|
+
|
11
|
+
let(:client) { double "client" }
|
12
|
+
|
13
|
+
before do
|
14
|
+
|
15
|
+
dummy_reply = {
|
16
|
+
"name" => "ok",
|
17
|
+
"arguments" => {
|
18
|
+
"result text" => "result text",
|
19
|
+
},
|
20
|
+
}
|
21
|
+
|
22
|
+
client \
|
23
|
+
.stub(:perform)
|
24
|
+
.and_return(dummy_reply)
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
subject do
|
29
|
+
Session.new client, "session id"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "performs the request" do
|
33
|
+
|
34
|
+
expected_request = {
|
35
|
+
"name" => "compile xquery",
|
36
|
+
"arguments" => {
|
37
|
+
"session id" => "session id",
|
38
|
+
"xquery text" => "xquery text",
|
39
|
+
"xquery filename" => "xquery filename",
|
40
|
+
},
|
41
|
+
}
|
42
|
+
|
43
|
+
client \
|
44
|
+
.should_receive(:perform)
|
45
|
+
.with(expected_request)
|
46
|
+
|
47
|
+
subject.compile_xquery \
|
48
|
+
"xquery text",
|
49
|
+
"xquery filename"
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
context "on success" do
|
54
|
+
|
55
|
+
it "returns the result text" do
|
56
|
+
|
57
|
+
returned_value =
|
58
|
+
subject.compile_xquery \
|
59
|
+
"xquery text",
|
60
|
+
"xquery filename"
|
61
|
+
|
62
|
+
returned_value.should == "result text"
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
context "on error" do
|
69
|
+
|
70
|
+
it "throws an error" do
|
71
|
+
|
72
|
+
error_reply = {
|
73
|
+
"name" => "error",
|
74
|
+
"arguments" => {
|
75
|
+
"file" => "file",
|
76
|
+
"line" => "line",
|
77
|
+
"column" => "column",
|
78
|
+
"error" => "error",
|
79
|
+
},
|
80
|
+
}
|
81
|
+
|
82
|
+
client \
|
83
|
+
.stub(:perform)
|
84
|
+
.and_return(error_reply)
|
85
|
+
|
86
|
+
expect {
|
87
|
+
|
88
|
+
subject.compile_xquery \
|
89
|
+
"xquery text",
|
90
|
+
"xquery filename"
|
91
|
+
|
92
|
+
}.to raise_error(RuleError) {
|
93
|
+
|error|
|
94
|
+
|
95
|
+
error.file.should == "file"
|
96
|
+
error.line.should == "line"
|
97
|
+
error.column.should == "column"
|
98
|
+
error.error.should == "error"
|
99
|
+
|
100
|
+
error.message.should == "file:line:column error"
|
101
|
+
|
102
|
+
}
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hq-engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cucumber
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- lib/hq/engine/unlock-command.rb
|
108
108
|
- lib/hq/engine/transformer.rb
|
109
109
|
- lib/hq/engine/rule-error.rb
|
110
|
+
- spec/hq/engine/subprocess-rule-provider/session-spec.rb
|
110
111
|
- spec/hq/engine/transformer-spec.rb
|
111
112
|
homepage: https://github.com/jamespharaoh/hq-engine
|
112
113
|
licenses: []
|
@@ -133,4 +134,5 @@ signing_key:
|
|
133
134
|
specification_version: 3
|
134
135
|
summary: HQ engine
|
135
136
|
test_files:
|
137
|
+
- spec/hq/engine/subprocess-rule-provider/session-spec.rb
|
136
138
|
- spec/hq/engine/transformer-spec.rb
|