diff --git a/spec/daru/io/exporters/avro_spec.rb b/spec/daru/io/exporters/avro_spec.rb index d99b549..85ee358 100644 --- a/spec/daru/io/exporters/avro_spec.rb +++ b/spec/daru/io/exporters/avro_spec.rb @@ -8,13 +8,13 @@ ) end - include_context 'exporter setup' + include_context 'with exporter setup' let(:filename) { 'test.avro' } before { described_class.new(df, schema).write(tempfile.path) } - context 'writes DataFrame to an Avro file' do + context 'when writes DataFrame to an Avro file' do context 'when schema is Hash' do let(:schema) do { diff --git a/spec/daru/io/exporters/csv_spec.rb b/spec/daru/io/exporters/csv_spec.rb index e3dad6b..c3dfc69 100644 --- a/spec/daru/io/exporters/csv_spec.rb +++ b/spec/daru/io/exporters/csv_spec.rb @@ -1,13 +1,13 @@ RSpec.describe Daru::IO::Exporters::CSV do subject { File.open(tempfile.path, &:readline).chomp.split(',', -1) } - include_context 'exporter setup' + include_context 'with exporter setup' let(:filename) { 'test.csv' } before { described_class.new(df, opts).write(tempfile.path) } - context 'writes DataFrame to a CSV file' do + context 'when writes DataFrame to a CSV file' do subject { Daru::DataFrame.rows content[1..-1].map { |x| x.map { |y| convert(y) } }, order: content[0] } let(:opts) { {} } @@ -25,12 +25,12 @@ ] end - context 'writes headers unless headers=false' do + context 'when writes headers unless headers=false' do it { is_expected.to be_an(Array) } it { is_expected.to eq(df.vectors.to_a) } end - context 'does not write headers when headers=false' do + context 'when does not write headers when headers=false' do let(:headers) { false } let(:opts) { {headers: headers} } @@ -38,7 +38,7 @@ it { is_expected.to eq(df.head(1).map { |v| (v.first || '').to_s }) } end - context 'writes convert_comma only on float values' do + context 'when writes convert_comma only on float values' do subject { CSV.read(tempfile.path, col_sep: ';') } let(:df) { Daru::DataFrame.new('a' => [1, 4.4, nil, 'Sr. Arthur']) } @@ -47,7 +47,7 @@ it { is_expected.to eq([['a'], ['1'], ['4,4'], [''], ['Sr. Arthur']]) } end - context 'writes into .csv.gz format' do + context 'when writes into .csv.gz format' do subject { Zlib::GzipReader.new(open(tempfile.path)).read.split("\n") } let(:opts) { {compression: :gzip} } @@ -57,7 +57,7 @@ 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']) } end - context 'writes into .csv.gz format with only order' do + context 'when writes into .csv.gz format with only order' do subject { Zlib::GzipReader.new(open(tempfile.path)).read.split("\n") } let(:df) { Daru::DataFrame.new('a' => [], 'b' => [], 'c' => [], 'd' => []) } diff --git a/spec/daru/io/exporters/excel_spec.rb b/spec/daru/io/exporters/excel_spec.rb index eacc037..ab3d8a6 100644 --- a/spec/daru/io/exporters/excel_spec.rb +++ b/spec/daru/io/exporters/excel_spec.rb @@ -1,5 +1,5 @@ RSpec.describe Daru::IO::Exporters::Excel do - include_context 'exporter setup' + include_context 'with exporter setup' let(:filename) { 'test_write.xls' } let(:content) { Spreadsheet.open tempfile.path } @@ -7,7 +7,7 @@ before { described_class.new(df, **opts).write(tempfile.path) } - context 'writes to excel spreadsheet' do + context 'when writes to excel spreadsheet' do subject do Daru::DataFrame.rows( Spreadsheet.open(tempfile.path).worksheet(0).rows[1..-1].map(&:to_a), @@ -29,25 +29,25 @@ ] end - context 'writes to excel spreadsheet with header formatting' do + context 'when writes to excel spreadsheet with header formatting' do subject { Spreadsheet.open(tempfile.path).worksheet(0).rows[0].format(0).font.color } it { is_expected.to eq(:blue) } end - context 'writes to excel spreadsheet with index formatting' do + context 'when writes to excel spreadsheet with index formatting' do subject { Spreadsheet.open(tempfile.path).worksheet(0).rows[1].format(0).font.color } it { is_expected.to eq(:green) } end - context 'writes to excel spreadsheet with data formatting' do + context 'when writes to excel spreadsheet with data formatting' do subject { Spreadsheet.open(tempfile.path).worksheet(0).rows[1].format(1).font.color } it { is_expected.to eq(:red) } end - context 'writes to excel spreadsheet with multi-index' do + context 'when writes to excel spreadsheet with multi-index' do subject { Spreadsheet.open(tempfile.path).worksheet(0).rows } let(:df) do diff --git a/spec/daru/io/exporters/json_spec.rb b/spec/daru/io/exporters/json_spec.rb index f272218..45e972f 100644 --- a/spec/daru/io/exporters/json_spec.rb +++ b/spec/daru/io/exporters/json_spec.rb @@ -1,5 +1,5 @@ RSpec.describe Daru::IO::Exporters::JSON do - include_context 'exporter setup' + include_context 'with exporter setup' subject { JSON.parse(File.read(tempfile.path)) } @@ -21,13 +21,13 @@ before { described_class.new(df, pretty: pretty, orient: orient, **opts).write(tempfile.path) } - context 'writes DataFrame with default jsonpath options' do + context 'when writes DataFrame with default jsonpath options' do it { is_expected.to be_an(Array).and all be_a(Hash) } its(:count) { is_expected.to eq(3) } its('first.keys') { is_expected.to match_array(%w[name age sex]) } end - context 'writes DataFrame with orient: :values' do + context 'when writes DataFrame with orient: :values' do let(:orient) { :values } it { is_expected.to be_an(Array).and all be_an(Array) } @@ -35,7 +35,7 @@ its(:first) { is_expected.to eq(['Jon Snow', 'Rhaegar Targaryen', 'Lyanna Stark']) } end - context 'writes DataFrame with orient: :split' do + context 'when writes DataFrame with orient: :split' do let(:orient) { :split } it { is_expected.to be_a(Hash).and all be_an(Array) } @@ -43,7 +43,7 @@ its(:keys) { is_expected.to eq(%w[vectors index data]) } end - context 'writes DataFrame with orient: :index' do + context 'when writes DataFrame with orient: :index' do let(:orient) { :index } it { is_expected.to be_an(Array).and all be_a(Hash) } @@ -51,7 +51,7 @@ its(:first) { is_expected.to eq('child' => {'sex' => 'Male', 'age' => 18, 'name' => 'Jon Snow'}) } end - context 'writes DataFrame with nested jsonpath options' do + context 'when writes DataFrame with nested jsonpath options' do let(:opts) { {name: '$.person.name', age: '$.person.age', sex: '$.gender', index: '$.relation'} } it { is_expected.to be_an(Array).and all be_a(Hash) } @@ -64,14 +64,14 @@ end end - context 'writes DataFrame with dynamic jsonpath options' do + context 'when writes DataFrame with dynamic jsonpath options' do let(:opts) { {age: '$.{index}.{name}.age', sex: '$.{index}.{name}.gender'} } it { is_expected.to be_an(Array).and all be_a(Hash) } its(:first) { is_expected.to eq('child' => {'Jon Snow' => {'age' => 18, 'gender' => 'Male'}}) } end - context 'writes DataFrame with block manipulation' do + context 'when writes DataFrame with block manipulation' do before do described_class.new(df, orient: orient, pretty: pretty) do |json| json.map { |j| [j.keys.first, j.values.first] }.to_h diff --git a/spec/daru/io/exporters/r_data_spec.rb b/spec/daru/io/exporters/r_data_spec.rb index 60da5d6..25e49f4 100644 --- a/spec/daru/io/exporters/r_data_spec.rb +++ b/spec/daru/io/exporters/r_data_spec.rb @@ -1,7 +1,7 @@ RSpec.describe Daru::IO::Exporters::RData do subject { Daru::DataFrame.new(instance.send(variables[0].to_sym)) } - include_context 'exporter setup' + include_context 'with exporter setup' let(:instance) { RSRuby.instance } let(:filename) { 'test.RData' } @@ -9,8 +9,8 @@ before { described_class.new(**opts).write(tempfile.path) } - context 'writes DataFrame to a RData file' do - let(:opts) { {:'first.df' => df, :'last.df' => df} } + context 'when writes DataFrame to a RData file' do + let(:opts) { {:'first.df' => df, :'last.df' => df} } it_behaves_like 'exact daru dataframe', ncols: 4, diff --git a/spec/daru/io/exporters/rds_spec.rb b/spec/daru/io/exporters/rds_spec.rb index 570aa1e..ed0589c 100644 --- a/spec/daru/io/exporters/rds_spec.rb +++ b/spec/daru/io/exporters/rds_spec.rb @@ -1,14 +1,14 @@ RSpec.describe Daru::IO::Exporters::RDS do subject { Daru::DataFrame.new(RSRuby.instance.eval_R("readRDS('#{tempfile.path}')")) } - include_context 'exporter setup' + include_context 'with exporter setup' let(:variable) { 'test.dataframe' } let(:filename) { 'test.rds' } before { described_class.new(df, variable).write(tempfile.path) } - context 'writes DataFrame to a RDS file' do + context 'when writes DataFrame to a RDS file' do it_behaves_like 'exact daru dataframe', ncols: 4, nrows: 5, diff --git a/spec/daru/io/exporters/sql_spec.rb b/spec/daru/io/exporters/sql_spec.rb index c38a239..c086a39 100644 --- a/spec/daru/io/exporters/sql_spec.rb +++ b/spec/daru/io/exporters/sql_spec.rb @@ -1,5 +1,5 @@ RSpec.describe Daru::IO::Exporters::SQL do - include_context 'exporter setup' + include_context 'with exporter setup' let(:dbh) { double } let(:table) { 'test' } diff --git a/spec/daru/io/importers/active_record_spec.rb b/spec/daru/io/importers/active_record_spec.rb index 11e2d32..f843e12 100644 --- a/spec/daru/io/importers/active_record_spec.rb +++ b/spec/daru/io/importers/active_record_spec.rb @@ -1,5 +1,6 @@ RSpec.describe Daru::IO::Importers::ActiveRecord do - include_context 'sqlite3 database setup' + include_context 'with sqlite3 database setup' + context 'without specifying field names' do let(:fields) { [] } diff --git a/spec/daru/io/importers/avro_spec.rb b/spec/daru/io/importers/avro_spec.rb index c36d4ac..8c3ffc2 100644 --- a/spec/daru/io/importers/avro_spec.rb +++ b/spec/daru/io/importers/avro_spec.rb @@ -3,7 +3,7 @@ let(:path) { '' } - context 'on complex numbers avro file' do + context 'when on complex numbers avro file' do let(:path) { 'spec/fixtures/avro/one_complex.avro' } it_behaves_like 'exact daru dataframe', @@ -13,7 +13,7 @@ data: [[100],[200]] end - context 'on twitter avro file' do + context 'when on twitter avro file' do let(:path) { 'spec/fixtures/avro/twitter.avro' } it_behaves_like 'exact daru dataframe', @@ -41,7 +41,7 @@ ] end - context 'on users avro file' do + context 'when on users avro file' do let(:path) { 'spec/fixtures/avro/users.avro' } it_behaves_like 'exact daru dataframe', diff --git a/spec/daru/io/importers/csv_spec.rb b/spec/daru/io/importers/csv_spec.rb index 1d28cdc..44064c5 100644 --- a/spec/daru/io/importers/csv_spec.rb +++ b/spec/daru/io/importers/csv_spec.rb @@ -18,7 +18,7 @@ let(:path) { 'spec/fixtures/csv/matrix_test.csv' } let(:opts) { {col_sep: ' ', headers: true} } - context 'loads from a CSV file' do + context 'when loads from a CSV file' do let('subject.vectors') { %I[image_resolution mls true_transform].to_index } it_behaves_like 'exact daru dataframe', @@ -31,7 +31,7 @@ ',-0.3027024,4262.65,0,0,0,1' end - context 'works properly for repeated headers' do + context 'when works properly for repeated headers' do let(:path) { 'spec/fixtures/csv/repeated_fields.csv' } let(:opts) { {header_converters: :symbol} } @@ -42,7 +42,7 @@ age_2: Daru::Vector.new([3, 4, 5, 6, nil, 8]) end - context 'accepts scientific notation as float' do + context 'when accepts scientific notation as float' do let(:path) { 'spec/fixtures/csv/scientific_notation.csv' } let(:opts) { {order: %w[x y]} } let(:df) { subject } @@ -64,7 +64,7 @@ end end - context 'follows the order of columns given in CSV' do + context 'when follows the order of columns given in CSV' do let(:path) { 'spec/fixtures/csv/sales-funnel.csv' } let(:opts) { {} } @@ -74,7 +74,7 @@ order: %w[Account Name Rep Manager Product Quantity Price Status] end - context 'parses empty dataframe from CSV with only headers' do + context 'when parses empty dataframe from CSV with only headers' do let(:path) { 'spec/fixtures/csv/column_headers_only.csv' } let(:opts) { {} } @@ -84,7 +84,7 @@ order: %w[col0 col1 col2] end - context 'skips rows from CSV files with headers option' do + context 'when skips rows from CSV files with headers option' do let(:path) { 'spec/fixtures/csv/sales-funnel.csv' } let(:opts) { {skiprows: 8, headers: true} } @@ -94,7 +94,7 @@ order: %i[account manager name price product quantity rep status] end - context 'skips rows from CSV files without headers option' do + context 'when skips rows from CSV files without headers option' do let(:path) { 'spec/fixtures/csv/sales-funnel.csv' } let(:opts) { {skiprows: 8} } @@ -104,7 +104,7 @@ order: %w[Account Name Rep Manager Product Quantity Price Status] end - context 'checks for boolean converter' do + context 'when checks for boolean converter' do let(:path) { 'spec/fixtures/csv/boolean_converter_test.csv' } let(:opts) { {converters: [:boolean]} } @@ -114,7 +114,7 @@ its('Domestic.to_a') { is_expected.to all be_boolean } end - context 'checks for skip_blanks option to skip empty rows' do + context 'when checks for skip_blanks option to skip empty rows' do let(:path) { 'spec/fixtures/csv/empty_rows_test.csv' } it_behaves_like 'exact daru dataframe', @@ -122,7 +122,7 @@ nrows: 13 end - context 'checks for equal parsing of csv and csv.gz files' do + context 'when checks for equal parsing of csv and csv.gz files' do ALL_CSV_FILES.each do |file| before { Zlib::GzipWriter.open(path) { |gz| gz.write File.read(csv_path) } } @@ -137,7 +137,7 @@ end end - context 'checks for equal parsing of local CSV files and remote CSV files' do + context 'when checks for equal parsing of local CSV files and remote CSV files' do ALL_CSV_FILES.each do |file| let(:local) { described_class.read("spec/fixtures/csv/#{file}.csv").call } let(:path) { "http://dummy-remote-url/#{file}.csv" } diff --git a/spec/daru/io/importers/excel_spec.rb b/spec/daru/io/importers/excel_spec.rb index 579a0db..528c08e 100644 --- a/spec/daru/io/importers/excel_spec.rb +++ b/spec/daru/io/importers/excel_spec.rb @@ -1,5 +1,5 @@ RSpec.describe Daru::IO::Importers::Excel do - context 'loads from excel spreadsheet' do + context 'when loads from excel spreadsheet' do subject { described_class.read(path).call } let(:path) { 'spec/fixtures/excel/test_xls.xls' } diff --git a/spec/daru/io/importers/excelx_spec.rb b/spec/daru/io/importers/excelx_spec.rb index eb09208..7cee491 100644 --- a/spec/daru/io/importers/excelx_spec.rb +++ b/spec/daru/io/importers/excelx_spec.rb @@ -61,7 +61,7 @@ end end - context 'checks for equal parsing of local XLSX files and remote XLSX files' do + context 'when checks for equal parsing of local XLSX files and remote XLSX files' do %w[LOBSTAHS_rt.windows Microcode Stock-counts-sheet].each do |file| let(:local) { described_class.read("spec/fixtures/excelx/#{file}.xlsx").call } let(:path) { "http://dummy-remote-url/#{file}.xlsx" } diff --git a/spec/daru/io/importers/html_spec.rb b/spec/daru/io/importers/html_spec.rb index 042c7ef..f76f32e 100644 --- a/spec/daru/io/importers/html_spec.rb +++ b/spec/daru/io/importers/html_spec.rb @@ -4,13 +4,13 @@ let(:opts) { {} } let(:df_index) { 0 } - context 'in wiki info table' do + context 'when in wiki info table' do let(:path) { 'spec/fixtures/html/wiki_table_info.html' } let(:order) { %w[FName LName Age] } let(:index) { %w[One Two Three Four Five Six Seven] } let(:name) { 'Wikipedia Information Table' } - context 'returns default dataframe' do + context 'when returns default dataframe' do it_behaves_like 'exact daru dataframe', ncols: 3, nrows: 7, @@ -22,7 +22,7 @@ ] end - context 'returns user-modified dataframe' do + context 'when returns user-modified dataframe' do let(:opts) { {order: order, index: index, name: name} } it_behaves_like 'exact daru dataframe', @@ -39,10 +39,10 @@ end end - context 'in wiki climate data' do + context 'when in wiki climate data' do let(:path) { 'spec/fixtures/html/wiki_climate.html' } - context 'returns default dataframe' do + context 'when returns default dataframe' do it_behaves_like 'exact daru dataframe', ncols: 13, nrows: 10, @@ -62,7 +62,7 @@ let(:index) { %w[W X Y Z] } let(:name) { 'Small HTML table with index' } - context 'returns user-modified dataframe' do + context 'when returns user-modified dataframe' do let(:opts) { {index: index, name: name} } it_behaves_like 'exact daru dataframe', @@ -75,12 +75,12 @@ end end - context 'in year-wise passengers figure' do + context 'when in year-wise passengers figure' do let(:path) { 'spec/fixtures/html/macau.html' } let(:match) { '2001' } let(:name) { 'Year-wise Passengers Figure' } - context 'returns matching dataframes with index' do + context 'when returns matching dataframes with index' do let(:opts) { {match: match, name: name} } it_behaves_like 'exact daru dataframe', @@ -107,13 +107,13 @@ end end - context 'in share market data' do + context 'when in share market data' do let(:path) { 'spec/fixtures/html/moneycontrol.html' } let(:match) { 'Sun Pharma' } let(:index) { %w[Alpha Beta Gamma Delta Misc] } let(:name) { 'Share Market Analysis' } - context 'returns matching dataframes' do + context 'when returns matching dataframes' do let(:opts) { {match: match} } it_behaves_like 'exact daru dataframe', @@ -129,7 +129,7 @@ ].transpose end - context 'returns user-modified matching dataframes' do + context 'when returns user-modified matching dataframes' do let(:opts) { {match: match, index: index, name: name} } it_behaves_like 'exact daru dataframe', @@ -148,10 +148,10 @@ end end - context 'in election results data' do + context 'when in election results data' do let(:path) { 'spec/fixtures/html/eciresults.html' } - context 'returns default dataframes' do + context 'when returns default dataframes' do it_behaves_like 'exact daru dataframe', ncols: 2, nrows: 19, diff --git a/spec/daru/io/importers/json_spec.rb b/spec/daru/io/importers/json_spec.rb index ad5a559..77b65aa 100644 --- a/spec/daru/io/importers/json_spec.rb +++ b/spec/daru/io/importers/json_spec.rb @@ -7,8 +7,8 @@ let(:columns) { nil } let(:named_columns) { {} } - context 'on simple json file' do - context 'in NASA data' do + context 'when on simple json file' do + context 'when in NASA data' do let(:path) { 'spec/fixtures/json/nasadata.json' } context 'without xpath (simple json)' do @@ -22,7 +22,7 @@ it_behaves_like 'importer with json-path option' - context 'parses json response' do + context 'when parses json response' do subject { described_class.from(instance).call(*columns, order: order, index: index, **named_columns) } let(:instance) { ::JSON.parse(File.read('spec/fixtures/json/nasadata.json')) } @@ -33,7 +33,7 @@ order: %w[designation discovery_date h_mag i_deg moid_au orbit_class period_yr pha q_au_1 q_au_2] end - context 'parses json string' do + context 'when parses json string' do subject { described_class.from(instance).call(*columns, order: order, index: index, **named_columns) } let(:instance) { File.read('spec/fixtures/json/nasadata.json') } @@ -44,7 +44,7 @@ order: %w[designation discovery_date h_mag i_deg moid_au orbit_class period_yr pha q_au_1 q_au_2] end - context 'parses remote and local file similarly' do + context 'when parses remote and local file similarly' do let(:local_path) { 'spec/fixtures/json/nasadata.json' } let(:path) { 'http://dummy-remote-url/nasadata.json' } @@ -61,8 +61,8 @@ order: %w[designation discovery_date h_mag i_deg moid_au orbit_class period_yr pha q_au_1 q_au_2] end - context 'raises error for invalid argument' do # rubocop:disable RSpec/EmptyExampleGroup - context 'json input is invalid' do # rubocop:disable RSpec/EmptyExampleGroup + context 'when raises error for invalid argument' do # rubocop:disable RSpec/EmptyExampleGroup + context 'when json input is invalid' do # rubocop:disable RSpec/EmptyExampleGroup subject { described_class.from([]).call(*columns, order: order, index: index, **named_columns) } let(:order) { %i[a b] } diff --git a/spec/daru/io/importers/mongo_spec.rb b/spec/daru/io/importers/mongo_spec.rb index 986aa6e..f5fb578 100644 --- a/spec/daru/io/importers/mongo_spec.rb +++ b/spec/daru/io/importers/mongo_spec.rb @@ -45,8 +45,8 @@ def store(path) before { store path } after { connection[collection].drop } - context 'on simple json file' do - context 'in NASA data' do + context 'when on simple json file' do + context 'when in NASA data' do let(:path) { 'spec/fixtures/json/nasadata.json' } let(:vector) do %w[_id designation discovery_date h_mag i_deg moid_au orbit_class period_yr pha q_au_1 q_au_2] @@ -59,7 +59,7 @@ def store(path) its('vectors.to_a') { is_expected.to match_array(vector) } end - context 'fetches paginated results - first page' do + context 'when fetches paginated results - first page' do let(:limit) { 30 } let(:nrows) { 30 } @@ -70,7 +70,7 @@ def store(path) its('vectors.to_a') { is_expected.to match_array(vector) } end - context 'fetches paginated results - last page' do + context 'when fetches paginated results - last page' do let(:skip) { 180 } let(:limit) { 30 } @@ -80,7 +80,7 @@ def store(path) its('vectors.to_a') { is_expected.to match_array(vector) } end - context 'fetches results with filter' do + context 'when fetches results with filter' do let(:filter) { {pha: :N} } let(:limit) { 200 } @@ -90,7 +90,7 @@ def store(path) its('vectors.to_a') { is_expected.to match_array(vector) } end - context 'fetches results with filter and pagination' do + context 'when fetches results with filter and pagination' do let(:filter) { {pha: :N} } let(:limit) { 100 } diff --git a/spec/daru/io/importers/plaintext_spec.rb b/spec/daru/io/importers/plaintext_spec.rb index 09d0f30..738c1ea 100644 --- a/spec/daru/io/importers/plaintext_spec.rb +++ b/spec/daru/io/importers/plaintext_spec.rb @@ -3,7 +3,7 @@ let(:vectors) { %i[v1 v2 v3] } - context 'reads data from plain text files' do + context 'when reads data from plain text files' do let(:path) { 'spec/fixtures/plaintext/bank2.dat' } let(:vectors) { %i[v1 v2 v3 v4 v5 v6] } @@ -13,7 +13,7 @@ order: %i[v1 v2 v3 v4 v5 v6] end - context 'understands empty fields', skip: 'See FIXME note at importers/plainext.rb#L33-L36' do + context 'when understands empty fields', skip: 'See FIXME note at importers/plainext.rb#L33-L36' do let(:path) { 'spec/fixtures/plaintext/empties.dat' } it_behaves_like 'exact daru dataframe', @@ -22,7 +22,7 @@ :'row[1].to_a' => [4, nil, 6] end - context 'understands non-numeric fields' do + context 'when understands non-numeric fields' do let(:path) { 'spec/fixtures/plaintext/strings.dat' } it_behaves_like 'exact daru dataframe', diff --git a/spec/daru/io/importers/r_data_spec.rb b/spec/daru/io/importers/r_data_spec.rb index c51e08e..e3f71b7 100644 --- a/spec/daru/io/importers/r_data_spec.rb +++ b/spec/daru/io/importers/r_data_spec.rb @@ -3,7 +3,7 @@ let(:variable) { nil } - context 'reads data from ACScounty file' do + context 'when reads data from ACScounty file' do let(:path) { 'spec/fixtures/rdata/ACScounty.RData' } let(:variable) { 'ACS3' } @@ -20,7 +20,7 @@ ] end - context 'reads data from Filings-by-state file' do + context 'when reads data from Filings-by-state file' do let(:path) { 'spec/fixtures/rdata/Filings-by-state.RData' } let(:variable) { 'bk.rates' } @@ -33,7 +33,7 @@ ] end - context 'reads data from Ownership file' do + context 'when reads data from Ownership file' do let(:path) { 'spec/fixtures/rdata/Ownership.RData' } let(:variable) { 'ownership.state.qtr' } diff --git a/spec/daru/io/importers/rds_spec.rb b/spec/daru/io/importers/rds_spec.rb index ad6dfde..3a21baf 100644 --- a/spec/daru/io/importers/rds_spec.rb +++ b/spec/daru/io/importers/rds_spec.rb @@ -1,7 +1,7 @@ RSpec.describe Daru::IO::Importers::RDS do subject { described_class.read(path).call } - context 'reads data from bc_sites RDS file' do + context 'when reads data from bc_sites RDS file' do let(:path) { 'spec/fixtures/rds/bc_sites.rds' } it_behaves_like 'exact daru dataframe', @@ -16,7 +16,7 @@ ] end - context 'reads data from chicago RDS file' do + context 'when reads data from chicago RDS file' do let(:path) { 'spec/fixtures/rds/chicago.rds' } it_behaves_like 'exact daru dataframe', @@ -28,7 +28,7 @@ ] end - context 'reads data from healthexp RDS file' do + context 'when reads data from healthexp RDS file' do let(:path) { 'spec/fixtures/rds/healthexp.Rds' } it_behaves_like 'exact daru dataframe', @@ -40,7 +40,7 @@ ] end - context 'reads data from heights RDS file' do + context 'when reads data from heights RDS file' do let(:path) { 'spec/fixtures/rds/heights.RDS' } it_behaves_like 'exact daru dataframe', @@ -52,7 +52,7 @@ ] end - context 'reads data from maacs_env RDS file' do + context 'when reads data from maacs_env RDS file' do let(:path) { 'spec/fixtures/rds/maacs_env.rds' } it_behaves_like 'exact daru dataframe', @@ -66,7 +66,7 @@ ] end - context 'reads data from RPPdataConverted RDS file' do + context 'when reads data from RPPdataConverted RDS file' do let(:path) { 'spec/fixtures/rds/RPPdataConverted.rds' } it_behaves_like 'exact daru dataframe', diff --git a/spec/daru/io/importers/redis_spec.rb b/spec/daru/io/importers/redis_spec.rb index f160654..8c6a19e 100644 --- a/spec/daru/io/importers/redis_spec.rb +++ b/spec/daru/io/importers/redis_spec.rb @@ -48,7 +48,7 @@ def store(key, value) after { connection.flushdb } - context 'on array of keys having hashes' do + context 'when on array of keys having hashes' do let(:index) { %i[10001 10002 10003 10004] } let(:data) do [ @@ -88,7 +88,7 @@ def store(key, value) end end - context 'on keys having array of hashes' do + context 'when on keys having array of hashes' do let(:index) { %i[10001 10003] } let(:data) do [ @@ -126,7 +126,7 @@ def store(key, value) end end - context 'on hash keys having arrays' do + context 'when on hash keys having arrays' do let(:index) { %i[age living name] } let(:data) do [ @@ -160,7 +160,7 @@ def store(key, value) end end - context 'on timestamps' do + context 'when on timestamps' do let(:index) { %i[090620171216 090620171218 090620171222 100620171225] } let(:data) do [ @@ -171,7 +171,7 @@ def store(key, value) ] end - context 'gets keys with pattern match and count' do + context 'when gets keys with pattern match and count' do let(:count) { 3 } let(:pattern) { '09062017*' } @@ -187,7 +187,7 @@ def store(key, value) ] end - context 'gets keys without pattern and count' do + context 'when gets keys without pattern and count' do it_behaves_like 'unordered daru dataframe', nrows: 4, ncols: 2, @@ -201,7 +201,7 @@ def store(key, value) ] end - context 'gets keys with pattern match' do + context 'when gets keys with pattern match' do let(:pattern) { '09062017*' } it_behaves_like 'unordered daru dataframe', @@ -217,12 +217,12 @@ def store(key, value) end end - context 'on dummy data of paginated keys' do + context 'when on dummy data of paginated keys' do let(:data) { Array.new(2000) { |i| {a: "a#{i}", b: "b#{i}"} } } let(:index) { Array.new(2000) { |i| "key#{i}".to_sym } } let(:pattern) { 'key1*' } - context 'parses only 1st page by default' do + context 'when parses only 1st page by default' do let(:count) { 400 } it_behaves_like 'unordered daru dataframe', @@ -231,7 +231,7 @@ def store(key, value) order: %i[a b] end - context 'parses entire pagination' do + context 'when parses entire pagination' do let(:count) { nil } it_behaves_like 'unordered daru dataframe', diff --git a/spec/daru/io/importers/sql_spec.rb b/spec/daru/io/importers/sql_spec.rb index 2884602..cfd848a 100644 --- a/spec/daru/io/importers/sql_spec.rb +++ b/spec/daru/io/importers/sql_spec.rb @@ -1,5 +1,5 @@ RSpec.describe Daru::IO::Importers::SQL do - include_context 'sqlite3 database setup' + include_context 'with sqlite3 database setup' subject { described_class.from(source).call(query) } @@ -64,7 +64,7 @@ data: [[20, 30],[1,2],%w[Homer Marge]] end - context 'raises error for invalid arguments' do # rubocop:disable RSpec/EmptyExampleGroup + context 'when raises error for invalid arguments' do # rubocop:disable RSpec/EmptyExampleGroup let(:query) { Object.new } let(:source) { 'spec/fixtures/plaintext/bank2.dat' } diff --git a/spec/support/shared_contexts.rb b/spec/support/shared_contexts.rb index 02725c6..8e4f46f 100644 --- a/spec/support/shared_contexts.rb +++ b/spec/support/shared_contexts.rb @@ -1,4 +1,4 @@ -RSpec.shared_context 'sqlite3 database setup' do +RSpec.shared_context 'with sqlite3 database setup' do module Daru module IO module Rspec @@ -27,7 +27,7 @@ class Account < ActiveRecord::Base after { FileUtils.rm(db_name) } end -RSpec.shared_context 'exporter setup' do +RSpec.shared_context 'with exporter setup' do let(:tempfile) { Tempfile.new(filename) } let(:opts) { {} } let(:df) do diff --git a/spec/support/shared_examples.rb b/spec/support/shared_examples.rb index 2aa4aac..dd4eb4d 100644 --- a/spec/support/shared_examples.rb +++ b/spec/support/shared_examples.rb @@ -22,7 +22,7 @@ end RSpec.shared_examples 'importer with json-path option' do - context 'in temperature data' do + context 'when in temperature data' do let(:path) { 'spec/fixtures/json/temp.json' } context 'with only jsonpath columns' do @@ -54,7 +54,7 @@ end end - context 'in tv series data' do + context 'when in tv series data' do let(:path) { 'spec/fixtures/json/got.json' } context 'with jsonpath columns' do @@ -101,7 +101,7 @@ end end - context 'on allsets data' do + context 'when on allsets data' do let(:path) { 'spec/fixtures/json/allsets.json' } context 'with jsonpath columns' do @@ -116,7 +116,7 @@ end end - context 'on VAT data' do + context 'when on VAT data' do let(:path) { 'spec/fixtures/json/jsonvat.json' } context 'with jsonpath columns' do