spec/smoke/source/yql_spec.rb in benschwarz-smoke-0.2.3 vs spec/smoke/source/yql_spec.rb in benschwarz-smoke-0.2.4
- old
+ new
@@ -2,19 +2,17 @@
describe "YQL" do
before :all do
# Fake web does not yet support regex matched uris
- #FakeWeb.register_uri("query.yahooapis.com/*") do |response|
- # response.body = File.read(File.join(SPEC_DIR, 'supports', 'search-web.yql'))
- # response.content_type "text/json"
- #end
+ FakeWeb.register_uri("query.yahooapis.com/*", :response => File.join(SPEC_DIR, 'supports', 'search-web.yql'))
Smoke.yql(:search) do
select :all
from "search.web"
where :query, "ruby"
+ path :query, :results, :result
emit do
rename(:url => :link)
end
end
@@ -26,18 +24,52 @@
it "should be a list of things" do
Smoke[:search].items.should be_an_instance_of(Array)
end
- it "should hold the url used to query" do
- Smoke[:search].request.uri.should == "http://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20search.web%20WHERE%20query%20=%20'ruby'&format=json"
+ describe "after dispatch" do
+ before do
+ Smoke[:search].output
+ end
+
+ it "should hold the url used to query" do
+ Smoke[:search].request.uri.should == "http://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20search.web%20WHERE%20query%20=%20'ruby'&format=json"
+ end
+
+ it "should have renamed url to link" do
+ Smoke[:search].output.first.should have_key(:link)
+ Smoke[:search].output.first.should_not have_key(:url)
+ end
+
+ it "should output a ruby object" do
+ Smoke[:search].output.should be_an_instance_of(Array)
+ end
end
- it "should have renamed url to link" do
- Smoke[:search].items.first.should have_key(:link)
- Smoke[:search].items.first.should_not have_key(:href)
- end
-
- it "should output a ruby object" do
- Smoke[:search].output.should be_an_instance_of(Array)
+ describe "yql definitions" do
+ before do
+ Smoke.yql(:smoke) do
+ use "http://datatables.org/alltables.env"
+
+ select :all
+ from "github.repo"
+ where :id, "benschwarz"
+ where :repo, "smoke"
+ path :query, :results
+ end
+
+ Smoke[:smoke].output # Force execution
+ end
+
+ it "should be a respository" do
+ Smoke[:smoke].output.should have_key(:repository)
+ end
+
+ it "should respond to use" do
+ Smoke[:smoke].should respond_to(:use)
+ end
+
+ it "should contain 'env' within the query string" do
+ Smoke[:smoke].request.uri.should =~ /env=/
+ end
end
end
\ No newline at end of file