lib/cloudflare/rspec/connection.rb in cloudflare-3.2.1 vs lib/cloudflare/rspec/connection.rb in cloudflare-4.0.0

- old
+ new

@@ -18,21 +18,28 @@ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. +require 'async/rspec' require_relative '../../cloudflare' module Cloudflare - module RSpec - module Connection - end + module RSpec + module Connection + end - RSpec.shared_context Connection do - # You must specify these in order for the tests to run. - let(:email) { 'jake@example.net' } - let(:key) { '5up3rS3cr3tAuthK3y' } - - let(:connection) { Cloudflare.connect(key: key, email: email) } - end - end + RSpec.shared_context Connection do + include_context Async::RSpec::Reactor + + # You must specify these in order for the tests to run. + let(:email) {ENV['CLOUDFLARE_EMAIL']} + let(:key) {ENV['CLOUDFLARE_KEY']} + + let(:connection) {@connection = Cloudflare.connect(key: key, email: email)} + + after do + @connection&.close + end + end + end end