diff --git a/.rubocop.yml b/.rubocop.yml index 18d16da..7ba9188 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -11,7 +11,7 @@ AllCops: Exclude: - bin/* - gemfiles/* - - spec/**/* + - spec/dummy/**/* Gemspec/RequireMFA: Enabled: false @@ -47,3 +47,10 @@ Layout/EmptyLinesAroundBlockBody: Layout/EmptyLinesAroundModuleBody: Enabled: false + +######### +# RSPEC # +######### + +RSpec/MultipleExpectations: + Max: 3 diff --git a/spec/acts_as_xlsx/macros_spec.rb b/spec/acts_as_xlsx/macros_spec.rb index e11fd2c..05a4f36 100644 --- a/spec/acts_as_xlsx/macros_spec.rb +++ b/spec/acts_as_xlsx/macros_spec.rb @@ -1,11 +1,13 @@ +# frozen_string_literal: true + require 'spec_helper' -RSpec.describe 'Basic tests' do +RSpec.describe ActsAsXlsx::Macros do describe 'to_xlsx_with_package' do let(:p) { Post.to_xlsx } - it 'should return xslx data' do + it 'returns xslx data' do Post.to_xlsx package: p, name: 'another posts' expect(p.workbook.worksheets.size).to eq 2 end @@ -14,13 +16,13 @@ describe 'to_xlsx_with_name' do let(:p) { Post.to_xlsx name: 'bob' } - it 'should return xslx data' do + it 'returns xslx data' do expect(p.workbook.worksheets.first.name).to eq 'bob' end end describe 'xlsx_columns' do - it 'should return xslx data' do + it 'returns xslx data' do expect(Post.xlsx_columns).to eq Post.column_names.map(&:to_sym) end end @@ -28,26 +30,26 @@ describe 'to_xslx_vanilla' do let(:p) { Post.to_xlsx } - it 'should return xslx data' do + it 'returns xslx data' do expect(p.workbook.worksheets.first.rows.first.cells.first.value).to eq 'Id' expect(p.workbook.worksheets.first.rows.last.cells.first.value).to eq 2 end end describe 'to_xslx_with_provided_data' do - let(:p) { Post.to_xlsx data: Post.where(title: "This is the first post").all } + let(:p) { Post.to_xlsx data: Post.where(title: 'This is the first post').all } - it 'should return xslx data' do + it 'returns xslx data' do expect(p.workbook.worksheets.first.rows.first.cells.first.value).to eq 'Id' expect(p.workbook.worksheets.first.rows.last.cells.first.value).to eq 1 end end describe 'columns' do - let(:p) { Post.to_xlsx columns: [:name, :title, :content, :votes] } + let(:p) { Post.to_xlsx columns: %i[name title content votes] } let(:sheet) { p.workbook.worksheets.first } - it 'should return xslx data' do + it 'returns xslx data' do expect(sheet.rows.first.cells.size).to eq Post.xlsx_columns.size - 3 expect(sheet.rows.first.cells.first.value).to eq 'Name' expect(sheet.rows.last.cells.last.value).to eq 7 @@ -55,20 +57,20 @@ end describe 'method_in_columns' do - let(:p) { Post.to_xlsx columns: [:name, :votes, :content, :ranking] } + let(:p) { Post.to_xlsx columns: %i[name votes content ranking] } let(:sheet) { p.workbook.worksheets.first } - it 'should return xslx data' do + it 'returns xslx data' do expect(sheet.rows.first.cells.first.value).to eq 'Name' expect(sheet.rows.last.cells.last.value).to eq Post.last.ranking end end describe 'chained_method' do - let(:p) { Post.to_xlsx columns: [:name, :votes, :content, :ranking, :'comments.last.content', :'comments.first.author.name'] } + let(:p) { Post.to_xlsx columns: %i[name votes content ranking comments.last.content comments.first.author.name] } let(:sheet) { p.workbook.worksheets.first } - it 'should return xslx data' do + it 'returns xslx data' do expect(sheet.rows.first.cells.first.value).to eq 'Name' expect(sheet.rows.last.cells.last.value).to eq Post.last.comments.last.author.name end diff --git a/spec/config_rspec.rb b/spec/config_rspec.rb index 2ff8172..0abea7a 100644 --- a/spec/config_rspec.rb +++ b/spec/config_rspec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Configure RSpec RSpec.configure do |config| # Use DB agnostic schema by default