Sha256: 5ff7e54306da6e677e1dbf99c7514519a6db557c32305fdca127b9d0794a609f

Contents?: true

Size: 1.2 KB

Versions: 5

Compression:

Stored size: 1.2 KB

Contents

require "spec_helper"

describe Uploadcare::Rails::ActionView::FormBuilder, type: :helper do
  before :each do
    @post = Post.new
    @form = ActionView::Helpers::FormBuilder.new(:post, @post, helper, {})
  end

  it "should include uploader tag for name" do
    tag = @form.uploadcare_field :file
    tag.should be_kind_of(String)
  end

  it "should have role attr" do
    tag = @form.uploadcare_field :file, :uploadcare => {:multiple => true}
    expect(tag).to have_selector('input[role="uploadcare-uploader"]', visible: :all)
  end

  it "should have custom data-attributes" do
    tag = @form.uploadcare_field :file, :data => {:custom => true}
    expect(tag).to have_selector('input[data-custom="true"]', visible: :all)
  end

  it "should have uploadcare namespace translated into data- attributes" do
    tag = @form.uploadcare_field :file, :uploadcare => {:custom => true}
    expect(tag).to have_selector('input[data-custom="true"]', visible: :all)
  end

  it "should override data namespace with uploadcare namespace" do
    tag = @form.uploadcare_field :file, :uploadcare => {:custom => true}, :data => {:custom => false}
    expect(tag).to have_selector('input[data-custom="true"]', visible: :all)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
uploadcare-rails-1.2.1 spec/helpers/form_helpers_spec.rb
uploadcare-rails-1.2.0 spec/helpers/form_helpers_spec.rb
uploadcare-rails-1.2.0.pre.alpha3 spec/helpers/form_helpers_spec.rb
uploadcare-rails-1.2.0.pre.alpha spec/helpers/form_helpers_spec.rb
uploadcare-rails-1.1.1 spec/helpers/form_helpers_spec.rb