Sha256: 4521a4c44c7bf321e767cecd0549762ea1fb1fad25658fa5351059c8ae9ee8d3

Contents?: true

Size: 759 Bytes

Versions: 16

Compression:

Stored size: 759 Bytes

Contents

require './spec/spec_helper'

class MyResource < Base
  extend Finders
  self.element_name = "my_resource"
end

describe Finders, "Finders model" do

  before(:each) do
    stub_auth_request
  end

  it "should get first result" do
    stub_api_get("/my_resource", 'finders.json')
    resource = MyResource.first
    resource.Id.should eq(1)
  end

  it "should get last result" do
    stub_api_get("/my_resource", 'finders.json')
    resource = MyResource.last
    resource.Id.should eq(2)
  end

  it "should find one result" do
    stub_api_get("/my_resource", 'finders.json', {
      :_limit => 1,
      :_filter => "Something Eq 'dude'"
    })
    resource = MyResource.find_one(:_filter => "Something Eq 'dude'")
    resource.Id.should eq(1)
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
spark_api-1.3.21 spec/unit/spark_api/models/finders_spec.rb
spark_api-1.3.20 spec/unit/spark_api/models/finders_spec.rb
spark_api-1.3.19 spec/unit/spark_api/models/finders_spec.rb
spark_api-1.3.18 spec/unit/spark_api/models/finders_spec.rb
spark_api-1.3.17 spec/unit/spark_api/models/finders_spec.rb
spark_api-1.3.16 spec/unit/spark_api/models/finders_spec.rb
spark_api-1.3.15 spec/unit/spark_api/models/finders_spec.rb
spark_api-1.3.14 spec/unit/spark_api/models/finders_spec.rb
spark_api-1.3.13 spec/unit/spark_api/models/finders_spec.rb
spark_api-1.3.10 spec/unit/spark_api/models/finders_spec.rb
spark_api-1.3.9 spec/unit/spark_api/models/finders_spec.rb
spark_api-1.3.6 spec/unit/spark_api/models/finders_spec.rb
spark_api-1.3.3 spec/unit/spark_api/models/finders_spec.rb
spark_api-1.3.1 spec/unit/spark_api/models/finders_spec.rb
spark_api-1.3.0 spec/unit/spark_api/models/finders_spec.rb
spark_api-1.2.1 spec/unit/spark_api/models/finders_spec.rb