Sha256: ed20cd85de3f8d4869cd8c02a61240537f6de660b377fdea2082be9fb8941758

Contents?: true

Size: 719 Bytes

Versions: 6

Compression:

Stored size: 719 Bytes

Contents

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
    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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
motion-resource-0.1.4 spec/motion-resource/associations/scope_spec.rb
motion-resource-0.1.3 spec/motion-resource/associations/scope_spec.rb
motion-resource-0.1.2 spec/motion-resource/associations/scope_spec.rb
motion-resource-0.1.1 spec/motion-resource/associations/scope_spec.rb
motion-resource-0.1.0 spec/motion-resource/associations/scope_spec.rb
motion-resource-0.0.2 spec/motion-resource/associations/scope_spec.rb