@@ -4,35 +4,47 @@ module PactBroker
4
4
module Matrix
5
5
describe ParseQuery do
6
6
describe ".call" do
7
- let ( :query ) { "q[][pacticipant]=Foo&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][version]=9.9.9" }
7
+ let ( :query ) { "q[][pacticipant]=Foo&q[][version]=1.2.3&q[][pacticipant]=Bar&q[][version]=9.9.9&success=true " }
8
8
9
9
subject { ParseQuery . call ( query ) }
10
10
11
11
it "extracts the pacticipant names and respective versions" do
12
- expect ( subject ) . to eq ( [ { pacticipant_name : "Foo" , pacticipant_version_number : "1.2.3" } , { pacticipant_name : "Bar" , pacticipant_version_number : "9.9.9" } ] )
12
+ expect ( subject . first ) . to eq ( [ { pacticipant_name : "Foo" , pacticipant_version_number : "1.2.3" } , { pacticipant_name : "Bar" , pacticipant_version_number : "9.9.9" } ] )
13
+ end
14
+
15
+ it "extracts the options" do
16
+ expect ( subject . last ) . to eq success : true
13
17
end
14
18
15
19
context "with spaces" do
16
20
let ( :query ) { "q[][pacticipant]=Name%20With%20Spaces&q[][version]=1%202" }
17
21
18
22
it "works" do
19
- expect ( subject ) . to eq [ { pacticipant_name : "Name With Spaces" , pacticipant_version_number : "1 2" } ]
23
+ expect ( subject . first ) . to eq [ { pacticipant_name : "Name With Spaces" , pacticipant_version_number : "1 2" } ]
20
24
end
21
25
end
22
26
23
27
context "with no q" do
24
28
let ( :query ) { "foo" }
25
29
26
30
it "returns an empty hash" do
27
- expect ( subject ) . to eq ( [ ] )
31
+ expect ( subject . first ) . to eq ( [ ] )
28
32
end
29
33
end
30
34
31
35
context "with an incorrect param names" do
32
36
let ( :query ) { "q[][wrong]=Foo&q[][blah]=1.2.3" }
33
37
34
38
it "returns nil keys or values" do
35
- expect ( subject ) . to eq [ { pacticipant_name : nil , pacticipant_version_number : nil } ]
39
+ expect ( subject . first ) . to eq [ { pacticipant_name : nil , pacticipant_version_number : nil } ]
40
+ end
41
+ end
42
+
43
+ context "with no options specified" do
44
+ let ( :query ) { "" }
45
+
46
+ it "does not set any options" do
47
+ expect ( subject . last ) . to eq ( { } )
36
48
end
37
49
end
38
50
end
0 commit comments