pivotal-erector 0.6.3 → 0.6.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.txt +10 -5
- data/VERSION.yml +1 -1
- data/bin/erector +3 -1
- data/lib/erector/erect.rb +4 -2
- data/lib/erector/erected.rb +14 -4
- data/lib/erector/mixin.rb +7 -0
- data/lib/erector/rhtml.treetop +48 -11
- data/lib/erector/widget.rb +146 -113
- data/lib/erector.rb +1 -0
- data/spec/erect/erect_rails_spec.rb +62 -0
- data/spec/erect/erect_spec.rb +165 -0
- data/spec/erect/erected_spec.rb +93 -0
- data/spec/erect/rhtml_parser_spec.rb +351 -0
- data/spec/erector/mixin_spec.rb +54 -0
- data/spec/erector/widget_spec.rb +38 -0
- metadata +14 -2
data/spec/erector/widget_spec.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
|
2
|
+
require 'benchmark'
|
2
3
|
|
3
4
|
module WidgetSpec
|
4
5
|
describe Erector::Widget do
|
@@ -51,6 +52,36 @@ module WidgetSpec
|
|
51
52
|
end
|
52
53
|
end
|
53
54
|
|
55
|
+
describe "#to_a" do
|
56
|
+
it "returns an array" do
|
57
|
+
widget = Erector::Widget.new do
|
58
|
+
div "Hello"
|
59
|
+
end
|
60
|
+
widget.to_a.should == ["<div>", "Hello", "</div>"]
|
61
|
+
end
|
62
|
+
|
63
|
+
# removing this, since oddly, when i run this test solo it works, but when
|
64
|
+
# i run it as part of a rake suite, i get the opposite result -Alex
|
65
|
+
# it "runs faster than using a string as the output" do
|
66
|
+
# widget = Erector::Widget.new do
|
67
|
+
# 1000.times do |i|
|
68
|
+
# div "Lorem ipsum dolor sit amet #{i}, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est #{i} laborum."
|
69
|
+
# end
|
70
|
+
# end
|
71
|
+
#
|
72
|
+
# times = 20
|
73
|
+
# time_for_to_a = Benchmark.measure { times.times { widget.to_a } }.total
|
74
|
+
# # puts "to_a: #{time_for_to_a}"
|
75
|
+
# time_for_string = Benchmark.measure { times.times { widget.to_s(:output => "") } }.total
|
76
|
+
# # puts "to_s(''): #{time_for_string}"
|
77
|
+
#
|
78
|
+
# percent_faster = (((time_for_string - time_for_to_a) / time_for_string)*100)
|
79
|
+
# # puts ("%.1f%%" % percent_faster)
|
80
|
+
#
|
81
|
+
# (time_for_to_a <= time_for_string).should be_true
|
82
|
+
# end
|
83
|
+
# end
|
84
|
+
|
54
85
|
describe "#instruct" do
|
55
86
|
it "when passed no arguments; returns an XML declaration with version 1 and utf-8" do
|
56
87
|
html = Erector::Widget.new do
|
@@ -786,5 +817,12 @@ module WidgetSpec
|
|
786
817
|
end
|
787
818
|
|
788
819
|
end
|
820
|
+
|
821
|
+
describe "#close_tag" do
|
822
|
+
it "works when it's all alone, even though it messes with the indent level" do
|
823
|
+
Erector::Widget.new { close_tag :foo }.to_s.should == "</foo>"
|
824
|
+
Erector::Widget.new { close_tag :foo; close_tag :bar }.to_s.should == "</foo></bar>"
|
825
|
+
end
|
826
|
+
end
|
789
827
|
end
|
790
828
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pivotal-erector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Chaffee
|
@@ -12,7 +12,7 @@ autorequire:
|
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
14
|
|
15
|
-
date: 2009-05-
|
15
|
+
date: 2009-05-24 00:00:00 -07:00
|
16
16
|
default_executable: erector
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
@@ -42,6 +42,7 @@ files:
|
|
42
42
|
- lib/erector/erected.rb
|
43
43
|
- lib/erector/extensions/object.rb
|
44
44
|
- lib/erector/indenting.rb
|
45
|
+
- lib/erector/mixin.rb
|
45
46
|
- lib/erector/rails.rb
|
46
47
|
- lib/erector/rails/extensions/action_controller.rb
|
47
48
|
- lib/erector/rails/extensions/action_view.rb
|
@@ -58,7 +59,12 @@ files:
|
|
58
59
|
- lib/erector/widgets.rb
|
59
60
|
- lib/erector/widgets/table.rb
|
60
61
|
- spec/core_spec_suite.rb
|
62
|
+
- spec/erect/erect_rails_spec.rb
|
63
|
+
- spec/erect/erect_spec.rb
|
64
|
+
- spec/erect/erected_spec.rb
|
65
|
+
- spec/erect/rhtml_parser_spec.rb
|
61
66
|
- spec/erector/indentation_spec.rb
|
67
|
+
- spec/erector/mixin_spec.rb
|
62
68
|
- spec/erector/unicode_builder_spec.rb
|
63
69
|
- spec/erector/widget_spec.rb
|
64
70
|
- spec/erector/widgets/table_spec.rb
|
@@ -94,8 +100,14 @@ specification_version: 3
|
|
94
100
|
summary: Html Builder library.
|
95
101
|
test_files:
|
96
102
|
- spec/core_spec_suite.rb
|
103
|
+
- spec/erect
|
104
|
+
- spec/erect/erect_rails_spec.rb
|
105
|
+
- spec/erect/erect_spec.rb
|
106
|
+
- spec/erect/erected_spec.rb
|
107
|
+
- spec/erect/rhtml_parser_spec.rb
|
97
108
|
- spec/erector
|
98
109
|
- spec/erector/indentation_spec.rb
|
110
|
+
- spec/erector/mixin_spec.rb
|
99
111
|
- spec/erector/unicode_builder_spec.rb
|
100
112
|
- spec/erector/widget_spec.rb
|
101
113
|
- spec/erector/widgets
|