Skip to content

Commit

Permalink
Move helper files into spec/support
Browse files Browse the repository at this point in the history
  • Loading branch information
kaka-ruto committed Dec 19, 2023
1 parent 56b0463 commit 08ac2a0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 29 deletions.
30 changes: 1 addition & 29 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,7 @@
require 'cloudflare/rspec/connection'
require 'cloudflare/zones'

RSpec.shared_context Cloudflare::Account do
include_context Cloudflare::RSpec::Connection

let(:account) do
if ACCOUNT_ID
connection.accounts.find_by_id(ACCOUNT_ID)
else
connection.accounts.first
end
end
end

RSpec.shared_context Cloudflare::Zone do
include_context Cloudflare::Account

let(:job_id) {JOB_ID}
let(:names) {NAMES.dup}
let(:name) {ZONE_NAME.dup}

let(:zones) {connection.zones}

let(:zone) {@zone = zones.find_by_name(name) || zones.create(name, account)}

# after do
# if defined? @zone
# @zone.delete
# end
# end
end
Dir[File.expand_path('../support/**/*.rb', __FILE__)].each{|path| require path}

RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
Expand Down
13 changes: 13 additions & 0 deletions spec/support/cloudflare/account.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

RSpec.shared_context Cloudflare::Account do
include_context Cloudflare::RSpec::Connection

let(:account) do
if ACCOUNT_ID
connection.accounts.find_by_id(ACCOUNT_ID)
else
connection.accounts.first
end
end
end
17 changes: 17 additions & 0 deletions spec/support/cloudflare/zone.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

RSpec.shared_context Cloudflare::Zone do
include_context Cloudflare::Account

let(:job_id) { JOB_ID }
let(:names) { NAMES.dup }
let(:name) { ZONE_NAME.dup }

let(:zones) { connection.zones }

let(:zone) { @zone = zones.find_by_name(name) || zones.create(name, account) }

after do
@zone.delete if defined? @zone
end
end

0 comments on commit 08ac2a0

Please sign in to comment.