rock_rms 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 514de0ec32fa96166e279cdf6e49215a7d624b6a
4
- data.tar.gz: 15f69b870070433905f4bb35b48392dd2649c6f7
3
+ metadata.gz: 27591a871df8890a775bd4f4c142a486d2e60118
4
+ data.tar.gz: ba514d35a3e780262708639fe5e676af846538d3
5
5
  SHA512:
6
- metadata.gz: 0b42adaf40fd595e89e941ad174c410bc9e7e508adac4f4aed40b3811cfe02254956efd6ca1ea63865c9cb9eb96a8350c3666fe2a7039b63dad36adbc338432c
7
- data.tar.gz: 3ed86f2a15a85b89f28c9af76348e1dbadb2ca0ae0ddeecf2dfe2a4abf5f0bbcc390a3f55725d45c455a5ace26606210eadd8f5397efed30116feeb1966f3b92
6
+ metadata.gz: f187f18982dd4286d90bf11d32832b7bdca43cf9e99fe39d1788e52d83dc42884ce0325428764798ab3f28c539a0e22936213bbc25b3bfda3f83b51bdc0175ee
7
+ data.tar.gz: d92f43093d060813bd1e8e0b83008eae443c218602942c910c5d45bdeee10d8a113b95d7f9290b8aba9b2c47425952aab9ebdcb2f1aaedc9f57249cd8af39223
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  rock_rms-*.gem
2
2
  .env
3
+ Gemfile.lock
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2.2
data/Rakefile ADDED
@@ -0,0 +1,29 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
8
+ task :environment do
9
+ require 'dotenv'
10
+ Dotenv.load
11
+
12
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
13
+ require 'rock_rms'
14
+ end
15
+
16
+ desc "Launch a pry shell with libraries loaded"
17
+ task :pry => :environment do
18
+ if ENV['ROCK_USERNAME']
19
+ @client = RockRMS::Client.new(
20
+ url: ENV['ROCK_API_URL'],
21
+ username: ENV['ROCK_USERNAME'],
22
+ password: ENV['ROCK_PASSWORD'],
23
+ logger: !!ENV['CLIENT_LOGGER']
24
+ )
25
+ end
26
+
27
+ require 'pry'
28
+ Pry.start
29
+ end
data/bin/rspec ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rspec' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rspec-core", "rspec")
data/lib/rock_rms.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  require_relative 'rock_rms/client'
2
+ require_relative 'rock_rms/error'
3
+ require_relative 'rock_rms/version'
2
4
 
3
5
  module RockRMS
4
6
  end
@@ -1,11 +1,9 @@
1
1
  require 'faraday'
2
2
  require 'faraday_middleware'
3
3
  require 'faraday_middleware/parse_oj'
4
- require_relative 'error'
5
- require_relative 'version'
6
4
 
7
- Dir[File.expand_path('../resources/*.rb', __FILE__)].each{|f| require f}
8
- Dir[File.expand_path('../responses/*.rb', __FILE__)].each{|f| require f}
5
+ Dir[File.expand_path('../resources/*.rb', __FILE__)].each { |f| require f }
6
+ Dir[File.expand_path('../responses/*.rb', __FILE__)].each { |f| require f }
9
7
 
10
8
  module RockRMS
11
9
  class Client
@@ -26,46 +24,44 @@ module RockRMS
26
24
  @cookie = auth['set-cookie']
27
25
  end
28
26
 
29
- def auth
30
- connection.post("#{@url}Auth/Login", {
31
- 'Username' => username,
32
- 'Password' => password,
33
- 'Persisted' => true
34
- })
27
+ def delete(path, options = {})
28
+ connection.delete(path, options).body
35
29
  end
36
30
 
37
31
  def get(path, options = {})
38
32
  connection.get(path, options).body
39
33
  end
40
34
 
41
- def post(path, req_body)
42
- connection.post do |req|
43
- req.url(path)
44
- req.body = req_body
45
- end.body
46
- end
47
-
48
- def patch(path, options)
49
- connection.patch(path, options).body
35
+ def patch(path, req_body)
36
+ connection.patch(path, req_body).body
50
37
  end
51
38
 
52
- def put(path, options)
53
- connection.put(path, options).body
39
+ def post(path, req_body)
40
+ connection.post(path, req_body).body
54
41
  end
55
42
 
56
- def delete(path, options = {})
57
- connection.delete(path, options).body
43
+ def put(path, req_body)
44
+ connection.put(path, req_body).body
58
45
  end
59
46
 
60
47
  private
61
48
 
49
+ def auth
50
+ connection.post(
51
+ 'Auth/Login',
52
+ 'Username' => username,
53
+ 'Password' => password,
54
+ 'Persisted' => true
55
+ )
56
+ end
57
+
62
58
  def connection
63
59
  headers = {
64
60
  accept: 'application/json',
65
61
  'User-Agent' => "rock-rms-ruby-gem/v#{RockRMS::VERSION}"
66
62
  }
67
63
 
68
- headers.merge!('Cookie' => cookie) if cookie
64
+ headers['Cookie'] = cookie if cookie
69
65
 
70
66
  Faraday.new(url: url, headers: headers) do |conn|
71
67
  conn.request :json
@@ -2,7 +2,7 @@ module RockRMS
2
2
  class Error < StandardError; end
3
3
  end
4
4
 
5
- require "faraday"
5
+ require 'faraday'
6
6
  module FaradayMiddleware
7
7
  class RockRMSErrorHandler < Faraday::Response::Middleware
8
8
  ERROR_STATUSES = 400..600
@@ -1,21 +1,20 @@
1
1
  module RockRMS
2
2
  class Client
3
3
  module Batch
4
-
5
4
  def list_batches(options = {})
6
- res = get(batches_path, options)
5
+ get(batches_path, options)
7
6
  end
8
7
 
9
8
  def find_batch(id)
10
- res = get(batches_path(id))
9
+ get(batches_path(id))
11
10
  end
12
11
 
13
12
  def create_batch(name:, start_time:, end_time:, foreign_key: nil)
14
13
  options = {
15
- "Name" => name,
16
- "BatchStartDateTime" => start_time,
17
- "BatchEndDateTime" => end_time,
18
- "ForeignKey" => foreign_key
14
+ 'Name' => name,
15
+ 'BatchStartDateTime' => start_time,
16
+ 'BatchEndDateTime' => end_time,
17
+ 'ForeignKey' => foreign_key
19
18
  }
20
19
 
21
20
  post(batches_path, options)
@@ -28,9 +27,8 @@ module RockRMS
28
27
  private
29
28
 
30
29
  def batches_path(id = nil)
31
- id ? "FinancialBatches/#{id}" : "FinancialBatches"
30
+ id ? "FinancialBatches/#{id}" : 'FinancialBatches'
32
31
  end
33
-
34
32
  end
35
33
  end
36
34
  end
@@ -1,8 +1,7 @@
1
1
  module RockRMS
2
2
  class Client
3
3
  module Donation
4
-
5
- def list_donations(options={})
4
+ def list_donations(options = {})
6
5
  res = get(transaction_path, options)
7
6
  RockRMS::Donation.format(res)
8
7
  end
@@ -19,24 +18,24 @@ module RockRMS
19
18
 
20
19
  def create_donation(payment_type:, authorized_person_id:, amount:, date:, fund_id:, batch_id:, transaction_code: nil)
21
20
  options = {
22
- "AuthorizedPersonAliasId" => authorized_person_id,
23
- "BatchId" => batch_id,
24
- "FinancialPaymentDetailId" => payment_type,
25
- "TransactionCode" => transaction_code,
26
- "TransactionDateTime" => date,
27
- "TransactionDetails" => [{
28
- "Amount" => amount,
29
- "AccountId" => fund_id,
21
+ 'AuthorizedPersonAliasId' => authorized_person_id,
22
+ 'BatchId' => batch_id,
23
+ 'FinancialPaymentDetailId' => payment_type,
24
+ 'TransactionCode' => transaction_code,
25
+ 'TransactionDateTime' => date,
26
+ 'TransactionDetails' => [{
27
+ 'Amount' => amount,
28
+ 'AccountId' => fund_id
30
29
  }],
31
- "TransactionTypeValueId" => 53, # contribution, registration
32
- "SourceTypeValueId" => 10, # website, kiosk, mobile app
30
+ 'TransactionTypeValueId' => 53, # contribution, registration
31
+ 'SourceTypeValueId' => 10, # website, kiosk, mobile app
33
32
  }
34
33
  post(transaction_path, options)
35
34
  end
36
35
 
37
36
  def update_donation(id, batch_id:)
38
37
  options = {
39
- "BatchId" => batch_id
38
+ 'BatchId' => batch_id
40
39
  }
41
40
  patch(transaction_path(id), options)
42
41
  end
@@ -48,9 +47,8 @@ module RockRMS
48
47
  private
49
48
 
50
49
  def transaction_path(id = nil)
51
- id ? "FinancialTransactions/#{id}" : "FinancialTransactions"
50
+ id ? "FinancialTransactions/#{id}" : 'FinancialTransactions'
52
51
  end
53
-
54
52
  end
55
53
  end
56
54
  end
@@ -1,7 +1,6 @@
1
1
  module RockRMS
2
2
  class Client
3
3
  module Fund
4
-
5
4
  def list_funds(options = {})
6
5
  res = get(fund_path, options)
7
6
  RockRMS::Fund.format(res)
@@ -10,9 +9,8 @@ module RockRMS
10
9
  private
11
10
 
12
11
  def fund_path(id = nil)
13
- id ? "FinancialAccounts/#{id}" : "FinancialAccounts"
12
+ id ? "FinancialAccounts/#{id}" : 'FinancialAccounts'
14
13
  end
15
-
16
14
  end
17
15
  end
18
16
  end
@@ -1,28 +1,14 @@
1
1
  module RockRMS
2
2
  class Client
3
3
  module PaymentMethod
4
-
5
- def list_payment_methods(options={})
4
+ def list_payment_methods(options = {})
6
5
  get(payment_method_path, options)
7
6
  end
8
7
 
9
- def create_payment_method(uuid:, person_id:, last_4:, payment_type:, name:)
10
- opts = {
11
- "PersonAliasId" => person_id,
12
- "Name" => name,
13
- "ForeignKey" => uuid,
14
- "FinancialPaymentDetail" => {
15
- "AccountNumberMasked" => last_4,
16
- "CurrencyTypeValueId" => payment_type == 'card' ? 156 : 157,
17
- }
18
- }
19
- post("FinancialPersonSavedAccounts", opts)
20
- end
21
-
22
8
  private
23
9
 
24
10
  def payment_method_path(id = nil)
25
- id ? "FinancialPaymentDetails/#{id}" : "FinancialPaymentDetails"
11
+ id ? "FinancialPaymentDetails/#{id}" : 'FinancialPaymentDetails'
26
12
  end
27
13
  end
28
14
  end
@@ -1,7 +1,7 @@
1
1
  module RockRMS
2
2
  class Client
3
3
  module Person
4
- def list_people(options={})
4
+ def list_people(options = {})
5
5
  res = get(people_path, options)
6
6
  RockRMS::Person.format(res)
7
7
  end
@@ -23,11 +23,11 @@ module RockRMS
23
23
 
24
24
  def create_person(first_name:, last_name:, email:)
25
25
  options = {
26
- "IsSystem" => false,
27
- "FirstName" => first_name,
28
- "LastName" => last_name,
29
- "Email" => email,
30
- "Gender" => 1
26
+ 'IsSystem' => false,
27
+ 'FirstName' => first_name,
28
+ 'LastName' => last_name,
29
+ 'Email' => email,
30
+ 'Gender' => 1
31
31
  }
32
32
  post(people_path, options)
33
33
  end
@@ -39,7 +39,7 @@ module RockRMS
39
39
  private
40
40
 
41
41
  def people_path(id = nil)
42
- id ? "People/#{id}" : "People"
42
+ id ? "People/#{id}" : 'People'
43
43
  end
44
44
  end
45
45
  end
@@ -1,8 +1,7 @@
1
1
  module RockRMS
2
2
  class Client
3
3
  module TransactionDetail
4
-
5
- def list_transaction_details(options={})
4
+ def list_transaction_details(options = {})
6
5
  get(transaction_detail_path, options)
7
6
  end
8
7
 
@@ -12,7 +11,7 @@ module RockRMS
12
11
 
13
12
  def update_transaction_detail(id, account_id:)
14
13
  options = {
15
- "AccountId" => account_id
14
+ 'AccountId' => account_id
16
15
  }
17
16
  patch(transaction_detail_path(id), options)
18
17
  end
@@ -20,7 +19,7 @@ module RockRMS
20
19
  private
21
20
 
22
21
  def transaction_detail_path(id = nil)
23
- id ? "FinancialTransactionDetails/#{id}" : "FinancialTransactionDetails"
22
+ id ? "FinancialTransactionDetails/#{id}" : 'FinancialTransactionDetails'
24
23
  end
25
24
  end
26
25
  end
@@ -2,7 +2,7 @@ module RockRMS
2
2
  class Donation
3
3
  def self.format(response)
4
4
  if response.is_a?(Array)
5
- response.map{|donation| format_donation(donation) }
5
+ response.map { |donation| format_donation(donation) }
6
6
  else
7
7
  format_donation(response)
8
8
  end
@@ -10,12 +10,12 @@ module RockRMS
10
10
 
11
11
  def self.format_donation(donation)
12
12
  {
13
- id: donation["Id"],
14
- date: donation["TransactionDateTime"],
15
- amount: donation["TransactionDetails"].reduce(0){|sum, td| sum + td["Amount"]},
16
- person_id: donation["AuthorizedPersonAliasId"],
17
- fund: "",
18
- batch_id: donation["BatchId"]
13
+ id: donation['Id'],
14
+ date: donation['TransactionDateTime'],
15
+ amount: donation['TransactionDetails'].reduce(0) { |sum, td| sum + td['Amount'] },
16
+ person_id: donation['AuthorizedPersonAliasId'],
17
+ fund: '',
18
+ batch_id: donation['BatchId']
19
19
  }
20
20
  end
21
21
  end
@@ -2,7 +2,7 @@ module RockRMS
2
2
  class Fund
3
3
  def self.format(response)
4
4
  if response.is_a?(Array)
5
- response.map{|fund| format_fund(fund) }
5
+ response.map { |fund| format_fund(fund) }
6
6
  else
7
7
  format_fund(response)
8
8
  end
@@ -10,8 +10,8 @@ module RockRMS
10
10
 
11
11
  def self.format_fund(fund)
12
12
  {
13
- id: fund["Id"],
14
- name: fund["Name"]
13
+ id: fund['Id'],
14
+ name: fund['Name']
15
15
  }
16
16
  end
17
17
  end
@@ -2,7 +2,7 @@ module RockRMS
2
2
  class Person
3
3
  def self.format(response)
4
4
  if response.is_a?(Array)
5
- response.map{|person| format_person(person) }
5
+ response.map { |person| format_person(person) }
6
6
  else
7
7
  format_person(response)
8
8
  end
@@ -10,13 +10,13 @@ module RockRMS
10
10
 
11
11
  def self.format_person(person)
12
12
  {
13
- id: person["Id"],
14
- name: person["FullName"],
15
- email: person["Email"],
16
- first_name: person["FirstName"],
17
- last_name: person["LastName"],
18
- giving_id: person["GivingId"],
19
- alias_id: person["PrimaryAliasId"]
13
+ id: person['Id'],
14
+ name: person['FullName'],
15
+ email: person['Email'],
16
+ first_name: person['FirstName'],
17
+ last_name: person['LastName'],
18
+ giving_id: person['GivingId'],
19
+ alias_id: person['PrimaryAliasId']
20
20
  }
21
21
  end
22
22
  end
@@ -1,3 +1,3 @@
1
1
  module RockRMS
2
- VERSION = "0.0.8"
2
+ VERSION = '0.0.9'.freeze
3
3
  end
data/rock_rms.gemspec CHANGED
@@ -17,6 +17,8 @@ Gem::Specification.new do |s|
17
17
  s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
18
  s.test_files = s.files.grep(%r{^(test)/})
19
19
 
20
+ s.required_ruby_version = '~> 2.2'
21
+
20
22
  s.require_paths = ["lib"]
21
23
 
22
24
  s.add_runtime_dependency 'faraday'
@@ -24,5 +26,11 @@ Gem::Specification.new do |s|
24
26
  s.add_runtime_dependency 'faraday_middleware-parse_oj'
25
27
  s.add_runtime_dependency 'json'
26
28
 
27
- s.add_development_dependency 'bundler'
29
+ s.add_development_dependency 'bundler', '~> 1.15'
30
+ s.add_development_dependency 'dotenv'
31
+ s.add_development_dependency 'pry'
32
+ s.add_development_dependency 'rake', '~> 10.4'
33
+ s.add_development_dependency 'rspec', '~> 3.7'
34
+ s.add_development_dependency 'sinatra', '~> 2.0'
35
+ s.add_development_dependency 'webmock', '~> 3.1'
28
36
  end
@@ -0,0 +1,131 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RockRMS::Client do
4
+ let(:attrs) do
5
+ {
6
+ url: 'http://some-rock-uri.com',
7
+ username: 'test',
8
+ password: 'test'
9
+ }
10
+ end
11
+ let(:attrs_without_logging) { attrs.merge(logger: false) }
12
+
13
+ subject(:client) { described_class.new(attrs_without_logging) }
14
+ let(:noisy_client) { described_class.new(attrs) }
15
+
16
+ describe '#initialize' do
17
+ it 'requries `url` param' do
18
+ expect { described_class.new }
19
+ .to raise_error(ArgumentError, /url/)
20
+ end
21
+
22
+ it 'requries `username` param' do
23
+ expect { described_class.new }
24
+ .to raise_error(ArgumentError, /username/)
25
+ end
26
+
27
+ it 'requries `password` param' do
28
+ expect { described_class.new }
29
+ .to raise_error(ArgumentError, /password/)
30
+ end
31
+
32
+ context 'url' do
33
+ it 'expects a valid URI' do
34
+ expect do
35
+ described_class.new(url: 'test', username: 'test', password: 'test')
36
+ end.to raise_error(URI::InvalidURIError)
37
+ end
38
+ end
39
+ end
40
+
41
+ context 'defaults' do
42
+ it '`logger` is `true`' do
43
+ expect(noisy_client.logger).to be_truthy
44
+ end
45
+
46
+ it 'sets base api url' do
47
+ expect(client.url).to eq('http://some-rock-uri.com/api/')
48
+ end
49
+ end
50
+
51
+ shared_examples 'param request' do |verb|
52
+ let(:endpoint) { "#{verb}_test" }
53
+ let(:url) { "http://some-rock-uri.com/api/#{endpoint}" }
54
+
55
+ before do
56
+ stub_request(:any, /_test/).to_return(body: response_body.to_json)
57
+ end
58
+
59
+ it 'requests at `path` argument' do
60
+ client.public_send(verb, endpoint)
61
+
62
+ expect(WebMock).to have_requested(verb, url)
63
+ end
64
+
65
+ it 'passes request parameters' do
66
+ client.public_send(verb, endpoint, request_params)
67
+
68
+ expect(WebMock).to have_requested(verb, url).with(query: request_params)
69
+ end
70
+
71
+ it 'returns parsed response body' do
72
+ expect(client.public_send(verb, endpoint)).to eq(response_body)
73
+ end
74
+ end
75
+
76
+ shared_examples 'body request' do |verb|
77
+ let(:body) { { 'test' => 123 } }
78
+ let(:endpoint) { "#{verb}_test" }
79
+ let(:url) { "http://some-rock-uri.com/api/#{endpoint}" }
80
+
81
+ let(:do_request) { client.public_send(verb, endpoint, body) }
82
+
83
+ before do
84
+ stub_request(:any, /_test/).to_return(body: body.to_json)
85
+ end
86
+
87
+ it 'requests at `path` argument' do
88
+ do_request
89
+
90
+ expect(WebMock).to have_requested(verb, url)
91
+ end
92
+
93
+ it 'passes request body' do
94
+ do_request
95
+
96
+ expect(WebMock)
97
+ .to have_requested(verb, url)
98
+ .with(body: body)
99
+ end
100
+
101
+ it 'returns parsed response body' do
102
+ expect(do_request).to eq(body)
103
+ end
104
+ end
105
+
106
+ describe '#get(path, options = {})' do
107
+ let(:request_params) { { 'test' => 123 } }
108
+ let(:response_body) { request_params }
109
+
110
+ include_examples 'param request', :get
111
+ end
112
+
113
+ describe '#delete(path, options = {})' do
114
+ let(:request_params) { { 'test' => 123 } }
115
+ let(:response_body) { {} }
116
+
117
+ include_examples 'param request', :delete
118
+ end
119
+
120
+ describe '#patch(path, req_body)' do
121
+ include_examples 'body request', :patch
122
+ end
123
+
124
+ describe '#post(path, req_body)' do
125
+ include_examples 'body request', :post
126
+ end
127
+
128
+ describe '#put(path, req_body)' do
129
+ include_examples 'body request', :put
130
+ end
131
+ end
@@ -0,0 +1,74 @@
1
+ require 'spec_helper'
2
+ require 'rack/utils'
3
+
4
+ RSpec.describe RockRMS::Error do
5
+ let(:client) {
6
+ RockRMS::Client.new(
7
+ url: 'http://some-rock-uri.com',
8
+ username: 'test',
9
+ password: 'test',
10
+ logger: false
11
+ )
12
+ }
13
+
14
+ CODES = Rack::Utils::HTTP_STATUS_CODES.keys.freeze
15
+
16
+ def stub(code, body)
17
+ stub_request(:any, /rock/).to_return(status: code, body: body)
18
+ end
19
+
20
+ def expect_failure(code, body)
21
+ expect {
22
+ client.get('anything')
23
+ }.to raise_error(RockRMS::Error, "#{code}: #{body}")
24
+ end
25
+
26
+ def expect_success
27
+ expect { client.get('anything') }.to_not raise_error
28
+ end
29
+
30
+ context 'informational responses' do
31
+ CODES.grep(100..199).each do |code|
32
+ it "does not raise error for #{code}" do
33
+ stub(code, '{}')
34
+ expect_success
35
+ end
36
+ end
37
+ end
38
+
39
+ context 'success responses' do
40
+ CODES.grep(200..299).each do |code|
41
+ it "does not raise error for #{code}" do
42
+ stub(code, '{}')
43
+ expect_success
44
+ end
45
+ end
46
+ end
47
+
48
+ context 'redirection responses' do
49
+ CODES.grep(300..399).each do |code|
50
+ it "does not raise error for #{code}" do
51
+ stub(code, '')
52
+ expect_success
53
+ end
54
+ end
55
+ end
56
+
57
+ context 'client error responses' do
58
+ CODES.grep(400..499).each do |code|
59
+ it "raises exception for #{code}" do
60
+ stub(code, 'test client error')
61
+ expect_failure(code, 'test client error')
62
+ end
63
+ end
64
+ end
65
+
66
+ context 'server error responses' do
67
+ CODES.grep(500..599).each do |code|
68
+ it "raises exception for #{code}" do
69
+ stub(code, 'test client error')
70
+ expect_failure(code, 'test client error')
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RockRMS do
4
+ it 'has a version number' do
5
+ expect(described_class::VERSION).to_not be_nil
6
+ end
7
+ end
@@ -0,0 +1,20 @@
1
+ $LOAD_PATH.unshift(File.join(__FILE__, "..", "..", "lib"))
2
+
3
+ require 'rock_rms'
4
+ require 'webmock/rspec'
5
+ require_relative './support/rock_mock'
6
+
7
+ RSpec.configure do |config|
8
+ config.before :suite do
9
+ WebMock.disable_net_connect!
10
+ end
11
+
12
+ config.before :each do
13
+ stub_request(:any, /rock/).to_rack(RockMock)
14
+ end
15
+
16
+ config.run_all_when_everything_filtered = true
17
+ config.filter_run :focus
18
+
19
+ config.order = 'random'
20
+ end
@@ -0,0 +1,23 @@
1
+ require 'sinatra/base'
2
+ require 'securerandom'
3
+
4
+ class RockMock < Sinatra::Base
5
+ post '/api/Auth/Login' do
6
+ content_type :json
7
+
8
+ response['Cache-Control'] = 'no-cache'
9
+ response['Content-Secuity-Policy'] = "frame-ancestors 'self'"
10
+ response['Date'] = Time.now.httpdate
11
+ response['Expires'] = '-1'
12
+ response['Pragma'] = 'no-cache'
13
+ response['Set-Cookie'] = [
14
+ ".ROCK=#{SecureRandom.hex(100)}",
15
+ "expires=#{(Time.now + 14).httpdate}",
16
+ 'path=/',
17
+ 'HttpOnly'
18
+ ].join('; ')
19
+ response['X-Frame-Options'] = 'SAMEORIGIN'
20
+
21
+ status 204
22
+ end
23
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rock_rms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Brooks
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-06 00:00:00.000000000 Z
11
+ date: 2017-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -68,6 +68,34 @@ dependencies:
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.15'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.15'
83
+ - !ruby/object:Gem::Dependency
84
+ name: dotenv
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
101
  - - ">="
@@ -80,18 +108,78 @@ dependencies:
80
108
  - - ">="
81
109
  - !ruby/object:Gem::Version
82
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '10.4'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '10.4'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '3.7'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '3.7'
139
+ - !ruby/object:Gem::Dependency
140
+ name: sinatra
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '2.0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '2.0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: webmock
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '3.1'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '3.1'
83
167
  description: A Ruby wrapper for the Rock RMS API -- a church management platform,
84
168
  simplified.
85
169
  email:
86
170
  - tbrooks@gmail.com
87
- executables: []
171
+ executables:
172
+ - rspec
88
173
  extensions: []
89
174
  extra_rdoc_files: []
90
175
  files:
91
176
  - ".gitignore"
177
+ - ".ruby-version"
92
178
  - Gemfile
93
179
  - LICENSE
94
180
  - README.md
181
+ - Rakefile
182
+ - bin/rspec
95
183
  - lib/rock_rms.rb
96
184
  - lib/rock_rms/client.rb
97
185
  - lib/rock_rms/error.rb
@@ -106,6 +194,11 @@ files:
106
194
  - lib/rock_rms/responses/person.rb
107
195
  - lib/rock_rms/version.rb
108
196
  - rock_rms.gemspec
197
+ - spec/rock_rms/client_spec.rb
198
+ - spec/rock_rms/error_spec.rb
199
+ - spec/rock_rms_spec.rb
200
+ - spec/spec_helper.rb
201
+ - spec/support/rock_mock.rb
109
202
  homepage: https://github.com/taylorbrooks/rock_rms
110
203
  licenses:
111
204
  - MIT
@@ -116,9 +209,9 @@ require_paths:
116
209
  - lib
117
210
  required_ruby_version: !ruby/object:Gem::Requirement
118
211
  requirements:
119
- - - ">="
212
+ - - "~>"
120
213
  - !ruby/object:Gem::Version
121
- version: '0'
214
+ version: '2.2'
122
215
  required_rubygems_version: !ruby/object:Gem::Requirement
123
216
  requirements:
124
217
  - - ">="
@@ -126,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
219
  version: '0'
127
220
  requirements: []
128
221
  rubyforge_project:
129
- rubygems_version: 2.6.8
222
+ rubygems_version: 2.4.8
130
223
  signing_key:
131
224
  specification_version: 4
132
225
  summary: A Ruby wrapper for the Rock RMS API