Skip to content

Commit

Permalink
move test-specific helpers inside RSpec.describe block
Browse files Browse the repository at this point in the history
If outside that block, the method or constant may bleed over into
another test file
  • Loading branch information
kspurgin committed Oct 1, 2021
1 parent 4c020d1 commit d294534
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
21 changes: 10 additions & 11 deletions spec/kiba/extend/destinations/csv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@

require 'spec_helper'

TEST_FILENAME = 'output.csv'

def run_job(input)
job = Kiba.parse do
source Kiba::Common::Sources::Enumerable, input
destination Kiba::Extend::Destinations::CSV, filename: TEST_FILENAME, initial_headers: %i[y z]
end
RSpec.describe Kiba::Extend::Destinations::CSV do
TEST_FILENAME = 'output.csv'
def run_job(input)
job = Kiba.parse do
source Kiba::Common::Sources::Enumerable, input
destination Kiba::Extend::Destinations::CSV, filename: TEST_FILENAME, initial_headers: %i[y z]
end

Kiba.run(job)
Kiba.run(job)

IO.read(TEST_FILENAME)
end
IO.read(TEST_FILENAME)
end

RSpec.describe Kiba::Extend::Destinations::CSV do
after(:each){ File.delete(TEST_FILENAME) if File.exist?(TEST_FILENAME) }

context 'when intial headers present' do
Expand Down
20 changes: 10 additions & 10 deletions spec/kiba/extend/destinations/json_array_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

require 'spec_helper'

TEST_FILENAME = 'output.json'
RSpec.describe Kiba::Extend::Destinations::JsonArray do
TEST_FILENAME = 'output.json'

def run_job(input)
job = Kiba.parse do
source Kiba::Common::Sources::Enumerable, input
destination Kiba::Extend::Destinations::JsonArray, filename: TEST_FILENAME
end
def run_job(input)
job = Kiba.parse do
source Kiba::Common::Sources::Enumerable, input
destination Kiba::Extend::Destinations::JsonArray, filename: TEST_FILENAME
end

Kiba.run(job)
Kiba.run(job)

IO.read(TEST_FILENAME)
end
IO.read(TEST_FILENAME)
end

RSpec.describe Kiba::Extend::Destinations::JsonArray do
after(:each){ File.delete(TEST_FILENAME) if File.exist?(TEST_FILENAME) }

context 'when simplest data ever' do
Expand Down

0 comments on commit d294534

Please sign in to comment.