testcloud-billing-ruby 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f25d46c63d454a9546bb872d34c6e484ed72b4c6
4
- data.tar.gz: 9e0bdc04d2159f6a1ce06e95620334baf5e30731
3
+ metadata.gz: 305b345dbd0ee4b20aef652a774b68726f93ca34
4
+ data.tar.gz: 22e801362ac96a51f68697bd2ce9b987d26eb272
5
5
  SHA512:
6
- metadata.gz: d526cb4f9fb219653069844e00e0fbe4e7b687a029415c476ffa7de27da2c685bc65ef05589d10829f94006d7fb47400e8cc4b193c402adcba0d75c12375dd77
7
- data.tar.gz: b1c732b0722b311eb23c89540c06e5bb0dc60162182d016e71db953da168b9e86650b71819e961978094c9172c6cd3865358e76851756ec7078842e917450e28
6
+ metadata.gz: e6fe73860f2f243cc8a3ab15a9aaa2950ebc9790bc914ef0583cd5ca19c56c214d11565762e1bfae5c21dabbf42ba2f188c2b4219826dbf8af023604bf09b4fb
7
+ data.tar.gz: dd8e06798a8b9c7bfda7c67b7f7e4286b0aa741ea3e9cfa3edd1fced4b06095289bb1fb13ad3f4c72e4eb4c543770443b452729c2d27faa191c5d663bb770f10
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Guardfile ADDED
@@ -0,0 +1,33 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ # Note: The cmd option is now required due to the increasing number of ways
5
+ # rspec may be run, below are examples of the most common uses.
6
+ # * bundler: 'bundle exec rspec'
7
+ # * bundler binstubs: 'bin/rspec'
8
+ # * spring: 'bin/rsspec' (This will use spring if running and you have
9
+ # installed the spring binstubs per the docs)
10
+ # * zeus: 'zeus rspec' (requires the server to be started separetly)
11
+ # * 'just' rspec: 'rspec'
12
+ guard :rspec, cmd: 'bundle exec rspec' do
13
+ watch(%r{^spec/.+_spec\.rb$})
14
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
15
+ watch('spec/spec_helper.rb') { "spec" }
16
+
17
+ # Rails example
18
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
19
+ watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
20
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
21
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
22
+ watch('config/routes.rb') { "spec/routing" }
23
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
24
+ watch('spec/rails_helper.rb') { "spec" }
25
+
26
+ # Capybara features specs
27
+ watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
28
+
29
+ # Turnip features and steps
30
+ watch(%r{^spec/acceptance/(.+)\.feature$})
31
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
32
+ end
33
+
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Testcloud::Billing::Ruby
2
2
 
3
- TODO: Write a gem description
3
+ [![Gem Version](https://badge.fury.io/rb/testcloud-billing-ruby.svg)](http://badge.fury.io/rb/testcloud-billing-ruby)
4
+
5
+ Connecting to the testCloud Billing API (currently only used internally).
4
6
 
5
7
  ## Installation
6
8
 
@@ -47,10 +49,9 @@ Create a Customer (in this case with SEPA direct debit payment):
47
49
  For credit card customers use this:
48
50
 
49
51
  ...
50
- timezone: "Berlin",
51
52
  payment_method: "credit_card",
52
- credit_card_data_attributes: {
53
- stripe_token: "THESTRIPETOKEN", # from Stripe.js
53
+ credit_card_data_attributes: { # from Stripe.js
54
+ stripe_token: "THESTRIPETOKEN",
54
55
  last4: "4242",
55
56
  brand: "visa",
56
57
  exp_month: "05",
@@ -60,7 +61,7 @@ For credit card customers use this:
60
61
  }
61
62
 
62
63
 
63
- To bill a customer:
64
+ Billing a customer:
64
65
 
65
66
  bill = Testcloud::Billing::Bill.create(
66
67
  customer_id: customer.id,
@@ -80,7 +81,7 @@ To bill a customer:
80
81
 
81
82
  ## Contributing
82
83
 
83
- 1. Fork it ( https://github.com/[my-github-username]/testcloud-billing-ruby/fork )
84
+ 1. Fork it ( https://github.com/testCloud/testcloud-billing-ruby/fork )
84
85
  2. Create your feature branch (`git checkout -b my-new-feature`)
85
86
  3. Commit your changes (`git commit -am 'Add some feature'`)
86
87
  4. Push to the branch (`git push origin my-new-feature`)
data/Rakefile CHANGED
@@ -1,2 +1,10 @@
1
+ require 'rspec/core/rake_task'
1
2
  require "bundler/gem_tasks"
2
3
 
4
+ # Default directory to look in is `/specs`
5
+ # Run with `rake spec`
6
+ RSpec::Core::RakeTask.new(:spec) do |task|
7
+ task.rspec_opts = ['--color', '--format', 'documentation']
8
+ end
9
+
10
+ task :default => :spec
@@ -0,0 +1,10 @@
1
+ module Testcloud
2
+ module Billing
3
+ class CreditCardDatum
4
+
5
+ include Her::Model
6
+ use_api Testcloud::Billing::HER
7
+
8
+ end
9
+ end
10
+ end
@@ -6,6 +6,11 @@ module Testcloud
6
6
  use_api Testcloud::Billing::HER
7
7
 
8
8
  has_many :bills
9
+ has_one :sepa_data
10
+ has_one :credit_card_data
11
+
12
+ accepts_nested_attributes_for :sepa_data
13
+ accepts_nested_attributes_for :credit_card_data
9
14
 
10
15
  end
11
16
  end
@@ -1,7 +1,7 @@
1
1
  module Testcloud
2
2
  module Billing
3
3
  module Ruby
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
6
6
  end
7
7
  end
@@ -6,3 +6,5 @@ require "testcloud/billing/authentication"
6
6
 
7
7
  require "testcloud/billing/customer"
8
8
  require "testcloud/billing/bill"
9
+ require "testcloud/billing/sepa_datum"
10
+ require "testcloud/billing/credit_card_datum"
@@ -0,0 +1,10 @@
1
+ module Testcloud
2
+ module Billing
3
+ class SepaDatum
4
+
5
+ include Her::Model
6
+ use_api Testcloud::Billing::HER
7
+
8
+ end
9
+ end
10
+ end
@@ -10,7 +10,7 @@ module Testcloud
10
10
  options[:url] ||= DEFAULT_URL
11
11
  HER.setup url: options[:url] do |c|
12
12
  # Authentication
13
- c.use Testcloud::Billing::Authentication, api_key: options[:api_key]
13
+ c.use Testcloud::Billing::Authentication, api_key: options[:api_key] if options[:api_key].present?
14
14
  # Request
15
15
  c.use Faraday::Request::UrlEncoded
16
16
  # Response
@@ -0,0 +1,9 @@
1
+ describe Testcloud::Billing do
2
+
3
+ it 'should find nil for 404s' do
4
+ stub_request(:any, "bapi.testcloud.io/customers/1").to_return( status: 404 )
5
+ Testcloud::Billing.setup url: 'http://bapi.testcloud.io', api_key: '123456789qwertzuio'
6
+ expect( Testcloud::Billing::Customer.find(1) ).to be_nil
7
+ end
8
+
9
+ end
@@ -0,0 +1,93 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
+ # file to always be loaded, without a need to explicitly require it in any files.
5
+ #
6
+ # Given that it is always loaded, you are encouraged to keep this file as
7
+ # light-weight as possible. Requiring heavyweight dependencies from this file
8
+ # will add to the boot time of your test suite on EVERY test run, even for an
9
+ # individual file that may not need all of that loaded. Instead, consider making
10
+ # a separate helper file that requires the additional dependencies and performs
11
+ # the additional setup, and require it from the spec files that actually need it.
12
+ #
13
+ # The `.rspec` file also contains a few flags that are not defaults but that
14
+ # users commonly want.
15
+ #
16
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
+
18
+ require 'testcloud/billing/ruby'
19
+ require 'webmock/rspec'
20
+
21
+ RSpec.configure do |config|
22
+ # rspec-expectations config goes here. You can use an alternate
23
+ # assertion/expectation library such as wrong or the stdlib/minitest
24
+ # assertions if you prefer.
25
+ config.expect_with :rspec do |expectations|
26
+ # This option will default to `true` in RSpec 4. It makes the `description`
27
+ # and `failure_message` of custom matchers include text for helper methods
28
+ # defined using `chain`, e.g.:
29
+ # be_bigger_than(2).and_smaller_than(4).description
30
+ # # => "be bigger than 2 and smaller than 4"
31
+ # ...rather than:
32
+ # # => "be bigger than 2"
33
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
34
+ end
35
+
36
+ # rspec-mocks config goes here. You can use an alternate test double
37
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
38
+ config.mock_with :rspec do |mocks|
39
+ # Prevents you from mocking or stubbing a method that does not exist on
40
+ # a real object. This is generally recommended, and will default to
41
+ # `true` in RSpec 4.
42
+ mocks.verify_partial_doubles = true
43
+ end
44
+
45
+ # The settings below are suggested to provide a good initial experience
46
+ # with RSpec, but feel free to customize to your heart's content.
47
+ =begin
48
+ # These two settings work together to allow you to limit a spec run
49
+ # to individual examples or groups you care about by tagging them with
50
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
51
+ # get run.
52
+ config.filter_run :focus
53
+ config.run_all_when_everything_filtered = true
54
+
55
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
56
+ # For more details, see:
57
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
58
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
59
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
60
+ config.disable_monkey_patching!
61
+
62
+ # This setting enables warnings. It's recommended, but in some cases may
63
+ # be too noisy due to issues in dependencies.
64
+ config.warnings = true
65
+
66
+ # Many RSpec users commonly either run the entire suite or an individual
67
+ # file, and it's useful to allow more verbose output when running an
68
+ # individual spec file.
69
+ if config.files_to_run.one?
70
+ # Use the documentation formatter for detailed output,
71
+ # unless a formatter has already been configured
72
+ # (e.g. via a command-line flag).
73
+ config.default_formatter = 'doc'
74
+ end
75
+
76
+ # Print the 10 slowest examples and example groups at the
77
+ # end of the spec run, to help surface which specs are running
78
+ # particularly slow.
79
+ config.profile_examples = 10
80
+
81
+ # Run specs in random order to surface order dependencies. If you find an
82
+ # order dependency and want to debug it, you can fix the order by providing
83
+ # the seed, which is printed after each run.
84
+ # --seed 1234
85
+ config.order = :random
86
+
87
+ # Seed global randomization in this process using the `--seed` CLI option.
88
+ # Setting this allows you to use `--seed` to deterministically reproduce
89
+ # test failures related to randomization by passing the same `--seed` value
90
+ # as the one that triggered the failure.
91
+ Kernel.srand config.seed
92
+ =end
93
+ end
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["jan.schwenzien@testcloud.io"]
11
11
  spec.summary = %q{Ruby client for the testCloud billing app.}
12
12
  spec.description = %q{Ruby client for the testCloud billing app built on Her.}
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/testCloud/testcloud-billing-ruby"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
@@ -20,6 +20,11 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.7"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "rspec-nc"
25
+ spec.add_development_dependency "guard"
26
+ spec.add_development_dependency "guard-rspec"
27
+ spec.add_development_dependency "webmock"
23
28
 
24
29
  spec.add_runtime_dependency "her", "~> 0.7"
25
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testcloud-billing-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Schwenzien
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-13 00:00:00.000000000 Z
11
+ date: 2014-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,76 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-nc
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard-rspec
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: webmock
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
41
111
  - !ruby/object:Gem::Dependency
42
112
  name: her
43
113
  requirement: !ruby/object:Gem::Requirement
@@ -60,18 +130,24 @@ extensions: []
60
130
  extra_rdoc_files: []
61
131
  files:
62
132
  - ".gitignore"
133
+ - ".rspec"
63
134
  - Gemfile
135
+ - Guardfile
64
136
  - LICENSE.txt
65
137
  - README.md
66
138
  - Rakefile
67
139
  - lib/testcloud/billing.rb
68
140
  - lib/testcloud/billing/authentication.rb
69
141
  - lib/testcloud/billing/bill.rb
142
+ - lib/testcloud/billing/credit_card_datum.rb
70
143
  - lib/testcloud/billing/customer.rb
71
144
  - lib/testcloud/billing/ruby.rb
72
145
  - lib/testcloud/billing/ruby/version.rb
146
+ - lib/testcloud/billing/sepa_datum.rb
147
+ - spec/auth_failure_spec.rb
148
+ - spec/spec_helper.rb
73
149
  - testcloud-billing-ruby.gemspec
74
- homepage: ''
150
+ homepage: https://github.com/testCloud/testcloud-billing-ruby
75
151
  licenses:
76
152
  - MIT
77
153
  metadata: {}
@@ -95,4 +171,6 @@ rubygems_version: 2.2.2
95
171
  signing_key:
96
172
  specification_version: 4
97
173
  summary: Ruby client for the testCloud billing app.
98
- test_files: []
174
+ test_files:
175
+ - spec/auth_failure_spec.rb
176
+ - spec/spec_helper.rb