Sha256: 4b11b8d85129b8c0e2d16a5786138aca6772ad0ce72c644334d0849e484f4310

Contents?: true

Size: 738 Bytes

Versions: 1

Compression:

Stored size: 738 Bytes

Contents

require 'spec_helper'
require 'action_controller'

RSpec.describe Hikari::Parser do
  it 'should split the given sort string' do
    g = Hikari::Parser.new('first_name_asc')
    expect(g.field).to eq('first_name')
    expect(g.order).to eq('ASC')
  end

  it 'should split the default order' do
    g = Hikari::Parser.new(nil, 'last_name ASC')
    expect(g.field).to eq('last_name')
    expect(g.order).to eq('ASC')
  end

  it 'should work without sort' do
    g = Hikari::Parser.new('first_name')
    expect(g.field).to eq('first_name')
    expect(g.order).to eq('ASC')
  end

  it 'should take a hash' do
    g = Hikari::Parser.new({last_name: :desc})
    expect(g.field).to eq('last_name')
    expect(g.order).to eq('DESC')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hikari-0.5.0 spec/lib/parser_spec.rb