Skip to content

Commit 0e64ef0

Browse files
committed
Improve Rubocop config, fix offenses
1 parent ea98c0a commit 0e64ef0

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
lines changed

.rubocop.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ AllCops:
1111
Exclude:
1212
- bin/*
1313
- gemfiles/*
14-
- spec/**/*
14+
- spec/dummy/**/*
1515

1616
Gemspec/RequireMFA:
1717
Enabled: false
@@ -47,3 +47,10 @@ Layout/EmptyLinesAroundBlockBody:
4747

4848
Layout/EmptyLinesAroundModuleBody:
4949
Enabled: false
50+
51+
#########
52+
# RSPEC #
53+
#########
54+
55+
RSpec/MultipleExpectations:
56+
Max: 3

spec/acts_as_xlsx/macros_spec.rb

+15-13
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
# frozen_string_literal: true
2+
13
require 'spec_helper'
24

3-
RSpec.describe 'Basic tests' do
5+
RSpec.describe ActsAsXlsx::Macros do
46

57
describe 'to_xlsx_with_package' do
68
let(:p) { Post.to_xlsx }
79

8-
it 'should return xslx data' do
10+
it 'returns xslx data' do
911
Post.to_xlsx package: p, name: 'another posts'
1012
expect(p.workbook.worksheets.size).to eq 2
1113
end
@@ -14,61 +16,61 @@
1416
describe 'to_xlsx_with_name' do
1517
let(:p) { Post.to_xlsx name: 'bob' }
1618

17-
it 'should return xslx data' do
19+
it 'returns xslx data' do
1820
expect(p.workbook.worksheets.first.name).to eq 'bob'
1921
end
2022
end
2123

2224
describe 'xlsx_columns' do
23-
it 'should return xslx data' do
25+
it 'returns xslx data' do
2426
expect(Post.xlsx_columns).to eq Post.column_names.map(&:to_sym)
2527
end
2628
end
2729

2830
describe 'to_xslx_vanilla' do
2931
let(:p) { Post.to_xlsx }
3032

31-
it 'should return xslx data' do
33+
it 'returns xslx data' do
3234
expect(p.workbook.worksheets.first.rows.first.cells.first.value).to eq 'Id'
3335
expect(p.workbook.worksheets.first.rows.last.cells.first.value).to eq 2
3436
end
3537
end
3638

3739
describe 'to_xslx_with_provided_data' do
38-
let(:p) { Post.to_xlsx data: Post.where(title: "This is the first post").all }
40+
let(:p) { Post.to_xlsx data: Post.where(title: 'This is the first post').all }
3941

40-
it 'should return xslx data' do
42+
it 'returns xslx data' do
4143
expect(p.workbook.worksheets.first.rows.first.cells.first.value).to eq 'Id'
4244
expect(p.workbook.worksheets.first.rows.last.cells.first.value).to eq 1
4345
end
4446
end
4547

4648
describe 'columns' do
47-
let(:p) { Post.to_xlsx columns: [:name, :title, :content, :votes] }
49+
let(:p) { Post.to_xlsx columns: %i[name title content votes] }
4850
let(:sheet) { p.workbook.worksheets.first }
4951

50-
it 'should return xslx data' do
52+
it 'returns xslx data' do
5153
expect(sheet.rows.first.cells.size).to eq Post.xlsx_columns.size - 3
5254
expect(sheet.rows.first.cells.first.value).to eq 'Name'
5355
expect(sheet.rows.last.cells.last.value).to eq 7
5456
end
5557
end
5658

5759
describe 'method_in_columns' do
58-
let(:p) { Post.to_xlsx columns: [:name, :votes, :content, :ranking] }
60+
let(:p) { Post.to_xlsx columns: %i[name votes content ranking] }
5961
let(:sheet) { p.workbook.worksheets.first }
6062

61-
it 'should return xslx data' do
63+
it 'returns xslx data' do
6264
expect(sheet.rows.first.cells.first.value).to eq 'Name'
6365
expect(sheet.rows.last.cells.last.value).to eq Post.last.ranking
6466
end
6567
end
6668

6769
describe 'chained_method' do
68-
let(:p) { Post.to_xlsx columns: [:name, :votes, :content, :ranking, :'comments.last.content', :'comments.first.author.name'] }
70+
let(:p) { Post.to_xlsx columns: %i[name votes content ranking comments.last.content comments.first.author.name] }
6971
let(:sheet) { p.workbook.worksheets.first }
7072

71-
it 'should return xslx data' do
73+
it 'returns xslx data' do
7274
expect(sheet.rows.first.cells.first.value).to eq 'Name'
7375
expect(sheet.rows.last.cells.last.value).to eq Post.last.comments.last.author.name
7476
end

spec/config_rspec.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# Configure RSpec
24
RSpec.configure do |config|
35
# Use DB agnostic schema by default

0 commit comments

Comments
 (0)