Skip to content

Commit ff598d9

Browse files
committed
Fix for rubocop-rspec 0.20.1
1 parent ff7cb07 commit ff598d9

22 files changed

+103
-102
lines changed

spec/daru/io/exporters/avro_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
)
99
end
1010

11-
include_context 'exporter setup'
11+
include_context 'with exporter setup'
1212

1313
let(:filename) { 'test.avro' }
1414

1515
before { described_class.new(df, schema).write(tempfile.path) }
1616

17-
context 'writes DataFrame to an Avro file' do
17+
context 'when writes DataFrame to an Avro file' do
1818
context 'when schema is Hash' do
1919
let(:schema) do
2020
{

spec/daru/io/exporters/csv_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
RSpec.describe Daru::IO::Exporters::CSV do
22
subject { File.open(tempfile.path, &:readline).chomp.split(',', -1) }
33

4-
include_context 'exporter setup'
4+
include_context 'with exporter setup'
55

66
let(:filename) { 'test.csv' }
77

88
before { described_class.new(df, opts).write(tempfile.path) }
99

10-
context 'writes DataFrame to a CSV file' do
10+
context 'when writes DataFrame to a CSV file' do
1111
subject { Daru::DataFrame.rows content[1..-1].map { |x| x.map { |y| convert(y) } }, order: content[0] }
1212

1313
let(:opts) { {} }
@@ -25,20 +25,20 @@
2525
]
2626
end
2727

28-
context 'writes headers unless headers=false' do
28+
context 'when writes headers unless headers=false' do
2929
it { is_expected.to be_an(Array) }
3030
it { is_expected.to eq(df.vectors.to_a) }
3131
end
3232

33-
context 'does not write headers when headers=false' do
33+
context 'when does not write headers when headers=false' do
3434
let(:headers) { false }
3535
let(:opts) { {headers: headers} }
3636

3737
it { is_expected.to be_an(Array) }
3838
it { is_expected.to eq(df.head(1).map { |v| (v.first || '').to_s }) }
3939
end
4040

41-
context 'writes convert_comma only on float values' do
41+
context 'when writes convert_comma only on float values' do
4242
subject { CSV.read(tempfile.path, col_sep: ';') }
4343

4444
let(:df) { Daru::DataFrame.new('a' => [1, 4.4, nil, 'Sr. Arthur']) }
@@ -47,7 +47,7 @@
4747
it { is_expected.to eq([['a'], ['1'], ['4,4'], [''], ['Sr. Arthur']]) }
4848
end
4949

50-
context 'writes into .csv.gz format' do
50+
context 'when writes into .csv.gz format' do
5151
subject { Zlib::GzipReader.new(open(tempfile.path)).read.split("\n") }
5252

5353
let(:opts) { {compression: :gzip} }
@@ -57,7 +57,7 @@
5757
it { is_expected.to eq(['a,b,c,d', '1,11,a,', '2,22,g,23', '3,33,4,4', '4,44,5,a', '5,55,addadf,ff']) }
5858
end
5959

60-
context 'writes into .csv.gz format with only order' do
60+
context 'when writes into .csv.gz format with only order' do
6161
subject { Zlib::GzipReader.new(open(tempfile.path)).read.split("\n") }
6262

6363
let(:df) { Daru::DataFrame.new('a' => [], 'b' => [], 'c' => [], 'd' => []) }

spec/daru/io/exporters/excel_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
RSpec.describe Daru::IO::Exporters::Excel do
2-
include_context 'exporter setup'
2+
include_context 'with exporter setup'
33

44
let(:filename) { 'test_write.xls' }
55
let(:content) { Spreadsheet.open tempfile.path }
66
let(:opts) { {header: {color: :blue}, data: {color: :red}, index: {color: :green}} }
77

88
before { described_class.new(df, **opts).write(tempfile.path) }
99

10-
context 'writes to excel spreadsheet' do
10+
context 'when writes to excel spreadsheet' do
1111
subject do
1212
Daru::DataFrame.rows(
1313
Spreadsheet.open(tempfile.path).worksheet(0).rows[1..-1].map(&:to_a),
@@ -29,25 +29,25 @@
2929
]
3030
end
3131

32-
context 'writes to excel spreadsheet with header formatting' do
32+
context 'when writes to excel spreadsheet with header formatting' do
3333
subject { Spreadsheet.open(tempfile.path).worksheet(0).rows[0].format(0).font.color }
3434

3535
it { is_expected.to eq(:blue) }
3636
end
3737

38-
context 'writes to excel spreadsheet with index formatting' do
38+
context 'when writes to excel spreadsheet with index formatting' do
3939
subject { Spreadsheet.open(tempfile.path).worksheet(0).rows[1].format(0).font.color }
4040

4141
it { is_expected.to eq(:green) }
4242
end
4343

44-
context 'writes to excel spreadsheet with data formatting' do
44+
context 'when writes to excel spreadsheet with data formatting' do
4545
subject { Spreadsheet.open(tempfile.path).worksheet(0).rows[1].format(1).font.color }
4646

4747
it { is_expected.to eq(:red) }
4848
end
4949

50-
context 'writes to excel spreadsheet with multi-index' do
50+
context 'when writes to excel spreadsheet with multi-index' do
5151
subject { Spreadsheet.open(tempfile.path).worksheet(0).rows }
5252

5353
let(:df) do

spec/daru/io/exporters/json_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
RSpec.describe Daru::IO::Exporters::JSON do
2-
include_context 'exporter setup'
2+
include_context 'with exporter setup'
33

44
subject { JSON.parse(File.read(tempfile.path)) }
55

@@ -21,37 +21,37 @@
2121

2222
before { described_class.new(df, pretty: pretty, orient: orient, **opts).write(tempfile.path) }
2323

24-
context 'writes DataFrame with default jsonpath options' do
24+
context 'when writes DataFrame with default jsonpath options' do
2525
it { is_expected.to be_an(Array).and all be_a(Hash) }
2626
its(:count) { is_expected.to eq(3) }
2727
its('first.keys') { is_expected.to match_array(%w[name age sex]) }
2828
end
2929

30-
context 'writes DataFrame with orient: :values' do
30+
context 'when writes DataFrame with orient: :values' do
3131
let(:orient) { :values }
3232

3333
it { is_expected.to be_an(Array).and all be_an(Array) }
3434
its(:count) { is_expected.to eq(3) }
3535
its(:first) { is_expected.to eq(['Jon Snow', 'Rhaegar Targaryen', 'Lyanna Stark']) }
3636
end
3737

38-
context 'writes DataFrame with orient: :split' do
38+
context 'when writes DataFrame with orient: :split' do
3939
let(:orient) { :split }
4040

4141
it { is_expected.to be_a(Hash).and all be_an(Array) }
4242
its(:count) { is_expected.to eq(3) }
4343
its(:keys) { is_expected.to eq(%w[vectors index data]) }
4444
end
4545

46-
context 'writes DataFrame with orient: :index' do
46+
context 'when writes DataFrame with orient: :index' do
4747
let(:orient) { :index }
4848

4949
it { is_expected.to be_an(Array).and all be_a(Hash) }
5050
its(:count) { is_expected.to eq(3) }
5151
its(:first) { is_expected.to eq('child' => {'sex' => 'Male', 'age' => 18, 'name' => 'Jon Snow'}) }
5252
end
5353

54-
context 'writes DataFrame with nested jsonpath options' do
54+
context 'when writes DataFrame with nested jsonpath options' do
5555
let(:opts) { {name: '$.person.name', age: '$.person.age', sex: '$.gender', index: '$.relation'} }
5656

5757
it { is_expected.to be_an(Array).and all be_a(Hash) }
@@ -64,14 +64,14 @@
6464
end
6565
end
6666

67-
context 'writes DataFrame with dynamic jsonpath options' do
67+
context 'when writes DataFrame with dynamic jsonpath options' do
6868
let(:opts) { {age: '$.{index}.{name}.age', sex: '$.{index}.{name}.gender'} }
6969

7070
it { is_expected.to be_an(Array).and all be_a(Hash) }
7171
its(:first) { is_expected.to eq('child' => {'Jon Snow' => {'age' => 18, 'gender' => 'Male'}}) }
7272
end
7373

74-
context 'writes DataFrame with block manipulation' do
74+
context 'when writes DataFrame with block manipulation' do
7575
before do
7676
described_class.new(df, orient: orient, pretty: pretty) do |json|
7777
json.map { |j| [j.keys.first, j.values.first] }.to_h

spec/daru/io/exporters/r_data_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
RSpec.describe Daru::IO::Exporters::RData do
22
subject { Daru::DataFrame.new(instance.send(variables[0].to_sym)) }
33

4-
include_context 'exporter setup'
4+
include_context 'with exporter setup'
55

66
let(:instance) { RSRuby.instance }
77
let(:filename) { 'test.RData' }
88
let(:variables) { instance.eval_R("load('#{tempfile.path}')") }
99

1010
before { described_class.new(**opts).write(tempfile.path) }
1111

12-
context 'writes DataFrame to a RData file' do
13-
let(:opts) { {:'first.df' => df, :'last.df' => df} }
12+
context 'when writes DataFrame to a RData file' do
13+
let(:opts) { {:'first.df' => df, :'last.df' => df} }
1414

1515
it_behaves_like 'exact daru dataframe',
1616
ncols: 4,

spec/daru/io/exporters/rds_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
RSpec.describe Daru::IO::Exporters::RDS do
22
subject { Daru::DataFrame.new(RSRuby.instance.eval_R("readRDS('#{tempfile.path}')")) }
33

4-
include_context 'exporter setup'
4+
include_context 'with exporter setup'
55

66
let(:variable) { 'test.dataframe' }
77
let(:filename) { 'test.rds' }
88

99
before { described_class.new(df, variable).write(tempfile.path) }
1010

11-
context 'writes DataFrame to a RDS file' do
11+
context 'when writes DataFrame to a RDS file' do
1212
it_behaves_like 'exact daru dataframe',
1313
ncols: 4,
1414
nrows: 5,

spec/daru/io/exporters/sql_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
RSpec.describe Daru::IO::Exporters::SQL do
2-
include_context 'exporter setup'
2+
include_context 'with exporter setup'
33

44
let(:dbh) { double }
55
let(:table) { 'test' }

spec/daru/io/importers/active_record_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
RSpec.describe Daru::IO::Importers::ActiveRecord do
2-
include_context 'sqlite3 database setup'
2+
include_context 'with sqlite3 database setup'
3+
34
context 'without specifying field names' do
45
let(:fields) { [] }
56

spec/daru/io/importers/avro_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
let(:path) { '' }
55

6-
context 'on complex numbers avro file' do
6+
context 'when on complex numbers avro file' do
77
let(:path) { 'spec/fixtures/avro/one_complex.avro' }
88

99
it_behaves_like 'exact daru dataframe',
@@ -13,7 +13,7 @@
1313
data: [[100],[200]]
1414
end
1515

16-
context 'on twitter avro file' do
16+
context 'when on twitter avro file' do
1717
let(:path) { 'spec/fixtures/avro/twitter.avro' }
1818

1919
it_behaves_like 'exact daru dataframe',
@@ -41,7 +41,7 @@
4141
]
4242
end
4343

44-
context 'on users avro file' do
44+
context 'when on users avro file' do
4545
let(:path) { 'spec/fixtures/avro/users.avro' }
4646

4747
it_behaves_like 'exact daru dataframe',

spec/daru/io/importers/csv_spec.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
let(:path) { 'spec/fixtures/csv/matrix_test.csv' }
1919
let(:opts) { {col_sep: ' ', headers: true} }
2020

21-
context 'loads from a CSV file' do
21+
context 'when loads from a CSV file' do
2222
let('subject.vectors') { %I[image_resolution mls true_transform].to_index }
2323

2424
it_behaves_like 'exact daru dataframe',
@@ -31,7 +31,7 @@
3131
',-0.3027024,4262.65,0,0,0,1'
3232
end
3333

34-
context 'works properly for repeated headers' do
34+
context 'when works properly for repeated headers' do
3535
let(:path) { 'spec/fixtures/csv/repeated_fields.csv' }
3636
let(:opts) { {header_converters: :symbol} }
3737

@@ -42,7 +42,7 @@
4242
age_2: Daru::Vector.new([3, 4, 5, 6, nil, 8])
4343
end
4444

45-
context 'accepts scientific notation as float' do
45+
context 'when accepts scientific notation as float' do
4646
let(:path) { 'spec/fixtures/csv/scientific_notation.csv' }
4747
let(:opts) { {order: %w[x y]} }
4848
let(:df) { subject }
@@ -64,7 +64,7 @@
6464
end
6565
end
6666

67-
context 'follows the order of columns given in CSV' do
67+
context 'when follows the order of columns given in CSV' do
6868
let(:path) { 'spec/fixtures/csv/sales-funnel.csv' }
6969
let(:opts) { {} }
7070

@@ -74,7 +74,7 @@
7474
order: %w[Account Name Rep Manager Product Quantity Price Status]
7575
end
7676

77-
context 'parses empty dataframe from CSV with only headers' do
77+
context 'when parses empty dataframe from CSV with only headers' do
7878
let(:path) { 'spec/fixtures/csv/column_headers_only.csv' }
7979
let(:opts) { {} }
8080

@@ -84,7 +84,7 @@
8484
order: %w[col0 col1 col2]
8585
end
8686

87-
context 'skips rows from CSV files with headers option' do
87+
context 'when skips rows from CSV files with headers option' do
8888
let(:path) { 'spec/fixtures/csv/sales-funnel.csv' }
8989
let(:opts) { {skiprows: 8, headers: true} }
9090

@@ -94,7 +94,7 @@
9494
order: %i[account manager name price product quantity rep status]
9595
end
9696

97-
context 'skips rows from CSV files without headers option' do
97+
context 'when skips rows from CSV files without headers option' do
9898
let(:path) { 'spec/fixtures/csv/sales-funnel.csv' }
9999
let(:opts) { {skiprows: 8} }
100100

@@ -104,7 +104,7 @@
104104
order: %w[Account Name Rep Manager Product Quantity Price Status]
105105
end
106106

107-
context 'checks for boolean converter' do
107+
context 'when checks for boolean converter' do
108108
let(:path) { 'spec/fixtures/csv/boolean_converter_test.csv' }
109109
let(:opts) { {converters: [:boolean]} }
110110

@@ -114,15 +114,15 @@
114114
its('Domestic.to_a') { is_expected.to all be_boolean }
115115
end
116116

117-
context 'checks for skip_blanks option to skip empty rows' do
117+
context 'when checks for skip_blanks option to skip empty rows' do
118118
let(:path) { 'spec/fixtures/csv/empty_rows_test.csv' }
119119

120120
it_behaves_like 'exact daru dataframe',
121121
ncols: 3,
122122
nrows: 13
123123
end
124124

125-
context 'checks for equal parsing of csv and csv.gz files' do
125+
context 'when checks for equal parsing of csv and csv.gz files' do
126126
ALL_CSV_FILES.each do |file|
127127
before { Zlib::GzipWriter.open(path) { |gz| gz.write File.read(csv_path) } }
128128

@@ -137,7 +137,7 @@
137137
end
138138
end
139139

140-
context 'checks for equal parsing of local CSV files and remote CSV files' do
140+
context 'when checks for equal parsing of local CSV files and remote CSV files' do
141141
ALL_CSV_FILES.each do |file|
142142
let(:local) { described_class.read("spec/fixtures/csv/#{file}.csv").call }
143143
let(:path) { "http://dummy-remote-url/#{file}.csv" }

0 commit comments

Comments
 (0)