Sha256: da11fda0fba61d24872be2febb7d5e7914ef2012b95b9eb274861724856f4258

Contents?: true

Size: 972 Bytes

Versions: 6

Compression:

Stored size: 972 Bytes

Contents

require 'spec_helper'

describe MarkMapper::OptionsHash do
  subject { described_class.new }

  describe "#[]=" do
    it "changes order to sort" do
      subject[:order] = "foo asc"
      subject[:sort].should == [["foo", 1]]
      subject[:order].should be_nil
    end

    it "changes sort(id) to sort(_id)" do
      subject[:sort] = "id asc"
      subject[:sort].should == [["_id", 1]]
    end

    it "changes select to fields" do
      subject[:select] = [:foo]
      subject[:fields].should == [:foo]
      subject[:select].should be_nil
    end

    it "changes offset to skip" do
      subject[:offset] = 10
      subject[:skip].should == 10
      subject[:offset].should be_nil
    end

    it "changes id to _id" do
      subject[:id] = :foo
      subject[:_id].should == :foo
      subject[:id].should be_nil
    end

    it "does not change the sort field" do
      subject[:order] = :order.asc
      subject[:sort].should == [["order", 1]]
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mark_mapper-0.0.6 spec/functional/options_hash_spec.rb
mark_mapper-0.0.5 spec/functional/options_hash_spec.rb
mark_mapper-0.0.4 spec/functional/options_hash_spec.rb
mark_mapper-0.0.3 spec/functional/options_hash_spec.rb
mark_mapper-0.0.2 spec/functional/options_hash_spec.rb
mark_mapper-0.0.1 spec/functional/options_hash_spec.rb