Sha256: a931c886bf45b4d400b8e07bb6008dc7274ea50ab50b8a3695a0684c52c4940d

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

require "spec_helper"

describe Herder::Model do
  it "should setup the remote site" do
    Herder::Model.user.should be == "user"
    Herder::Model.password.should be == "password"
    Herder::Model.site.should be == URI("http://localhost")
  end

  it "should inherit active resource" do
    Herder::Model.new.should be_a(ActiveResource::Base)
  end

  describe "#where" do
    it "should pass the query along to find" do
      options = {foo: :bar}
      Herder::Model.should_receive(:find).with(:all, params: {"foo" => :bar})
      Herder::Model.where(options).to_s
    end

    it "should accept strings" do
      options = {"foo" => "bar"}
      Herder::Model.should_receive(:find).with(:all, params: options)
      Herder::Model.where("foo = 'bar'").to_s
    end

    it "should accept strings with formats as tokens" do
      options = {"foo" => "bar"}
      Herder::Model.should_receive(:find).with(:all, params: options)
      Herder::Model.where("foo = ?", "bar").to_s
    end

    it "should be chain-able" do
      options = {"foo" => "bar", "baz" => "qar"}
      Herder::Model.should_receive(:find).with(:all, params: options)
      Herder::Model.where("foo = ?", "bar").where("baz = ?", "qar").to_s
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
herder-0.0.5 spec/herder/model_spec.rb
herder-0.0.4 spec/herder/model_spec.rb