spec/motion-resource/associations/scope_spec.rb in motion-resource-0.0.1 vs spec/motion-resource/associations/scope_spec.rb in motion-resource-0.0.2
- old
+ new
@@ -1,21 +1,34 @@
describe "scope" do
extend WebStub::SpecHelpers
+ before do
+ stub_request(:get, "http://example.com/comments/recent.json").to_return(json: [{ id: 1, text: 'Whats up?' }])
+ end
+
it "should define a custom url" do
Comment.should.respond_to :recent_url
end
it "should fetch collection" do
- stub_request(:get, "http://example.com/comments/recent.json").to_return(json: [{ id: 1, text: 'Whats up?' }])
-
Comment.recent do |results|
@results = results
resume
end
wait_max 1.0 do
@results.size.should == 1
@results.first.text.should == 'Whats up?'
+ end
+ end
+
+ it "should give HTTP response to block" do
+ Comment.recent do |results, response|
+ @response = response
+ resume
+ end
+
+ wait_max 1.0 do
+ @response.should.be.ok
end
end
end