smoke 0.5.15 → 0.5.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 15
2
+ :patch: 16
3
3
  :major: 0
4
4
  :minor: 5
@@ -6,7 +6,7 @@ module Smoke
6
6
  def initialize(name, &block)
7
7
  raise StandardError, "Sources must have a name" unless name
8
8
  @name = name
9
- @items, @prepare, @transformation = [], [], []
9
+ @items, @prepare, @requirements, @transformation = [], [], [], []
10
10
 
11
11
  activate!
12
12
  instance_eval(&block) if block_given?
@@ -130,7 +130,7 @@ module Smoke
130
130
  # # End use
131
131
  # Smoke[:twitter].username(:benschwarz).output
132
132
  def prepare(args = {}, &block)
133
- @requirements = args.delete(:require) || []
133
+ @requirements = [args.delete(:require)].flatten
134
134
 
135
135
  raise ArgumentError, "requires a block" unless block_given?
136
136
  @prepare << block
@@ -6,8 +6,10 @@ module Smoke
6
6
  xml.items {
7
7
  items.each do |item|
8
8
  xml.item {
9
- item.each_pair do |key, value|
10
- xml.send(key, value)
9
+ %w(id type class).each{|m| item["#{m}_".to_sym] = item.delete(m.to_sym) }
10
+
11
+ item.each do |k, v|
12
+ xml.send(k, v)
11
13
  end
12
14
  }
13
15
  end
@@ -233,8 +233,12 @@ describe Smoke::Origin do
233
233
  prepare :require => [:username, :feed] do
234
234
  url "http://domain.tld/#{feed}/#{username}/feed.json", :type => :json
235
235
  end
236
-
237
- path :photos, :photo
236
+ end
237
+
238
+ Smoke.data :single_requirement do
239
+ prepare :require => :username do
240
+ url "http://domain.tld/#{feed}/#{username}/feed.json", :type => :json
241
+ end
238
242
  end
239
243
  end
240
244
 
@@ -246,6 +250,12 @@ describe Smoke::Origin do
246
250
  Smoke.requirements.requirements.should include(:username)
247
251
  Smoke.requirements.requirements.should include(:feed)
248
252
  Smoke.requirements.requirements.length.should == 2
253
+ Smoke.requirements.requirements.should be_an_instance_of(Array)
254
+ end
255
+
256
+ it "should have a single requirement, within an array" do
257
+ Smoke.single_requirement.requirements.should be_an_instance_of(Array)
249
258
  end
259
+
250
260
  end
251
261
  end
@@ -3,7 +3,10 @@ require File.join(File.dirname(__FILE__), "..", "..", "spec_helper.rb")
3
3
  describe Smoke::Output::XML do
4
4
  before do
5
5
  @tree = :tree
6
- @items = [{:animal => "monkey", :mammal => true}, {:animal => "elephant"}]
6
+ @items = [
7
+ {:id => 1, :class => "first", :type => "mammal", :animal => "monkey"},
8
+ {:id => 2, :class => "second", :type => "mammal", :animal => "elephant"}
9
+ ]
7
10
  @xml = Smoke::Output::XML.generate(@tree, @items)
8
11
  @document = Nokogiri::XML(@xml)
9
12
  end
@@ -21,4 +24,20 @@ describe Smoke::Output::XML do
21
24
  item.content.should =~ /monkey/
22
25
  end
23
26
  end
27
+ end
28
+
29
+ describe "Smoke XML output with real data" do
30
+ before :all do
31
+ @url = "http://domain.tld/feed.json"
32
+ FakeWeb.register_uri(@url, :response => File.join(SPEC_DIR, 'supports', 'flickr-photo.json'))
33
+
34
+ Smoke.data :real_xml_output do
35
+ url "http://domain.tld/feed.json", :type => :json
36
+ path :photos, :photo
37
+ end
38
+ end
39
+
40
+ it "should not error" do
41
+ Smoke.real_xml_output.output(:xml).should include "<?xml"
42
+ end
24
43
  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.15
4
+ version: 0.5.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Schwarz
@@ -172,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
172
  requirements: []
173
173
 
174
174
  rubyforge_project:
175
- rubygems_version: 1.3.2
175
+ rubygems_version: 1.3.5
176
176
  signing_key:
177
177
  specification_version: 3
178
178
  summary: smoke is a Ruby based DSL that allows you to query web services such as YQL, RSS / Atom and JSON or XML in an elegant manner.