Skip to content

Commit

Permalink
Setup specs for forms endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Palleas committed Dec 3, 2016
1 parent bc1c050 commit 9b013df
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ gemspec

gem 'dotenv', '~> 2.1', '>= 2.1.1'
gem 'webmock', '~> 2.1'
gem 'vcr', '~> 3.0', '>= 3.0.3'
64 changes: 64 additions & 0 deletions fixtures/vcr_cassettes/forms.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions lib/convertkit/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def connection
f.params['api_secret'] = api_secret if api_secret
f.params['api_key'] = api_key if api_key

# f.proxy URI('http://localhost:8888')

f.response :json, content_type: /\bjson$/
end
end
Expand Down
21 changes: 21 additions & 0 deletions spec/convertkit/client/forms_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require "spec_helper"

module Convertkit
class Client
describe Sequences do
before do
@client = Convertkit::Client.new
end

describe "#forms" do
it "fetches forms", :vcr do
#stub = stub_request(:get, "https://api.convertkit.com/v3/forms")
VCR.use_cassette 'forms' do
@forms = @client.forms
end
#expect(stub).to have_been_made.once
end
end
end
end
end
20 changes: 20 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,23 @@
require 'convertkit'
require "dotenv"
Dotenv.load(".env.local")

require 'webmock/rspec'
require 'vcr'

Convertkit.configure do |config|
config.api_secret = ENV["API_SECRET"]
config.api_key = ENV["API_KEY"]
end

VCR.configure do |config|
config.cassette_library_dir = "fixtures/vcr_cassettes"
config.hook_into :webmock
config.filter_sensitive_data("<API_SECRET>") { ENV["API_SECRET"] }
config.filter_sensitive_data("<API_KEY>") { ENV["API_KEY"] }
config.allow_http_connections_when_no_cassette = true
end

WebMock.allow_net_connect!


0 comments on commit 9b013df

Please sign in to comment.