spec/http_spec.rb in opal-browser-0.2.0 vs spec/http_spec.rb in opal-browser-0.3.0

- old
+ new

@@ -1,23 +1,18 @@ require 'spec_helper' require 'browser/http' describe Browser::HTTP do - let :path do - '/http' - end + let(:path) { '/http' } + let(:path_file) { '/http-file' } describe '.get' do - async 'fetches a path' do + it 'fetches a path' do Browser::HTTP.get(path).then {|res| - async { - expect(res.text).to eq('lol') - } + expect(res.text).to eq('lol') }.rescue { - async { - fail - } + fail } end end describe '.get!' do @@ -25,39 +20,36 @@ expect(Browser::HTTP.get!(path).text).to eq('lol') end end describe '.post' do - async 'sends parameters properly' do + it 'sends parameters properly' do Browser::HTTP.post(path, lol: 'wut').then {|res| - async { - expect(res.text).to eq('ok') - } + expect(res.text).to eq('ok') }.rescue { - async { - fail - } + 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 - async 'sends parameters properly' do + it 'sends parameters properly' do Browser::HTTP.put(path, lol: 'wut').then {|res| - async { - expect(res.text).to eq('ok') - } + expect(res.text).to eq('ok') }.rescue { - async { - fail - } + fail } end end describe '.put!' do @@ -65,18 +57,14 @@ expect(Browser::HTTP.put!(path, lol: 'wut').text).to eq('ok') end end describe '.delete' do - async 'fetches a path' do + it 'fetches a path' do Browser::HTTP.delete(path).then {|res| - async { - expect(res.text).to eq('lol') - } + expect(res.text).to eq('lol') }.rescue { - async { - fail - } + fail } end end describe '.delete!' do