Skip to content

Commit

Permalink
Eliminated the evil trailing comma.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob Aman committed Jul 21, 2012
1 parent bcf255d commit cf04765
Showing 1 changed file with 32 additions and 31 deletions.
63 changes: 32 additions & 31 deletions spec/addressable/template_spec.rb
Expand Up @@ -43,7 +43,7 @@
context "Operator #:" do
it_behaves_like 'expands', {
'X{#var}' => 'X#value',
'X{#hello}' => 'X#Hello%20World!',
'X{#hello}' => 'X#Hello%20World!'
}
end
end
Expand All @@ -68,46 +68,47 @@
context "Operator + (multiple vars):" do
it_behaves_like 'expands', {
'{+x,hello,y}' => '1024,Hello%20World!,768',
'{+path,x}/here' => '/foo/bar,1024/here',
'{+path,x}/here' => '/foo/bar,1024/here'
}
end
context "Operator # (multiple vars):" do
it_behaves_like 'expands', {
'{#x,hello,y}' => '#1024,Hello%20World!,768',
'{#path,x}/here' => '#/foo/bar,1024/here',
'{#path,x}/here' => '#/foo/bar,1024/here'
}
end
context "Operator ." do
it_behaves_like 'expands', {
'X{.var}' => 'X.value',
'X{.x,y}' => 'X.1024.768',
'X{.x,y}' => 'X.1024.768'
}
end
context "Operator /" do
it_behaves_like 'expands', {
'{/var}' => '/value',
'{/var,x}/here' => '/value/1024/here',
'{/var,x}/here' => '/value/1024/here'
}
end
context "Operator ;" do
it_behaves_like 'expands', {
'{;x,y}' => ';x=1024;y=768',
'{;x,y,empty}' => ';x=1024;y=768;empty',
'{;x,y,empty}' => ';x=1024;y=768;empty'
}
end
context "Operator ?" do
it_behaves_like 'expands', {
'{?x,y}' => '?x=1024&y=768',
'{?x,y,empty}' => '?x=1024&y=768&empty=',
'{?x,y,empty}' => '?x=1024&y=768&empty='
}
end
context "Operator &" do
it_behaves_like 'expands', {
'?fixed=yes{&x}' => '?fixed=yes&x=1024',
'{&x,y,empty}' => '&x=1024&y=768&empty=',
'{&x,y,empty}' => '&x=1024&y=768&empty='
}
end
end

describe "Level 4" do
subject{
{
Expand Down Expand Up @@ -140,7 +141,7 @@
'semi=%3B,comma=%2C,dot=.',
'dot=.,comma=%2C,semi=%3B',
'comma=%2C,dot=.,semi=%3B'
],
]
}
end
context "Operator + with value modifiers" do
Expand All @@ -163,7 +164,7 @@
'semi=;,comma=,,dot=.',
'dot=.,comma=,,semi=;',
'comma=,,dot=.,semi=;'
],
]
}
end
context "Operator # with value modifiers" do
Expand All @@ -186,7 +187,7 @@
'#semi=;,comma=,,dot=.',
'#dot=.,comma=,,semi=;',
'#comma=,,dot=.,semi=;'
],
]
}
end
context "Operator . with value modifiers" do
Expand All @@ -209,7 +210,7 @@
'X.semi=%3B.comma=%2C.dot=.',
'X.dot=..comma=%2C.semi=%3B',
'X.comma=%2C.dot=..semi=%3B'
],
]
}
end
context "Operator / with value modifiers" do
Expand All @@ -233,7 +234,7 @@
'/semi=%3B/comma=%2C/dot=.',
'/dot=./comma=%2C/semi=%3B',
'/comma=%2C/dot=./semi=%3B'
],
]
}
end
context "Operator ; with value modifiers" do
Expand All @@ -256,7 +257,7 @@
';semi=%3B;comma=%2C;dot=.',
';dot=.;comma=%2C;semi=%3B',
';comma=%2C;dot=.;semi=%3B'
],
]
}
end
context "Operator ? with value modifiers" do
Expand All @@ -279,7 +280,7 @@
'?semi=%3B&comma=%2C&dot=.',
'?dot=.&comma=%2C&semi=%3B',
'?comma=%2C&dot=.&semi=%3B'
],
]
}
end
context "Operator & with value modifiers" do
Expand All @@ -302,7 +303,7 @@
'&semi=%3B&comma=%2C&dot=.',
'&dot=.&comma=%2C&semi=%3B',
'&comma=%2C&dot=.&semi=%3B'
],
]
}
end
end
Expand All @@ -321,7 +322,7 @@
'{var:30}' => 'value',
'{var}' => 'value',
'{semi}' => '%3B',
'{semi:2}' => '%3B',
'{semi:2}' => '%3B'
}
end
context "explode" do
Expand All @@ -334,23 +335,23 @@
describe "Expansion" do
subject{
{
:count => [ "one", "two", "three" ],
:dom => [ "example", "com" ],
:count => ["one", "two", "three"],
:dom => ["example", "com"],
:dub => "me/too",
:hello => "Hello World!",
:half => "50%",
:var => "value",
:who => "fred",
:base => "http://example.com/home/",
:path => "/foo/bar",
:list => [ "red", "green", "blue" ],
:keys => { "semi"=>";","dot"=>".","comma"=>"," },
:list => ["red", "green", "blue"],
:keys => {"semi" => ";","dot" => ".","comma" => ","},
:v => "6",
:x => "1024",
:y => "768",
:empty => "",
:empty_keys => {},
:undef => nil,
:undef => nil
}
}
context "concatenation" do
Expand All @@ -363,7 +364,7 @@
'{;count*}' => ';count=one;count=two;count=three',
'{?count}' => '?count=one,two,three',
'{?count*}' => '?count=one&count=two&count=three',
'{&count*}' => '&count=one&count=two&count=three',
'{&count*}' => '&count=one&count=two&count=three'
}
end
context "simple expansion" do
Expand Down Expand Up @@ -397,7 +398,7 @@
'semi=%3B,comma=%2C,dot=.',
'dot=.,comma=%2C,semi=%3B',
'comma=%2C,dot=.,semi=%3B'
],
]
}
end
context "reserved expansion (+)" do
Expand Down Expand Up @@ -432,7 +433,7 @@
'semi=;,comma=,,dot=.',
'dot=.,comma=,,semi=;',
'comma=,,dot=.,semi=;'
],
]
}
end
context "fragment expansion (#)" do
Expand Down Expand Up @@ -462,7 +463,7 @@
'#semi=;,comma=,,dot=.',
'#dot=.,comma=,,semi=;',
'#comma=,,dot=.,semi=;'
],
]
}
end
context "label expansion (.)" do
Expand Down Expand Up @@ -494,7 +495,7 @@
'X.comma=%2C.dot=..semi=%3B'
],
'X{.empty_keys}' => 'X',
'X{.empty_keys*}' => 'X',
'X{.empty_keys*}' => 'X'
}
end
context "path expansion (/)" do
Expand Down Expand Up @@ -526,7 +527,7 @@
'/semi=%3B/comma=%2C/dot=.',
'/dot=./comma=%2C/semi=%3B',
'/comma=%2C/dot=./semi=%3B'
],
]
}
end
context "path-style expansion (;)" do
Expand Down Expand Up @@ -557,7 +558,7 @@
';semi=%3B;comma=%2C;dot=.',
';dot=.;comma=%2C;semi=%3B',
';comma=%2C;dot=.;semi=%3B'
],
]
}
end
context "form query expansion (?)" do
Expand Down Expand Up @@ -585,7 +586,7 @@
'?semi=%3B&comma=%2C&dot=.',
'?dot=.&comma=%2C&semi=%3B',
'?comma=%2C&dot=.&semi=%3B'
],
]
}
end
context "form query expansion (&)" do
Expand Down Expand Up @@ -613,7 +614,7 @@
'&semi=%3B&comma=%2C&dot=.',
'&dot=.&comma=%2C&semi=%3B',
'&comma=%2C&dot=.&semi=%3B'
],
]
}
end
end
Expand Down

0 comments on commit cf04765

Please sign in to comment.