Sha256: cf6a52571b2db45a3ada8e59dca743e716adc929e4dfc249849216b9cc1d2f43

Contents?: true

Size: 1 KB

Versions: 4

Compression:

Stored size: 1 KB

Contents

require_relative 'spec_helper'
require 'fluentd_server/web_helper'

describe 'WebHelper' do
  include FluentdServer::WebHelper

  context '#parse_query' do
    it 'key=val' do
      expect(parse_query('key=val')).to eql({'key'=>'val'})
    end

    it 'array' do
      # Array support of Rack::Utils.parse_query is as
      # `key=1&key=2` #=> key => ['1', '2']
      # But, I change it as `key[]=1&key[]=2` referring PHP
      expect(parse_query('key[]=1&key[]=2')).to eql({'key'=>['1','2']})
    end

    it 'hash' do
      expect(parse_query('name[key1]=1&name[key2]=2')).to eql(
        {'name' => {'key1'=>'1', 'key2'=>'2'}}
      )
    end
  end

  context '#escape_url' do
    it { expect(escape_url('a b')).to eql('a+b') }
  end

  context '#active_if' do
    it { expect(active_if(true)).to eql('active') }
    it { expect(active_if(false)).to be_nil }
  end

  context '#disabled_if' do
    it { expect(disabled_if(true)).to eql('disabled="disabled"') }
    it { expect(disabled_if(false)).to be_nil }
  end

end


Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fluentd-server-0.3.2 spec/web_helper_spec.rb
fluentd-server-0.3.1 spec/web_helper_spec.rb
fluentd-server-0.3.0 spec/web_helper_spec.rb
fluentd-server-0.2.0 spec/web_helper_spec.rb