Sha256: d79fa693f91d185adc6dd8f1d8e1d5bc8f93582960b9a774eea2bedd449b1ed8

Contents?: true

Size: 1.64 KB

Versions: 7

Compression:

Stored size: 1.64 KB

Contents

require 'spec_helper'
require 'browser/http'

describe Browser::HTTP do
  let(:path) { '/http' }
  let(:path_file) { '/http-file' }

  describe '.get' do
    it 'fetches a path' do
      Browser::HTTP.get(path).then {|res|
        expect(res.text).to eq('lol')
      }.rescue {
        fail
      }
    end
  end

  describe '.get!' do
    it 'fetches a path' do
      expect(Browser::HTTP.get!(path).text).to eq('lol')
    end
  end

  describe '.post' do
    it 'sends parameters properly' do
      Browser::HTTP.post(path, lol: 'wut').then {|res|
        expect(res.text).to eq('ok')
      }.rescue {
        fail
      }
    end
  end

  describe '.post!' do
    it 'sends parameters properly' do
      expect(Browser::HTTP.post!(path, lol: 'wut').text).to eq('ok')
    end

    it 'sends files properly' do
      file = Browser::File.create(["content"], "yay.txt", type: "text/plain")
      expect(Browser::HTTP.post!(path_file, lol: 'wut', file: file).text).to eq('ok')
    end
  end

  describe '.put' do
    it 'sends parameters properly' do
      Browser::HTTP.put(path, lol: 'wut').then {|res|
        expect(res.text).to eq('ok')
      }.rescue {
        fail
      }
    end
  end

  describe '.put!' do
    it 'sends parameters properly' do
      expect(Browser::HTTP.put!(path, lol: 'wut').text).to eq('ok')
    end
  end

  describe '.delete' do
    it 'fetches a path' do
      Browser::HTTP.delete(path).then {|res|
        expect(res.text).to eq('lol')
      }.rescue {
        fail
      }
    end
  end

  describe '.delete!' do
    it 'fetches a path' do
      expect(Browser::HTTP.delete!(path).text).to eq('lol')
    end
  end
end if Browser::HTTP.supported?

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
opal-browser-0.3.5 spec/http_spec.rb
opal-browser-0.3.4 spec/http_spec.rb
atome-opal-browser-0.3.9.5 spec/http_spec.rb
opal-browser-0.3.3 spec/http_spec.rb
opal-browser-0.3.2 spec/http_spec.rb
opal-browser-0.3.1 spec/http_spec.rb
opal-browser-0.3.0 spec/http_spec.rb