smoke 0.5.13 → 0.5.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION.yml +1 -1
- data/lib/smoke/output/xml.rb +7 -9
- data/spec/smoke/origin_spec.rb +19 -14
- data/spec/smoke/output/xml_spec.rb +2 -2
- metadata +2 -2
data/VERSION.yml
CHANGED
data/lib/smoke/output/xml.rb
CHANGED
@@ -3,17 +3,15 @@ module Smoke
|
|
3
3
|
class XML
|
4
4
|
def self.generate(tree_name, items)
|
5
5
|
builder = Nokogiri::XML::Builder.new do |xml|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
xml.send(key, value)
|
12
|
-
end
|
13
|
-
}
|
6
|
+
xml.items {
|
7
|
+
items.each do |item|
|
8
|
+
xml.item {
|
9
|
+
item.each_pair do |key, value|
|
10
|
+
xml.send(key, value)
|
14
11
|
end
|
15
12
|
}
|
16
|
-
|
13
|
+
end
|
14
|
+
}
|
17
15
|
end
|
18
16
|
|
19
17
|
builder.to_xml
|
data/spec/smoke/origin_spec.rb
CHANGED
@@ -18,31 +18,36 @@ describe Smoke::Origin do
|
|
18
18
|
|
19
19
|
describe "transformations" do
|
20
20
|
it "should have renamed properties" do
|
21
|
-
Smoke
|
21
|
+
Smoke.test.output.first.should have_key(:title)
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should sort by a given property" do
|
25
|
-
Smoke
|
25
|
+
Smoke.test.output.first[:title].should == "Platypus"
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should reverse the results" do
|
29
|
-
Smoke
|
29
|
+
Smoke.test.output.should == [{:title => "Platypus", :name => "Peter"}]
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should truncate results given a length" do
|
33
|
-
Smoke
|
33
|
+
Smoke.test.output.size.should == 1
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should output" do
|
37
|
-
Smoke
|
37
|
+
Smoke.test.output.should be_an_instance_of(Array)
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should output json" do
|
41
|
-
Smoke
|
41
|
+
Smoke.test.output(:json).should =~ /^\[\{/
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should output yml" do
|
45
|
-
Smoke
|
45
|
+
Smoke.test.output(:yaml).should =~ /^--- \n- :/
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should output xml" do
|
49
|
+
Smoke.test.output(:xml).should include "<?xml version=\"1.0\"?>"
|
50
|
+
Smoke.test.output(:xml).should == "<?xml version=\"1.0\"?>\n<items>\n <item>\n <title>Platypus</title>\n <name>Peter</name>\n </item>\n</items>\n"
|
46
51
|
end
|
47
52
|
|
48
53
|
describe "filtering" do
|
@@ -152,25 +157,25 @@ describe Smoke::Origin do
|
|
152
157
|
|
153
158
|
describe "transformations" do
|
154
159
|
it "should respond to emit" do
|
155
|
-
Smoke
|
160
|
+
Smoke.test.should respond_to(:emit)
|
156
161
|
end
|
157
162
|
|
158
163
|
it "emit should require a block" do
|
159
|
-
lambda { Smoke
|
160
|
-
lambda { Smoke
|
164
|
+
lambda { Smoke.test.emit }.should raise_error
|
165
|
+
lambda { Smoke.test.emit {} }.should_not raise_error
|
161
166
|
end
|
162
167
|
|
163
168
|
it "should respond to transform" do
|
164
|
-
Smoke
|
169
|
+
Smoke.test.should respond_to(:transform)
|
165
170
|
end
|
166
171
|
|
167
172
|
it "tranform should require a block" do
|
168
|
-
lambda { Smoke
|
169
|
-
lambda { Smoke
|
173
|
+
lambda { Smoke.test.transform }.should raise_error
|
174
|
+
lambda { Smoke.test.transform {} }.should_not raise_error
|
170
175
|
end
|
171
176
|
|
172
177
|
it "should have at least one transformation" do
|
173
|
-
Smoke
|
178
|
+
Smoke.test.transformation.size.should_not be_nil
|
174
179
|
end
|
175
180
|
end
|
176
181
|
|
@@ -2,8 +2,8 @@ require File.join(File.dirname(__FILE__), "..", "..", "spec_helper.rb")
|
|
2
2
|
|
3
3
|
describe Smoke::Output::XML do
|
4
4
|
before do
|
5
|
-
@tree =
|
6
|
-
@items = [{:animal => "monkey"}]
|
5
|
+
@tree = :tree
|
6
|
+
@items = [{:animal => "monkey", :mammal => true}, {:animal => "elephant"}]
|
7
7
|
@xml = Smoke::Output::XML.generate(@tree, @items)
|
8
8
|
@document = Nokogiri::XML(@xml)
|
9
9
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smoke
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Schwarz
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-28 00:00:00 +10:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|