smoke 0.5.13 → 0.5.14

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 13
2
+ :patch: 14
3
3
  :major: 0
4
4
  :minor: 5
@@ -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
- xml.send(tree_name) {
7
- xml.items {
8
- items.each do |item|
9
- xml.item {
10
- item.each_pair do |key, value|
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
@@ -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[:test].output.first.should have_key(:title)
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[:test].output.first[:title].should == "Platypus"
25
+ Smoke.test.output.first[:title].should == "Platypus"
26
26
  end
27
27
 
28
28
  it "should reverse the results" do
29
- Smoke[:test].output.should == [{:title => "Platypus", :name => "Peter"}]
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[:test].output.size.should == 1
33
+ Smoke.test.output.size.should == 1
34
34
  end
35
35
 
36
36
  it "should output" do
37
- Smoke[:test].output.should be_an_instance_of(Array)
37
+ Smoke.test.output.should be_an_instance_of(Array)
38
38
  end
39
39
 
40
40
  it "should output json" do
41
- Smoke[:test].output(:json).should =~ /^\[\{/
41
+ Smoke.test.output(:json).should =~ /^\[\{/
42
42
  end
43
43
 
44
44
  it "should output yml" do
45
- Smoke[:test].output(:yaml).should =~ /^--- \n- :/
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[:test].should respond_to(:emit)
160
+ Smoke.test.should respond_to(:emit)
156
161
  end
157
162
 
158
163
  it "emit should require a block" do
159
- lambda { Smoke[:test].emit }.should raise_error
160
- lambda { Smoke[:test].emit {} }.should_not raise_error
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[:test].should respond_to(:transform)
169
+ Smoke.test.should respond_to(:transform)
165
170
  end
166
171
 
167
172
  it "tranform should require a block" do
168
- lambda { Smoke[:test].transform }.should raise_error
169
- lambda { Smoke[:test].transform {} }.should_not raise_error
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[:test].transformation.size.should_not be_nil
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 = "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.13
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-27 00:00:00 +10:00
12
+ date: 2009-09-28 00:00:00 +10:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency