form_stalker 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,52 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://www.formstack.com/api/v2/form/1.json?oauth_token=
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- Accept-Encoding:
11
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
- Accept:
13
- - "*/*"
14
- User-Agent:
15
- - Ruby
16
- Host:
17
- - www.formstack.com
18
- response:
19
- status:
20
- code: 401
21
- message: Unauthorized
22
- headers:
23
- Content-Type:
24
- - text/html; charset=UTF-8
25
- Date:
26
- - Fri, 29 Jul 2016 14:10:09 GMT
27
- P3p:
28
- - CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI
29
- DSP COR"
30
- Server:
31
- - nginx
32
- Set-Cookie:
33
- - FormstackAdmin=j6qsj5ic07b4mc6hjl5ajrgs20; path=/api/; secure; HttpOnly
34
- - rgisanonymous=false; expires=Sun, 28-Aug-2016 14:10:09 GMT; Max-Age=2592000
35
- - rgisanonymous=true; expires=Sun, 28-Aug-2016 14:10:09 GMT; Max-Age=2592000
36
- - rguserid=ab9075e5-0ad0-4463-966b-38209e9005dd; expires=Sun, 28-Aug-2016 14:10:09
37
- GMT; Max-Age=2592000
38
- - rguuid=true; expires=Sun, 28-Aug-2016 14:10:09 GMT; Max-Age=2592000
39
- Www-Authenticate:
40
- - Bearer realm='Service', error='invalid_token'
41
- X-Robots-Tag:
42
- - noindex, nofollow
43
- Content-Length:
44
- - '0'
45
- Connection:
46
- - keep-alive
47
- body:
48
- encoding: UTF-8
49
- string: ''
50
- http_version:
51
- recorded_at: Fri, 29 Jul 2016 14:10:09 GMT
52
- recorded_with: VCR 3.0.3
@@ -1,92 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FormStalker::Client do
4
- describe '.new' do
5
- context 'when sending configuration options' do
6
- let(:client) { described_class.new(oauth_token: '123') }
7
-
8
- it 'client.config.oauth_token should reflect that initialization' do
9
- expect(client.config.oauth_token).to eq '123'
10
- end
11
- end
12
-
13
- context 'when sending a Config instance' do
14
- let(:client) do
15
- described_class.new(FormStalker::Config.new(oauth_token: '1234'))
16
- end
17
-
18
- it 'client.config.oauth_token should reflect that initialization' do
19
- expect(client.config.oauth_token).to eq '1234'
20
- end
21
- end
22
- end
23
-
24
- describe '.form' do
25
- before(:all) do
26
- @client ||= described_class.new(oauth_token: valid_oauth_token)
27
- end
28
-
29
- context 'when sending a valid id' do
30
- before do
31
- VCR.use_cassette('form_valid_id') do
32
- @response = @client.form('2178204')
33
- end
34
- end
35
-
36
- it '@response should have data' do
37
- expect(@response.data).to be_an_instance_of FormStalker::Data::Form
38
- end
39
-
40
- it '@response should NOT have an error' do
41
- expect(@response.error).to be_nil
42
- end
43
- end
44
-
45
- context 'when sending an invalid id' do
46
- before do
47
- VCR.use_cassette('form_invalid_id') do
48
- @response = @client.form(-1)
49
- end
50
- end
51
-
52
- it '@response should have an error' do
53
- expect(@response.error).to eq 'The form was not found'
54
- end
55
- end
56
- end
57
-
58
- describe '.form_fields' do
59
- before(:all) do
60
- @client ||= described_class.new(oauth_token: valid_oauth_token)
61
- end
62
-
63
- context 'when sending a valid id' do
64
- before do
65
- VCR.use_cassette('form_fields_valid_id') do
66
- @response = @client.form_fields('2178204')
67
- end
68
- end
69
-
70
- it '@response should have data' do
71
- expect(@response.data[0]).to \
72
- be_an_instance_of FormStalker::Data::FormField
73
- end
74
-
75
- it '@response should NOT have an error' do
76
- expect(@response.error).to be_nil
77
- end
78
- end
79
-
80
- context 'when sending an invalid id' do
81
- before do
82
- VCR.use_cassette('form_fields_invalid_id') do
83
- @response = @client.form_fields(-1)
84
- end
85
- end
86
-
87
- it '@response should have an error' do
88
- expect(@response.error).to eq 'A valid form id was not supplied'
89
- end
90
- end
91
- end
92
- end
@@ -1,53 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FormStalker do
4
- describe '.configure' do
5
- context 'when setting the "config.oauth_token"' do
6
- before do
7
- FormStalker.configure { |config| config.oauth_token = '123' }
8
- end
9
- after do
10
- FormStalker.configure { |config| config.oauth_token = nil }
11
- end
12
-
13
- it 'FormStalker.config.oauth_token should reflect that change' do
14
- expect(FormStalker.config.oauth_token).to eq '123'
15
- end
16
-
17
- context 'when setting the "config.oauth_token" yet again' do
18
- before do
19
- FormStalker.configure { |config| config.oauth_token = '1234' }
20
- end
21
- after do
22
- FormStalker.configure { |config| config.oauth_token = nil }
23
- end
24
-
25
- it 'FormStalker.config.oauth_token should reflect that change' do
26
- expect(FormStalker.config.oauth_token).to eq '1234'
27
- end
28
- end
29
- end
30
- end
31
-
32
- describe '.config' do
33
- context 'when setting the #oauth_token' do
34
- before { FormStalker.config.oauth_token = '123' }
35
- after { FormStalker.config.oauth_token = nil }
36
-
37
- it 'FormStalker.client.config.oauth_token should reflect that change' do
38
- expect(FormStalker.client.config.oauth_token).to eq '123'
39
- end
40
- end
41
- end
42
-
43
- describe '.client' do
44
- context 'when setting the #config.oauth_token' do
45
- before { FormStalker.client.config.oauth_token = '123' }
46
- after { FormStalker.client.config.oauth_token = nil }
47
-
48
- it 'FormStalker.config.oauth_token should reflect that change' do
49
- expect(FormStalker.config.oauth_token).to eq '123'
50
- end
51
- end
52
- end
53
- end
@@ -1,22 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FormStalker::Request do
4
- describe '.get' do
5
- context 'when using an invalid oauth_token' do
6
- let(:bad_connection) { FormStalker::Connection.new({}) }
7
- let(:request) { described_class.new(bad_connection) }
8
-
9
- before do
10
- VCR.use_cassette('invalid_oauth_token') do
11
- @response = request.get('form/1.json')
12
- end
13
- end
14
-
15
- it '@response should have an error' do
16
- expect(@response.error).to eq \
17
- 'Either your oauth token is invalid ' \
18
- "or you don't have access to this resource"
19
- end
20
- end
21
- end
22
- end
data/spec/spec_helper.rb DELETED
@@ -1,34 +0,0 @@
1
- require 'codeclimate-test-reporter'
2
-
3
- CodeClimate::TestReporter.start
4
-
5
- require 'simplecov'
6
-
7
- SimpleCov.start do
8
- root('lib/')
9
- coverage_dir('../tmp/coverage/')
10
- end
11
-
12
- $LOAD_PATH << File.expand_path('../', File.dirname(__FILE__))
13
-
14
- require 'pry'
15
- require 'vcr'
16
- require 'form_stalker'
17
- require 'webmock/rspec'
18
-
19
- Dir['./spec/**/support/**/*.rb'].each do |file|
20
- require file
21
- end
22
-
23
- VCR.configure do |config|
24
- config.hook_into :webmock
25
- config.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
26
- end
27
-
28
- RSpec.configure do |config|
29
- config.include Helpers
30
-
31
- config.run_all_when_everything_filtered = true
32
-
33
- config.order = 'random'
34
- end
@@ -1,9 +0,0 @@
1
- module Helpers
2
- def valid_oauth_token
3
- ENV['FORMSTACK_OAUTH_TOKEN'] || 'valid_oauth_token'
4
- end
5
-
6
- def invalid_oauth_token
7
- 'invalid_oauth_token'
8
- end
9
- end