spec/scanner_spec.rb in curly-templates-1.0.1 vs spec/scanner_spec.rb in curly-templates-2.0.0.beta1
- old
+ new
@@ -2,24 +2,24 @@
describe Curly::Scanner, ".scan" do
it "returns the tokens in the source" do
scan("foo {{bar}} baz").should == [
[:text, "foo "],
- [:reference, "bar"],
+ [:component, "bar"],
[:text, " baz"]
]
end
- it "scans parameterized references" do
+ it "scans components with identifiers" do
scan("{{foo.bar}}").should == [
- [:reference, "foo.bar"]
+ [:component, "foo.bar"]
]
end
- it "allows references with whitespace" do
+ it "allows components with whitespace" do
scan("{{ foo bar}}").should == [
- [:reference, " foo bar"]
+ [:component, " foo bar"]
]
end
it "scans comments in the source" do
scan("foo {{!bar}} baz").should == [
@@ -57,28 +57,37 @@
[:text, "{{"],
[:text, " lala! }} bar"]
]
end
- it "scans block tags" do
- scan('foo {{#bar}} hello {{/bar}}').should == [
+ it "scans conditional block tags" do
+ scan('foo {{#bar?}} hello {{/bar?}}').should == [
[:text, "foo "],
- [:block_start, "bar"],
+ [:conditional_block_start, "bar?"],
[:text, " hello "],
- [:block_end, "bar"]
+ [:conditional_block_end, "bar?"]
]
end
it "scans inverse block tags" do
- scan('foo {{^bar}} hello {{/bar}}').should == [
+ scan('foo {{^bar?}} hello {{/bar?}}').should == [
[:text, "foo "],
- [:inverse_block_start, "bar"],
+ [:inverse_conditional_block_start, "bar?"],
[:text, " hello "],
- [:block_end, "bar"]
+ [:conditional_block_end, "bar?"]
]
end
+ it "scans collection block tags" do
+ scan('foo {{*bar}} hello {{/bar}}').should == [
+ [:text, "foo "],
+ [:collection_block_start, "bar"],
+ [:text, " hello "],
+ [:collection_block_end, "bar"]
+ ]
+ end
+
it "treats quotes as text" do
scan('"').should == [
[:text, '"']
]
end
@@ -87,10 +96,10 @@
scan('#{foo}').should == [
[:text, '#{foo}']
]
end
- it "raises Curly::SyntaxError on unclosed references" do
+ it "raises Curly::SyntaxError on unclosed components" do
["{{", "{{yolo"].each do |template|
expect { scan(template) }.to raise_error(Curly::SyntaxError)
end
end