comma 4.1.0 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +12 -1
  3. data/.rubocop_todo.yml +3 -364
  4. data/.travis.yml +20 -38
  5. data/Appraisals +20 -1
  6. data/Gemfile +5 -1
  7. data/Gemfile.lock +54 -36
  8. data/README.md +59 -0
  9. data/Rakefile +2 -0
  10. data/comma.gemspec +12 -15
  11. data/gemfiles/active5.0.7.2.gemfile +12 -0
  12. data/gemfiles/active5.0.7.2.gemfile.lock +113 -0
  13. data/gemfiles/active5.1.7.gemfile +12 -0
  14. data/gemfiles/active5.1.7.gemfile.lock +113 -0
  15. data/gemfiles/active5.2.4.3.gemfile +12 -0
  16. data/gemfiles/active5.2.4.3.gemfile.lock +113 -0
  17. data/gemfiles/active6.0.3.1.gemfile +12 -0
  18. data/gemfiles/active6.0.3.1.gemfile.lock +113 -0
  19. data/gemfiles/{rails4.2.8.gemfile → rails5.0.7.2.gemfile} +5 -2
  20. data/gemfiles/rails5.0.7.2.gemfile.lock +204 -0
  21. data/gemfiles/{rails4.1.16.gemfile → rails5.1.7.gemfile} +5 -2
  22. data/gemfiles/rails5.1.7.gemfile.lock +204 -0
  23. data/gemfiles/{rails5.0.1.gemfile → rails5.2.4.3.gemfile} +5 -2
  24. data/gemfiles/rails5.2.4.3.gemfile.lock +212 -0
  25. data/gemfiles/{rails4.0.13.gemfile → rails6.0.3.1.gemfile} +4 -2
  26. data/gemfiles/rails6.0.3.1.gemfile.lock +227 -0
  27. data/init.rb +2 -0
  28. data/lib/comma.rb +26 -36
  29. data/lib/comma/array.rb +2 -0
  30. data/lib/comma/data_extractor.rb +7 -9
  31. data/lib/comma/data_mapper_collection.rb +8 -4
  32. data/lib/comma/extractor.rb +2 -6
  33. data/lib/comma/generator.rb +12 -13
  34. data/lib/comma/header_extractor.rb +19 -15
  35. data/lib/comma/mongoid.rb +10 -7
  36. data/lib/comma/object.rb +5 -2
  37. data/lib/comma/relation.rb +16 -10
  38. data/lib/comma/version.rb +3 -1
  39. data/spec/comma/comma_spec.rb +71 -50
  40. data/spec/comma/data_extractor_spec.rb +13 -18
  41. data/spec/comma/header_extractor_spec.rb +8 -15
  42. data/spec/comma/rails/active_record_spec.rb +34 -34
  43. data/spec/comma/rails/data_mapper_collection_spec.rb +4 -4
  44. data/spec/comma/rails/mongoid_spec.rb +8 -8
  45. data/spec/controllers/users_controller_spec.rb +83 -70
  46. data/spec/non_rails_app/ruby_classes.rb +13 -6
  47. data/spec/rails_app/active_record/config.rb +2 -2
  48. data/spec/rails_app/active_record/models.rb +3 -3
  49. data/spec/rails_app/data_mapper/config.rb +1 -1
  50. data/spec/rails_app/mongoid/config.rb +3 -3
  51. data/spec/rails_app/rails_app.rb +13 -13
  52. data/spec/rails_app/tmp/.gitkeep +0 -0
  53. data/spec/spec_helper.rb +21 -5
  54. metadata +29 -46
  55. data/README.markdown +0 -353
  56. data/gemfiles/active4.0.13.gemfile +0 -10
  57. data/gemfiles/active4.0.13.gemfile.lock +0 -107
  58. data/gemfiles/active4.1.16.gemfile +0 -10
  59. data/gemfiles/active4.1.16.gemfile.lock +0 -106
  60. data/gemfiles/active4.2.8.gemfile +0 -10
  61. data/gemfiles/active4.2.8.gemfile.lock +0 -105
  62. data/gemfiles/active5.0.1.gemfile +0 -10
  63. data/gemfiles/active5.0.1.gemfile.lock +0 -104
  64. data/gemfiles/active5.1.0.gemfile +0 -10
  65. data/gemfiles/active5.1.0.gemfile.lock +0 -104
  66. data/gemfiles/rails4.0.13.gemfile.lock +0 -158
  67. data/gemfiles/rails4.1.16.gemfile.lock +0 -163
  68. data/gemfiles/rails4.2.8.gemfile.lock +0 -187
  69. data/gemfiles/rails5.0.1.gemfile.lock +0 -194
  70. data/gemfiles/rails5.1.0.gemfile +0 -11
  71. data/gemfiles/rails5.1.0.gemfile.lock +0 -194
@@ -1,4 +1,5 @@
1
- # -*- coding: utf-8 -*-
1
+ # frozen_string_literal: true
2
+
2
3
  require 'comma/extractor'
3
4
  require 'active_support/core_ext/class/attribute'
4
5
  require 'active_support/core_ext/date_time/conversions'
@@ -7,44 +8,47 @@ require 'active_support/core_ext/string/inflections'
7
8
 
8
9
  module Comma
9
10
  class HeaderExtractor < Extractor
10
-
11
11
  class_attribute :value_humanizer
12
12
 
13
- DEFAULT_VALUE_HUMANIZER = lambda do |value, model_class|
13
+ DEFAULT_VALUE_HUMANIZER = lambda do |value, _model_class|
14
14
  value.is_a?(String) ? value : value.to_s.humanize
15
15
  end
16
16
  self.value_humanizer = DEFAULT_VALUE_HUMANIZER
17
17
 
18
- def method_missing(sym, *args, &block)
18
+ def method_missing(sym, *args, &_block)
19
19
  model_class = @instance.class
20
- @results << self.value_humanizer.call(sym, model_class) if args.blank?
20
+ @results << value_humanizer.call(sym, model_class) if args.blank?
21
21
  args.each do |arg|
22
22
  case arg
23
23
  when Hash
24
- arg.each do |k, v|
25
- @results << self.value_humanizer.call(v, get_association_class(model_class, sym))
24
+ arg.each do |_k, v|
25
+ @results << value_humanizer.call(v, get_association_class(model_class, sym))
26
26
  end
27
27
  when Symbol
28
- @results << self.value_humanizer.call(arg, get_association_class(model_class, sym))
28
+ @results << value_humanizer.call(arg, get_association_class(model_class, sym))
29
29
  when String
30
- @results << self.value_humanizer.call(arg, model_class)
30
+ @results << value_humanizer.call(arg, model_class)
31
31
  else
32
32
  raise "Unknown header symbol #{arg.inspect}"
33
33
  end
34
34
  end
35
35
  end
36
36
 
37
- def __static_column__(header = '', &block)
37
+ def __static_column__(header = '', &_block)
38
38
  @results << header
39
39
  end
40
40
 
41
41
  private
42
42
 
43
- def get_association_class(model_class, association)
44
- if model_class.respond_to?(:reflect_on_association)
45
- association = model_class.reflect_on_association(association)
46
- association.klass rescue nil
47
- end
43
+ def get_association_class(model_class, association)
44
+ return unless model_class.respond_to?(:reflect_on_association)
45
+
46
+ begin
47
+ model_class.reflect_on_association(association)&.klass
48
+ rescue ArgumentError, NameError
49
+ # Since Rails 5.2, ArgumentError is raised.
50
+ nil
51
+ end
48
52
  end
49
53
  end
50
54
  end
@@ -1,12 +1,15 @@
1
- #Conditionally set to_comma on Mongoid records if mongoid gem is installed
1
+ # frozen_string_literal: true
2
+
3
+ # Conditionally set to_comma on Mongoid records if mongoid gem is installed
2
4
  begin
3
5
  require 'mongoid'
4
- class Mongoid::Criteria
5
- def to_comma(style = :default)
6
- Comma::Generator.new(self, style).run(:each)
6
+
7
+ module Mongoid
8
+ class Criteria
9
+ def to_comma(style = :default)
10
+ Comma::Generator.new(self, style).run(:each)
11
+ end
7
12
  end
8
13
  end
9
- rescue LoadError
14
+ rescue LoadError # rubocop:disable Lint/HandleExceptions
10
15
  end
11
-
12
-
@@ -1,4 +1,5 @@
1
- # -*- coding: utf-8 -*-
1
+ # frozen_string_literal: true
2
+
2
3
  require 'comma/data_extractor'
3
4
  require 'comma/header_extractor'
4
5
 
@@ -32,6 +33,8 @@ class Object
32
33
  end
33
34
 
34
35
  def raise_unless_style_exists(style)
35
- raise "No comma format for class #{self.class} defined for style #{style}" unless self.comma_formats && self.comma_formats[style]
36
+ return if self.comma_formats && self.comma_formats[style]
37
+
38
+ raise "No comma format for class #{self.class} defined for style #{style}"
36
39
  end
37
40
  end
@@ -1,12 +1,18 @@
1
- class ActiveRecord::Relation
2
- def to_comma(style = :default)
3
- iterator_method =
4
- if arel.ast.limit || !arel.ast.orders.empty?
5
- Rails.logger.warn "#to_comma is being used on a relation with limit or order clauses. Falling back to iterating with :each. This can cause performance issues." if defined?(Rails)
6
- :each
7
- else
8
- :find_each
9
- end
10
- Comma::Generator.new(self, style).run(iterator_method)
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecord
4
+ class Relation
5
+ def to_comma(style = :default)
6
+ iterator_method =
7
+ if arel.ast.limit || !arel.ast.orders.empty?
8
+ Rails.logger.warn { <<~WARN } if defined?(Rails)
9
+ #to_comma is being used on a relation with limit or order clauses. Falling back to iterating with :each. This can cause performance issues.
10
+ WARN
11
+ :each
12
+ else
13
+ :find_each
14
+ end
15
+ Comma::Generator.new(self, style).run(iterator_method)
16
+ end
11
17
  end
12
18
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Comma
2
- VERSION = '4.1.0'
4
+ VERSION = '4.4.0'
3
5
  end
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.dirname(__FILE__) + '/../spec_helper'
2
4
 
3
5
  describe Comma do
4
-
5
6
  it 'should extend object to add a comma method' do
6
7
  expect(Object).to respond_to(:comma)
7
8
  end
@@ -30,7 +31,6 @@ describe Comma do
30
31
  end
31
32
 
32
33
  describe Comma, 'generating CSV' do # rubocop:disable Metrics/BlockLength
33
-
34
34
  before do
35
35
  @isbn = Isbn.new('123123123', '321321321')
36
36
  @book = Book.new('Smalltalk-80', 'Language and Implementation', @isbn)
@@ -40,53 +40,54 @@ describe Comma, 'generating CSV' do # rubocop:disable Metrics/BlockLength
40
40
  end
41
41
 
42
42
  it 'should extend Array to add a #to_comma method which will return CSV content for objects within the array' do
43
- expect(@books.to_comma).to eq("Title,Description,Issuer,ISBN-10,ISBN-13\nSmalltalk-80,Language and Implementation,ISBN,123123123,321321321\n")
43
+ expected = "Title,Description,Issuer,ISBN-10,ISBN-13\nSmalltalk-80,Language and Implementation,ISBN,123123123,321321321\n" # rubocop:disable Metrics/LineLength
44
+ expect(@books.to_comma).to eq(expected)
44
45
  end
45
46
 
46
47
  it 'should return an empty string when generating CSV from an empty array' do
47
- expect(Array.new.to_comma).to eq('')
48
+ expect([].to_comma).to eq('')
48
49
  end
49
50
 
50
- it "should change the style when specified" do
51
+ it 'should change the style when specified' do
51
52
  expect(@books.to_comma(:brief)).to eq("Name,Description\nSmalltalk-80,Language and Implementation\n")
52
53
  end
53
54
 
54
55
  describe 'with :filename specified' do
55
- after{ File.delete('comma.csv') }
56
+ after { File.delete('comma.csv') }
56
57
 
57
- it "should write to the file" do
58
- @books.to_comma(:filename => 'comma.csv')
59
- expect(File.read('comma.csv')).to eq("Title,Description,Issuer,ISBN-10,ISBN-13\nSmalltalk-80,Language and Implementation,ISBN,123123123,321321321\n")
58
+ it 'should write to the file' do
59
+ @books.to_comma(filename: 'comma.csv')
60
+ expected = "Title,Description,Issuer,ISBN-10,ISBN-13\nSmalltalk-80,Language and Implementation,ISBN,123123123,321321321\n" # rubocop:disable Metrics/LineLength
61
+ expect(File.read('comma.csv')).to eq(expected)
60
62
  end
61
63
 
62
- it "should accept FasterCSV options" do
63
- @books.to_comma(:filename => 'comma.csv', :col_sep => ';', :force_quotes => true)
64
- expect(File.read('comma.csv')).to eq("\"Title\";\"Description\";\"Issuer\";\"ISBN-10\";\"ISBN-13\"\n\"Smalltalk-80\";\"Language and Implementation\";\"ISBN\";\"123123123\";\"321321321\"\n")
64
+ it 'should accept FasterCSV options' do
65
+ @books.to_comma(filename: 'comma.csv', col_sep: ';', force_quotes: true)
66
+ expected = "\"Title\";\"Description\";\"Issuer\";\"ISBN-10\";\"ISBN-13\"\n\"Smalltalk-80\";\"Language and Implementation\";\"ISBN\";\"123123123\";\"321321321\"\n" # rubocop:disable Metrics/LineLength
67
+ expect(File.read('comma.csv')).to eq(expected)
65
68
  end
66
-
67
69
  end
68
70
 
69
- describe "with FasterCSV options" do
70
- it "should not change when options are empty" do
71
- expect(@books.to_comma({})).to eq("Title,Description,Issuer,ISBN-10,ISBN-13\nSmalltalk-80,Language and Implementation,ISBN,123123123,321321321\n")
71
+ describe 'with FasterCSV options' do
72
+ it 'should not change when options are empty' do
73
+ expected = "Title,Description,Issuer,ISBN-10,ISBN-13\nSmalltalk-80,Language and Implementation,ISBN,123123123,321321321\n" # rubocop:disable Metrics/LineLength
74
+ expect(@books.to_comma({})).to eq(expected)
72
75
  end
73
76
 
74
77
  it 'should accept the options in #to_comma and generate the appropriate CSV' do
75
- expect(@books.to_comma(:col_sep => ';', :force_quotes => true))
76
- .to eq("\"Title\";\"Description\";\"Issuer\";\"ISBN-10\";\"ISBN-13\"\n\"Smalltalk-80\";\"Language and Implementation\";\"ISBN\";\"123123123\";\"321321321\"\n")
78
+ expected = "\"Title\";\"Description\";\"Issuer\";\"ISBN-10\";\"ISBN-13\"\n\"Smalltalk-80\";\"Language and Implementation\";\"ISBN\";\"123123123\";\"321321321\"\n" # rubocop:disable Metrics/LineLength
79
+ expect(@books.to_comma(col_sep: ';', force_quotes: true)).to eq(expected)
77
80
  end
78
81
 
79
- it "should change the style when specified" do
80
- expect(@books.to_comma(:style => :brief, :col_sep => ';', :force_quotes => true))
82
+ it 'should change the style when specified' do
83
+ expect(@books.to_comma(style: :brief, col_sep: ';', force_quotes: true))
81
84
  .to eq("\"Name\";\"Description\"\n\"Smalltalk-80\";\"Language and Implementation\"\n")
82
85
  end
83
86
  end
84
87
  end
85
88
 
86
89
  describe Comma, 'defining CSV descriptions' do
87
-
88
90
  describe 'with an unnamed description' do
89
-
90
91
  before do
91
92
  class Foo
92
93
  comma do; end
@@ -100,7 +101,6 @@ describe Comma, 'defining CSV descriptions' do
100
101
  end
101
102
 
102
103
  describe 'with a named description' do
103
-
104
104
  before do
105
105
  class Bar
106
106
  comma do; end
@@ -117,9 +117,7 @@ describe Comma, 'defining CSV descriptions' do
117
117
  end
118
118
 
119
119
  describe Comma, 'to_comma data/headers object extensions' do # rubocop:disable Metrics/BlockLength
120
-
121
120
  describe 'with unnamed descriptions' do
122
-
123
121
  before do
124
122
  class Foo
125
123
  attr_accessor :content
@@ -144,11 +142,9 @@ describe Comma, 'to_comma data/headers object extensions' do # rubocop:disable M
144
142
  it 'should return the CSV representation including header and content when called on an array' do
145
143
  expect(Array(@foo).to_comma).to eq("Content\ncontent\n")
146
144
  end
147
-
148
145
  end
149
146
 
150
147
  describe 'with named descriptions' do
151
-
152
148
  before do
153
149
  class Foo
154
150
  attr_accessor :content
@@ -175,11 +171,10 @@ describe Comma, 'to_comma data/headers object extensions' do # rubocop:disable M
175
171
  end
176
172
 
177
173
  it 'should raise an error if the requested description is not avaliable' do
178
- expect { @foo.to_comma(:bad) }.to raise_error
179
- expect { @foo.to_comma_headers(:bad) }.to raise_error
180
- expect { Array(@foo).to_comma(:bad) }.to raise_error
174
+ expect { @foo.to_comma(:bad) }.to raise_error(RuntimeError)
175
+ expect { @foo.to_comma_headers(:bad) }.to raise_error(RuntimeError)
176
+ expect { Array(@foo).to_comma(:bad) }.to raise_error(RuntimeError)
181
177
  end
182
-
183
178
  end
184
179
 
185
180
  describe 'with block' do # rubocop:disable BlockLength
@@ -188,11 +183,11 @@ describe Comma, 'to_comma data/headers object extensions' do # rubocop:disable M
188
183
  attr_accessor :content, :created_at, :updated_at
189
184
  comma do
190
185
  content
191
- content('Truncated Content') {|i| i && i.length > 10 ? i[0..10] : '---' }
192
- created_at { |i| i && i.to_s(:db) }
193
- updated_at { |i| i && i.to_s(:db) }
194
- created_at 'Created Custom Label' do |i| i && i.to_s(:short) end
195
- updated_at 'Updated at Custom Label' do |i| i && i.to_s(:short) end
186
+ content('Truncated Content') { |i| i && i.length > 10 ? i[0..10] : '---' }
187
+ created_at { |i| i&.to_s(:db) }
188
+ updated_at { |i| i&.to_s(:db) }
189
+ created_at 'Created Custom Label' do |i| i&.to_s(:short) end
190
+ updated_at 'Updated at Custom Label' do |i| i&.to_s(:short) end
196
191
  end
197
192
 
198
193
  def initialize(content, created_at = Time.now, updated_at = Time.now)
@@ -209,38 +204,66 @@ describe Comma, 'to_comma data/headers object extensions' do # rubocop:disable M
209
204
 
210
205
  it 'should return yielded values by block' do
211
206
  _header, foo = Array(@foo).to_comma.split("\n")
212
- expect(foo).to eq([@content, @content[0..10], @time.to_s(:db), @time.to_s(:db), @time.to_s(:short), @time.to_s(:short)].join(','))
207
+ expected = [
208
+ @content,
209
+ @content[0..10],
210
+ @time.to_s(:db),
211
+ @time.to_s(:db),
212
+ @time.to_s(:short),
213
+ @time.to_s(:short)
214
+ ].join(',')
215
+ expect(foo).to eq(expected)
213
216
  end
214
217
 
215
218
  it 'should return headers with custom labels from block' do
216
219
  header, _foo = Array(@foo).to_comma.split("\n")
217
- expect(header).to eq(['Content', 'Truncated Content', 'Created at', 'Updated at', 'Created Custom Label', 'Updated at Custom Label'].join(','))
220
+ expected = [
221
+ 'Content',
222
+ 'Truncated Content',
223
+ 'Created at',
224
+ 'Updated at',
225
+ 'Created Custom Label',
226
+ 'Updated at Custom Label'
227
+ ].join(',')
228
+ expect(header).to eq(expected)
218
229
  end
219
230
 
220
231
  it 'should put headers in place when forced' do
221
- header, _foo = Array(@foo).to_comma(:write_headers => true).split("\n")
222
- expect(header).to eq(['Content', 'Truncated Content', 'Created at', 'Updated at', 'Created Custom Label', 'Updated at Custom Label'].join(','))
232
+ header, _foo = Array(@foo).to_comma(write_headers: true).split("\n")
233
+ expected = [
234
+ 'Content',
235
+ 'Truncated Content',
236
+ 'Created at',
237
+ 'Updated at',
238
+ 'Created Custom Label',
239
+ 'Updated at Custom Label'
240
+ ].join(',')
241
+ expect(header).to eq(expected)
223
242
  end
224
243
 
225
244
  it 'should not write headers if specified' do
226
- header, _foo = Array(@foo).to_comma(:write_headers => false).split("\n")
227
- expect(header).to eq([@content, @content[0..10], @time.to_s(:db), @time.to_s(:db), @time.to_s(:short), @time.to_s(:short)].join(','))
245
+ header, _foo = Array(@foo).to_comma(write_headers: false).split("\n")
246
+ expected = [
247
+ @content,
248
+ @content[0..10],
249
+ @time.to_s(:db),
250
+ @time.to_s(:db),
251
+ @time.to_s(:short),
252
+ @time.to_s(:short)
253
+ ].join(',')
254
+ expect(header).to eq(expected)
228
255
  end
229
-
230
256
  end
231
257
 
232
-
233
258
  describe 'on an object with no comma declaration' do
234
-
235
259
  it 'should raise an error mentioning there is no comma description defined for that class' do
236
260
  expect { 'a string'.to_comma }.to raise_error('No comma format for class String defined for style default')
237
- expect { 'a string'.to_comma_headers }.to raise_error('No comma format for class String defined for style default')
261
+ expect { 'a string'.to_comma_headers }
262
+ .to raise_error('No comma format for class String defined for style default')
238
263
  end
239
-
240
264
  end
241
265
 
242
266
  describe 'on objects using Single Table Inheritance' do
243
-
244
267
  before do
245
268
  class MySuperClass
246
269
  attr_accessor :content
@@ -273,9 +296,7 @@ describe Comma, 'to_comma data/headers object extensions' do # rubocop:disable M
273
296
  it 'should return and array of data content, as defined in comma block in super class, if not present in child' do
274
297
  expect(@childNoComma.to_comma).to eq(%w[super-content])
275
298
  end
276
-
277
299
  end
278
-
279
300
  end
280
301
 
281
302
  describe Comma, '__use__ keyword' do
@@ -1,4 +1,5 @@
1
- # -*- coding: utf-8 -*-
1
+ # frozen_string_literal: true
2
+
2
3
  require 'spec_helper'
3
4
 
4
5
  # comma do
@@ -9,7 +10,6 @@ require 'spec_helper'
9
10
  # end
10
11
 
11
12
  describe Comma::DataExtractor do # rubocop:disable Metrics/BlockLength
12
-
13
13
  before do
14
14
  @isbn = Isbn.new('123123123', '321321321')
15
15
  @book = Book.new('Smalltalk-80', 'Language and Implementation', @isbn)
@@ -18,47 +18,42 @@ describe Comma::DataExtractor do # rubocop:disable Metrics/BlockLength
18
18
  end
19
19
 
20
20
  describe 'when no parameters are provided' do
21
-
22
21
  it 'should use the string value returned by sending the method name on the object' do
23
- @data.should include('Language and Implementation')
22
+ expect(@data).to include('Language and Implementation')
24
23
  end
25
24
  end
26
25
 
27
26
  describe 'when given a string description as a parameter' do
28
-
29
27
  it 'should use the string value returned by sending the method name on the object' do
30
- @data.should include('Smalltalk-80')
28
+ expect(@data).to include('Smalltalk-80')
31
29
  end
32
30
  end
33
31
 
34
32
  describe 'when an hash is passed as a parameter' do
35
-
36
33
  describe 'with a string value' do
37
-
38
34
  it 'should use the string value, returned by sending the hash key to the object' do
39
- @data.should include('123123123')
40
- @data.should include('321321321')
35
+ expect(@data).to include('123123123')
36
+ expect(@data).to include('321321321')
41
37
  end
42
38
 
43
39
  it 'should not fail when an associated object is nil' do
44
- lambda { Book.new('Smalltalk-80', 'Language and Implementation', nil).to_comma }.should_not raise_error
40
+ expect { Book.new('Smalltalk-80', 'Language and Implementation', nil).to_comma }.not_to raise_error
45
41
  end
46
42
  end
47
43
  end
48
-
49
44
  end
50
45
 
51
46
  describe Comma::DataExtractor, 'id attribute' do
52
47
  before do
53
48
  @data = Class.new(Struct.new(:id)) do
54
49
  comma do
55
- id 'ID' do |id| '42' end
50
+ id 'ID' do |_id| '42' end
56
51
  end
57
52
  end.new(1).to_comma
58
53
  end
59
54
 
60
55
  it 'id attribute should yield block' do
61
- @data.should include('42')
56
+ expect(@data).to include('42')
62
57
  end
63
58
  end
64
59
 
@@ -69,13 +64,13 @@ describe Comma::DataExtractor, 'with static column method' do
69
64
  __static_column__
70
65
  __static_column__ 'STATIC'
71
66
  __static_column__ 'STATIC' do '' end
72
- __static_column__ 'STATIC' do |o| o.name end
67
+ __static_column__ 'STATIC', &:name
73
68
  end
74
69
  end.new(1, 'John Doe').to_comma
75
70
  end
76
71
 
77
72
  it 'should extract headers' do
78
- @data.should eq([nil, nil, '', 'John Doe'])
73
+ expect(@data).to eq([nil, nil, '', 'John Doe'])
79
74
  end
80
75
  end
81
76
 
@@ -85,12 +80,12 @@ describe Comma::DataExtractor, 'nil value' do
85
80
  comma do
86
81
  name
87
82
  name 'Name'
88
- name 'Name' do |name| nil end
83
+ name 'Name' do |_name| nil end
89
84
  end
90
85
  end.new(1, nil).to_comma
91
86
  end
92
87
 
93
88
  it 'should extract nil' do
94
- @data.should eq([nil, nil, nil])
89
+ expect(@data).to eq([nil, nil, nil])
95
90
  end
96
91
  end