Sha256: bd0540c6f32cc9f4a4a7b5d90589190e882b088055922d08c732971cc2261344

Contents?: true

Size: 825 Bytes

Versions: 2

Compression:

Stored size: 825 Bytes

Contents

require 'spec_helper'

describe Masheri::Member do
  let(:url) { Masheri.rpc.url }

  let(:items) {
    [{"name" => "Name"}] * 10
  }

  let(:params) {
    {
      'method' => "object.query",
      'params' => [query],
      'id'     => 1
    }
  }

  let(:headers) {
    {
      "Content-Type"   => "application/json",
      "Accept"         => "text/plain",
      "Content-Length" => params.size
    }
  }

  let(:json) {
    {
      "result" => {
        "items" => items
      }
    }.to_json
  }


  context "with standard query" do
    let(:query) {
      "SELECT * FROM members ITEMS 100"
    }

    it "should grab all the members" do
      ::RestClient.should_receive(:post).with(url, params.to_json, headers).and_return(json)
      objects = Masheri::Member.all
      objects.length.should == 10
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
masheri-0.6.1 spec/masheri/member_spec.rb
masheri-0.6.0 spec/masheri/member_spec.rb