bitcoin_payable 0.0.1

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.
Files changed (83) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +4 -0
  3. data/Gemfile.lock +158 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +125 -0
  6. data/Rakefile +3 -0
  7. data/bitcoin_payable.gemspec +35 -0
  8. data/features/bitcoin_payments.feature +20 -0
  9. data/features/default.feature +5 -0
  10. data/features/pricing_processor.feature +4 -0
  11. data/features/step_definitions/bitcoin_payment_steps.rb +16 -0
  12. data/features/step_definitions/currency_conversion_steps.rb +4 -0
  13. data/features/step_definitions/model_step.rb +11 -0
  14. data/features/step_definitions/widget_steps.rb +3 -0
  15. data/features/support/env.rb +33 -0
  16. data/lib/bitcoin_payable.rb +23 -0
  17. data/lib/bitcoin_payable/address.rb +24 -0
  18. data/lib/bitcoin_payable/bitcoin_calculator.rb +15 -0
  19. data/lib/bitcoin_payable/bitcoin_payment.rb +64 -0
  20. data/lib/bitcoin_payable/bitcoin_payment_transaction.rb +7 -0
  21. data/lib/bitcoin_payable/commands/payment_processor.rb +38 -0
  22. data/lib/bitcoin_payable/commands/pricing_processor.rb +46 -0
  23. data/lib/bitcoin_payable/config.rb +13 -0
  24. data/lib/bitcoin_payable/currency_conversion.rb +4 -0
  25. data/lib/bitcoin_payable/has_bitcoin_payment.rb +16 -0
  26. data/lib/bitcoin_payable/tasks.rb +17 -0
  27. data/lib/bitcoin_payable/version.rb +3 -0
  28. data/lib/generators/bitcoin_payable/install_generator.rb +22 -0
  29. data/lib/generators/bitcoin_payable/templates/create_bitcoin_payment_transactions.rb +15 -0
  30. data/lib/generators/bitcoin_payable/templates/create_bitcoin_payments.rb +17 -0
  31. data/lib/generators/bitcoin_payable/templates/create_currency_conversions.rb +10 -0
  32. data/spec/dummy/README.rdoc +28 -0
  33. data/spec/dummy/Rakefile +6 -0
  34. data/spec/dummy/app/assets/images/.keep +0 -0
  35. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  36. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  37. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  38. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  39. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  40. data/spec/dummy/app/mailers/.keep +0 -0
  41. data/spec/dummy/app/models/.keep +0 -0
  42. data/spec/dummy/app/models/concerns/.keep +0 -0
  43. data/spec/dummy/app/models/widget.rb +3 -0
  44. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  45. data/spec/dummy/bin/bundle +3 -0
  46. data/spec/dummy/bin/rails +4 -0
  47. data/spec/dummy/bin/rake +4 -0
  48. data/spec/dummy/config.ru +4 -0
  49. data/spec/dummy/config/application.rb +23 -0
  50. data/spec/dummy/config/boot.rb +5 -0
  51. data/spec/dummy/config/database.yml +25 -0
  52. data/spec/dummy/config/environment.rb +5 -0
  53. data/spec/dummy/config/environments/development.rb +29 -0
  54. data/spec/dummy/config/environments/production.rb +80 -0
  55. data/spec/dummy/config/environments/test.rb +36 -0
  56. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  57. data/spec/dummy/config/initializers/bitcoin_payable.rb +1 -0
  58. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  59. data/spec/dummy/config/initializers/inflections.rb +16 -0
  60. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  61. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  62. data/spec/dummy/config/initializers/session_store.rb +3 -0
  63. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  64. data/spec/dummy/config/locales/en.yml +23 -0
  65. data/spec/dummy/config/routes.rb +56 -0
  66. data/spec/dummy/db/development.sqlite3 +0 -0
  67. data/spec/dummy/db/migrate/20140510023211_create_widgets.rb +8 -0
  68. data/spec/dummy/db/migrate/20140510025739_create_bitcoin_payments.rb +17 -0
  69. data/spec/dummy/db/migrate/20140510025740_create_bitcoin_payment_transactions.rb +10 -0
  70. data/spec/dummy/db/migrate/20140511021326_create_currency_conversions.rb +10 -0
  71. data/spec/dummy/db/schema.rb +50 -0
  72. data/spec/dummy/db/test.sqlite3 +0 -0
  73. data/spec/dummy/lib/assets/.keep +0 -0
  74. data/spec/dummy/log/.keep +0 -0
  75. data/spec/dummy/log/development.log +85 -0
  76. data/spec/dummy/log/test.log +384 -0
  77. data/spec/dummy/public/404.html +58 -0
  78. data/spec/dummy/public/422.html +58 -0
  79. data/spec/dummy/public/500.html +57 -0
  80. data/spec/dummy/public/favicon.ico +0 -0
  81. data/spec/dummy/test/fixtures/widgets.yml +11 -0
  82. data/spec/dummy/test/models/widget_test.rb +7 -0
  83. metadata +325 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2f5d9650ea027c2efde7202dd4022609f33cb429
4
+ data.tar.gz: 63490e5bdfce90487c755d9377656b601b917768
5
+ SHA512:
6
+ metadata.gz: 1ae414724a5c27d25c9e89e773a6e88e0b69616b678d734ca9402c6fc50500f1dbe62b6cd79c424b1c7e21c3e81451fa9f36646f076a8de2a5e9de84c8889378
7
+ data.tar.gz: bb5355b2584488fd3be82401c5228fcbeb4e4df3d104adcd6863697642498dc18871831088a7a4f494083c73ad5c48316263bccab5ed679e9da4af0ba33556b5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bitcoin_payable.gemspec
4
+ gemspec
@@ -0,0 +1,158 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ bitcoin_payable (0.0.1)
5
+ cucumber-rails
6
+ database_cleaner
7
+ helloblock
8
+ money-tree
9
+ rails (~> 4.0.0)
10
+ rspec-rails
11
+ state_machine
12
+
13
+ GEM
14
+ remote: https://rubygems.org/
15
+ specs:
16
+ actionmailer (4.0.5)
17
+ actionpack (= 4.0.5)
18
+ mail (~> 2.5.4)
19
+ actionpack (4.0.5)
20
+ activesupport (= 4.0.5)
21
+ builder (~> 3.1.0)
22
+ erubis (~> 2.7.0)
23
+ rack (~> 1.5.2)
24
+ rack-test (~> 0.6.2)
25
+ activemodel (4.0.5)
26
+ activesupport (= 4.0.5)
27
+ builder (~> 3.1.0)
28
+ activerecord (4.0.5)
29
+ activemodel (= 4.0.5)
30
+ activerecord-deprecated_finders (~> 1.0.2)
31
+ activesupport (= 4.0.5)
32
+ arel (~> 4.0.0)
33
+ activerecord-deprecated_finders (1.0.3)
34
+ activesupport (4.0.5)
35
+ i18n (~> 0.6, >= 0.6.9)
36
+ minitest (~> 4.2)
37
+ multi_json (~> 1.3)
38
+ thread_safe (~> 0.1)
39
+ tzinfo (~> 0.3.37)
40
+ arel (4.0.2)
41
+ builder (3.1.4)
42
+ capybara (2.3.0)
43
+ mime-types (>= 1.16)
44
+ nokogiri (>= 1.3.3)
45
+ rack (>= 1.0.0)
46
+ rack-test (>= 0.5.4)
47
+ xpath (~> 2.0)
48
+ cucumber (1.3.15)
49
+ builder (>= 2.1.2)
50
+ diff-lcs (>= 1.1.3)
51
+ gherkin (~> 2.12)
52
+ multi_json (>= 1.7.5, < 2.0)
53
+ multi_test (>= 0.1.1)
54
+ cucumber-rails (1.4.1)
55
+ capybara (>= 1.1.2, < 3)
56
+ cucumber (>= 1.3.8, < 2)
57
+ mime-types (~> 1.16)
58
+ nokogiri (~> 1.5)
59
+ rails (>= 3, < 5)
60
+ database_cleaner (1.3.0)
61
+ diff-lcs (1.2.5)
62
+ erubis (2.7.0)
63
+ faraday (0.9.0)
64
+ multipart-post (>= 1.2, < 3)
65
+ faraday_middleware (0.9.1)
66
+ faraday (>= 0.7.4, < 0.10)
67
+ ffi (1.9.3)
68
+ gherkin (2.12.2)
69
+ multi_json (~> 1.3)
70
+ hashie (2.0.5)
71
+ helloblock (0.0.2)
72
+ faraday_middleware (~> 0.9)
73
+ json
74
+ multi_json (~> 1.9)
75
+ rash (~> 0.4)
76
+ yajl-ruby (~> 1.2)
77
+ hike (1.2.3)
78
+ i18n (0.6.9)
79
+ json (1.8.1)
80
+ mail (2.5.4)
81
+ mime-types (~> 1.16)
82
+ treetop (~> 1.4.8)
83
+ mime-types (1.25.1)
84
+ mini_portile (0.6.0)
85
+ minitest (4.7.5)
86
+ money-tree (0.8.7)
87
+ ffi
88
+ multi_json (1.10.1)
89
+ multi_test (0.1.1)
90
+ multipart-post (2.0.0)
91
+ nokogiri (1.6.2.1)
92
+ mini_portile (= 0.6.0)
93
+ polyglot (0.3.5)
94
+ rack (1.5.2)
95
+ rack-test (0.6.2)
96
+ rack (>= 1.0)
97
+ rails (4.0.5)
98
+ actionmailer (= 4.0.5)
99
+ actionpack (= 4.0.5)
100
+ activerecord (= 4.0.5)
101
+ activesupport (= 4.0.5)
102
+ bundler (>= 1.3.0, < 2.0)
103
+ railties (= 4.0.5)
104
+ sprockets-rails (~> 2.0.0)
105
+ railties (4.0.5)
106
+ actionpack (= 4.0.5)
107
+ activesupport (= 4.0.5)
108
+ rake (>= 0.8.7)
109
+ thor (>= 0.18.1, < 2.0)
110
+ rake (10.3.1)
111
+ rash (0.4.0)
112
+ hashie (~> 2.0.0)
113
+ rspec-core (3.0.1)
114
+ rspec-support (~> 3.0.0)
115
+ rspec-expectations (3.0.1)
116
+ diff-lcs (>= 1.2.0, < 2.0)
117
+ rspec-support (~> 3.0.0)
118
+ rspec-mocks (3.0.1)
119
+ rspec-support (~> 3.0.0)
120
+ rspec-rails (3.0.1)
121
+ actionpack (>= 3.0)
122
+ activesupport (>= 3.0)
123
+ railties (>= 3.0)
124
+ rspec-core (~> 3.0.0)
125
+ rspec-expectations (~> 3.0.0)
126
+ rspec-mocks (~> 3.0.0)
127
+ rspec-support (~> 3.0.0)
128
+ rspec-support (3.0.0)
129
+ sprockets (2.12.1)
130
+ hike (~> 1.2)
131
+ multi_json (~> 1.0)
132
+ rack (~> 1.0)
133
+ tilt (~> 1.1, != 1.3.0)
134
+ sprockets-rails (2.0.1)
135
+ actionpack (>= 3.0)
136
+ activesupport (>= 3.0)
137
+ sprockets (~> 2.8)
138
+ sqlite3 (1.3.9)
139
+ state_machine (1.2.0)
140
+ thor (0.19.1)
141
+ thread_safe (0.3.4)
142
+ tilt (1.4.1)
143
+ treetop (1.4.15)
144
+ polyglot
145
+ polyglot (>= 0.3.1)
146
+ tzinfo (0.3.39)
147
+ xpath (2.0.0)
148
+ nokogiri (~> 1.3)
149
+ yajl-ruby (1.2.1)
150
+
151
+ PLATFORMS
152
+ ruby
153
+
154
+ DEPENDENCIES
155
+ bitcoin_payable!
156
+ bundler (~> 1.3)
157
+ rake
158
+ sqlite3 (~> 1.2)
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Jonathan Salis
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,125 @@
1
+ # BitcoinPayable
2
+
3
+ A rails gem that enables any model to have bitcoin payments.
4
+ The polymorhpic table bitcoin_payments creates payments with unique addresses based on a BIP32 deterministic seed using https://github.com/wink/money-tree
5
+ and uses the https://helloblock.io API to check for payments.
6
+
7
+ Payments have 3 states: `pending`, `partial_payment`, `paid_in_full`
8
+
9
+ No private keys needed, No bitcoind blockchain indexing on new servers, just address and payments.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ gem 'bitcoin_payable'
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ $ rails g bitcoin_payable:install
22
+
23
+ $ bundle exec rake db:migrate
24
+
25
+ Or install it yourself as:
26
+
27
+ $ gem install bitcoin_payable
28
+
29
+ ## Usage
30
+
31
+ ### Configuration
32
+
33
+ config/initializers/bitcoin_payable.rb
34
+
35
+ BitcoinPayable.config.currency = :cad
36
+ BitcoinPayable.config.master_seed = ENV["MASTER_SEED"] # Use master_seed OR master_public_key
37
+ BitcoinPayable.config.master_public_key = ENV["MASTER_PUBLIC_KEY"]
38
+ BitcoinPayable.config.testnet = true
39
+
40
+ #### Master Seed
41
+
42
+ The 32 Hex master seed.
43
+ Reference: https://github.com/wink/money-tree#create-a-master-node-seed
44
+
45
+ #### Master Public Key
46
+
47
+ A BIP32 MPK in "Extended Key" format.
48
+
49
+ ### Adding it to your model
50
+
51
+ class Product < ActiveRecord::Base
52
+ has_bitcoin_payments
53
+ end
54
+
55
+ ### Creating a payment from your application
56
+
57
+ def create_payment(amount_in_cents)
58
+ self.bitcoin_payments.create!(reason: 'sale', price: amount_in_cents)
59
+ end
60
+
61
+ ### Update payments with the current price of BTC based on your currency
62
+
63
+ BitcoinPayable also supports local currency conversions and BTC exchange rates.
64
+
65
+ The `process_prices` rake task connects to api.bitcoinaverage.com to get the 24 hour weighted average of BTC for your specified currency.
66
+ It then updates all payments that havent received an update in the last 30 minutes with the new value owing in BTC.
67
+ This *honors* the price of a payment for 30 minutes at a time.
68
+
69
+ rake bitcoin_payable:process_prices
70
+
71
+ ### Processing payments
72
+
73
+ All payments are calculated against the dollar amount of the payment. So a `bitcoin_payment` for $49.99 will have it's value calculated in BTC.
74
+ It will stay at that price for 30 minutes. When a payment is made, a transaction is created that stores the BTC in satoshis paid, and the exchange rate is was paid at.
75
+ This is very valuable for accounting later. (capital gains of all payments received)
76
+
77
+ If a partial payment is made, the BTC value is recalculated for the remaining *dollar* amount with the latest exchange rate.
78
+ This means that if someone pays 0.01 for a 0.5 payment, that 0.01 is converted into dollars at the time of processing and the
79
+ remaining amount is calculated in dollars and the remaining amount in BTC is issued. (If BTC bombs, that value could be greater than 0.5 now)
80
+
81
+ This prevents people from gaming the payments by paying very little BTC in hopes the price will rise.
82
+ Payments are not recalculated based on the current value of BTC, but in dollars.
83
+
84
+ To run the payment processor:
85
+
86
+ `rake bitcoin_payable:process_payments`
87
+
88
+ ### Notify your application when a payment is made
89
+
90
+ Use the `bitcoin_payment_paid` method
91
+
92
+ def Product < ActiveRecord::Base
93
+ has_bitcoin_payments
94
+
95
+ def create_payment(amount_in_cents)
96
+ self.bitcoin_payments.create!(reason: 'sale', price: amount_in_cents)
97
+ end
98
+
99
+ def bitcoin_payment_paid
100
+ self.ship!
101
+ end
102
+ end
103
+
104
+ ### View all the transactions in the payment
105
+
106
+ bitcoin_payment = @product.bitcoin_payments.first
107
+ bitcoin_payment.transactions.each do |transaction|
108
+ puts transaction.block_hash
109
+ puts transaction.block_time
110
+
111
+ puts transaction.transaction_hash
112
+
113
+ puts transaction.estimated_value
114
+ puts transaction.estimated_time
115
+
116
+ puts transaction.btc_conversion
117
+ end
118
+
119
+ ## Contributing
120
+
121
+ 1. Fork it
122
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
123
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
124
+ 4. Push to the branch (`git push origin my-new-feature`)
125
+ 5. Create new Pull Request
@@ -0,0 +1,3 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake'
3
+ require 'bitcoin_payable/tasks'
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bitcoin_payable/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bitcoin_payable"
8
+ spec.version = BitcoinPayable::VERSION
9
+ spec.authors = ["Jonathan Salis"]
10
+ spec.email = ["jon.salis@bitcoinsultants.ca"]
11
+ spec.description = %q{A Bitcoin payment processor}
12
+ spec.summary = %q{A Bitcoin payment processor}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency 'sqlite3', '~> 1.2'
24
+
25
+ spec.required_rubygems_version = '>= 1.3.6'
26
+
27
+ spec.add_dependency "rails", "~> 4.0.0"
28
+ spec.add_dependency "cucumber-rails"
29
+ spec.add_dependency "rspec-rails"
30
+ spec.add_dependency "database_cleaner"
31
+ #spec.add_dependency "bitcoin-addrgen"
32
+ spec.add_dependency "state_machine"
33
+ spec.add_dependency "helloblock"
34
+ spec.add_dependency "money-tree"
35
+ end
@@ -0,0 +1,20 @@
1
+ Feature: BitcoinPayment creation, validation and state
2
+
3
+ Background:
4
+ Given a saved widget
5
+
6
+ Scenario Outline: A saved widget can create a payment
7
+ Given a new bitcoin_payment
8
+ Then the bitcoin_payment field <field> is set to <value>
9
+ And the bitcoin_payment field amount_due is set to 1
10
+ When the bitcoin_payment is saved
11
+ Then the bitcoin_payment should have an address
12
+ And the bitcoin_payment should have the state pending
13
+
14
+ Examples:
15
+
16
+ | field | value |
17
+ | reason | New Payment |
18
+
19
+
20
+
@@ -0,0 +1,5 @@
1
+ Feature: Testing an empty widget
2
+
3
+ Scenario: An unsaved widget should respond to bitcoin_payments
4
+ Given an unsaved widget
5
+ Then the widget should have 0 bitcoin_payments
@@ -0,0 +1,4 @@
1
+ Feature: Pricing Processor tests
2
+
3
+ Scenario: The test framework should set up 3 currency conversions
4
+ Given there should be 3 currency_conversions
@@ -0,0 +1,16 @@
1
+ Given /^the bitcoin_payment field (\S*) is set to (.*)/ do |field, value|
2
+ @bitcoin_payment.send("#{field}=", value)
3
+ end
4
+
5
+ Given /^the bitcoin_payment is saved$/ do
6
+ @bitcoin_payment.save
7
+ @bitcoin_payment.reload.new_record?.should be_false
8
+ end
9
+
10
+ Given /^the bitcoin_payment should have an address$/ do
11
+ @bitcoin_payment.address.should_not be_nil
12
+ end
13
+
14
+ Given /^the bitcoin_payment should have the state (\S+)$/ do |state|
15
+ @bitcoin_payment.state.should eq(state)
16
+ end
@@ -0,0 +1,4 @@
1
+ Given /^there should be (\d+) currency_conversions?$/ do |n|
2
+ @currency_conversions.should_not be_nil
3
+ @currency_conversions.count.should eql(n.to_i)
4
+ end
@@ -0,0 +1,11 @@
1
+ Given /^an unsaved widget$/ do
2
+ @widget = Widget.new
3
+ end
4
+
5
+ Given /^a saved widget$/ do
6
+ @widget = Widget.create
7
+ end
8
+
9
+ Given /^a new bitcoin_payment$/ do
10
+ @bitcoin_payment = @widget.bitcoin_payments.new
11
+ end
@@ -0,0 +1,3 @@
1
+ Given /^the widget should have (\d+) bitcoin_payments$/ do |n|
2
+ @widget.bitcoin_payments.count.should eql(n.to_i)
3
+ end
@@ -0,0 +1,33 @@
1
+ ENV["RAILS_ENV"] ||= "test"
2
+ require File.expand_path("../../../spec/dummy/config/environment.rb", __FILE__)
3
+
4
+ ENV["RAILS_ROOT"] ||= File.dirname(__FILE__) + "../../../spec/dummy"
5
+
6
+ require 'cucumber/rails'
7
+ require 'cucumber/rspec/doubles'
8
+
9
+ # Remove/comment out the lines below if your app doesn't have a database.
10
+ # For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
11
+ begin
12
+ DatabaseCleaner.strategy = :transaction
13
+ rescue NameError
14
+ raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
15
+ end
16
+
17
+ Before do
18
+ 3.times do
19
+ BitcoinPayable::CurrencyConversion.create!(
20
+ currency: rand() * (0.99 - 0.85) + 0.85,
21
+ btc: (rand(500.0) + 500.0) * 100
22
+ )
23
+ end
24
+ @currency_conversions = BitcoinPayable::CurrencyConversion.all
25
+
26
+ # return_values = []
27
+ # 10.times do
28
+ # return_values << rand(500.0) + 500.0
29
+ # end
30
+
31
+ #allow_any_instance_of(BitcoinPayable::PricingProcessor).to receive(:get_btc).and_return { return_values.shift }
32
+ #allow_any_instance_of(BitcoinPayable::PricingProcessor).to receive(:get_currency).and_return(rand() * (0.99 - 0.85) + 0.85)
33
+ end