Sha256: b7dacbc49ebc07a63f4dc22156930b637f86652382f1f8c03e406a94d2a41aeb

Contents?: true

Size: 572 Bytes

Versions: 2

Compression:

Stored size: 572 Bytes

Contents

require 'spec_helper'

describe SortableHelper, type: :helper do

  describe "#sortable_fetch" do

    class ARDummy
      alias_method :id, :object_id
    end

    context "with no block" do
      it { expect { helper.sortable_fetch(Array.new) }.to raise_error('You must call with block!') }
    end

    context "with block" do
      it "should yield item and its object id" do
        obj = ARDummy.new
        sortable_fetch([ obj ]) do |item, id|
          expect(item).to eq obj
          expect(id).to eq "ARDummy_#{obj.id}"
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails_sortable-0.1.1 spec/helpers/sortable_helper_spec.rb
rails_sortable-0.1.0 spec/helpers/sortable_helper_spec.rb