comma 4.0.1 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +10 -0
  3. data/.rubocop_todo.yml +422 -0
  4. data/.travis.yml +32 -19
  5. data/Appraisals +7 -7
  6. data/Gemfile +3 -2
  7. data/Gemfile.lock +18 -3
  8. data/Rakefile +5 -5
  9. data/comma.gemspec +2 -1
  10. data/gemfiles/active4.0.13.gemfile +1 -0
  11. data/gemfiles/active4.0.13.gemfile.lock +15 -1
  12. data/gemfiles/active4.1.16.gemfile +1 -0
  13. data/gemfiles/active4.1.16.gemfile.lock +19 -4
  14. data/gemfiles/{active5.0.0.1.gemfile → active4.2.8.gemfile} +3 -2
  15. data/gemfiles/{active4.2.7.1.gemfile.lock → active4.2.8.gemfile.lock} +45 -31
  16. data/gemfiles/active5.0.1.gemfile +10 -0
  17. data/gemfiles/{active5.0.0.1.gemfile.lock → active5.0.1.gemfile.lock} +45 -30
  18. data/gemfiles/active5.1.0.gemfile +10 -0
  19. data/gemfiles/active5.1.0.gemfile.lock +104 -0
  20. data/gemfiles/rails4.0.13.gemfile +1 -0
  21. data/gemfiles/rails4.0.13.gemfile.lock +15 -1
  22. data/gemfiles/rails4.1.16.gemfile +1 -0
  23. data/gemfiles/rails4.1.16.gemfile.lock +19 -4
  24. data/gemfiles/{rails4.2.7.1.gemfile → rails4.2.8.gemfile} +2 -1
  25. data/gemfiles/{rails4.2.7.1.gemfile.lock → rails4.2.8.gemfile.lock} +81 -69
  26. data/gemfiles/{rails5.0.0.1.gemfile → rails5.0.1.gemfile} +2 -1
  27. data/gemfiles/{rails5.0.0.1.gemfile.lock → rails5.0.1.gemfile.lock} +83 -70
  28. data/gemfiles/{active4.2.7.1.gemfile → rails5.1.0.gemfile} +4 -2
  29. data/gemfiles/rails5.1.0.gemfile.lock +194 -0
  30. data/lib/comma/version.rb +1 -1
  31. data/spec/comma/comma_spec.rb +42 -40
  32. data/spec/comma/data_extractor_spec.rb +1 -1
  33. data/spec/comma/header_extractor_spec.rb +1 -1
  34. data/spec/comma/rails/active_record_spec.rb +5 -5
  35. data/spec/comma/rails/data_mapper_collection_spec.rb +1 -1
  36. data/spec/controllers/users_controller_spec.rb +41 -30
  37. data/spec/rails_app/active_record/models.rb +8 -1
  38. data/spec/rails_app/rails_app.rb +27 -3
  39. metadata +19 -13
@@ -1,3 +1,3 @@
1
1
  module Comma
2
- VERSION = '4.0.1'
2
+ VERSION = '4.1.0'
3
3
  end
@@ -3,15 +3,15 @@ require File.dirname(__FILE__) + '/../spec_helper'
3
3
  describe Comma do
4
4
 
5
5
  it 'should extend object to add a comma method' do
6
- Object.should respond_to(:comma)
6
+ expect(Object).to respond_to(:comma)
7
7
  end
8
8
 
9
9
  it 'should extend object to have a to_comma method' do
10
- Object.should respond_to(:to_comma)
10
+ expect(Object).to respond_to(:to_comma)
11
11
  end
12
12
 
13
13
  it 'should extend object to have a to_comma_headers method' do
14
- Object.should respond_to(:to_comma_headers)
14
+ expect(Object).to respond_to(:to_comma_headers)
15
15
  end
16
16
 
17
17
  describe '.to_comma_header' do
@@ -29,7 +29,7 @@ describe Comma do
29
29
  end
30
30
  end
31
31
 
32
- describe Comma, 'generating CSV' do
32
+ describe Comma, 'generating CSV' do # rubocop:disable Metrics/BlockLength
33
33
 
34
34
  before do
35
35
  @isbn = Isbn.new('123123123', '321321321')
@@ -40,15 +40,15 @@ describe Comma, 'generating CSV' do
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
- @books.to_comma.should == "Title,Description,Issuer,ISBN-10,ISBN-13\nSmalltalk-80,Language and Implementation,ISBN,123123123,321321321\n"
43
+ expect(@books.to_comma).to eq("Title,Description,Issuer,ISBN-10,ISBN-13\nSmalltalk-80,Language and Implementation,ISBN,123123123,321321321\n")
44
44
  end
45
45
 
46
46
  it 'should return an empty string when generating CSV from an empty array' do
47
- Array.new.to_comma.should == ''
47
+ expect(Array.new.to_comma).to eq('')
48
48
  end
49
49
 
50
50
  it "should change the style when specified" do
51
- @books.to_comma(:brief).should == "Name,Description\nSmalltalk-80,Language and Implementation\n"
51
+ expect(@books.to_comma(:brief)).to eq("Name,Description\nSmalltalk-80,Language and Implementation\n")
52
52
  end
53
53
 
54
54
  describe 'with :filename specified' do
@@ -56,27 +56,29 @@ describe Comma, 'generating CSV' do
56
56
 
57
57
  it "should write to the file" do
58
58
  @books.to_comma(:filename => 'comma.csv')
59
- File.read('comma.csv').should == "Title,Description,Issuer,ISBN-10,ISBN-13\nSmalltalk-80,Language and Implementation,ISBN,123123123,321321321\n"
59
+ expect(File.read('comma.csv')).to eq("Title,Description,Issuer,ISBN-10,ISBN-13\nSmalltalk-80,Language and Implementation,ISBN,123123123,321321321\n")
60
60
  end
61
61
 
62
62
  it "should accept FasterCSV options" do
63
63
  @books.to_comma(:filename => 'comma.csv', :col_sep => ';', :force_quotes => true)
64
- File.read('comma.csv').should == "\"Title\";\"Description\";\"Issuer\";\"ISBN-10\";\"ISBN-13\"\n\"Smalltalk-80\";\"Language and Implementation\";\"ISBN\";\"123123123\";\"321321321\"\n"
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")
65
65
  end
66
66
 
67
67
  end
68
68
 
69
69
  describe "with FasterCSV options" do
70
70
  it "should not change when options are empty" do
71
- @books.to_comma({}).should == "Title,Description,Issuer,ISBN-10,ISBN-13\nSmalltalk-80,Language and Implementation,ISBN,123123123,321321321\n"
71
+ expect(@books.to_comma({})).to eq("Title,Description,Issuer,ISBN-10,ISBN-13\nSmalltalk-80,Language and Implementation,ISBN,123123123,321321321\n")
72
72
  end
73
73
 
74
74
  it 'should accept the options in #to_comma and generate the appropriate CSV' do
75
- @books.to_comma(:col_sep => ';', :force_quotes => true).should == "\"Title\";\"Description\";\"Issuer\";\"ISBN-10\";\"ISBN-13\"\n\"Smalltalk-80\";\"Language and Implementation\";\"ISBN\";\"123123123\";\"321321321\"\n"
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")
76
77
  end
77
78
 
78
79
  it "should change the style when specified" do
79
- @books.to_comma(:style => :brief, :col_sep => ';', :force_quotes => true).should == "\"Name\";\"Description\"\n\"Smalltalk-80\";\"Language and Implementation\"\n"
80
+ expect(@books.to_comma(:style => :brief, :col_sep => ';', :force_quotes => true))
81
+ .to eq("\"Name\";\"Description\"\n\"Smalltalk-80\";\"Language and Implementation\"\n")
80
82
  end
81
83
  end
82
84
  end
@@ -92,8 +94,8 @@ describe Comma, 'defining CSV descriptions' do
92
94
  end
93
95
 
94
96
  it 'should name the current description :default if no name has been provided' do
95
- Foo.comma_formats.should_not be_empty
96
- Foo.comma_formats[:default].should_not be_nil
97
+ expect(Foo.comma_formats).not_to be_empty
98
+ expect(Foo.comma_formats[:default]).not_to be_nil
97
99
  end
98
100
  end
99
101
 
@@ -107,14 +109,14 @@ describe Comma, 'defining CSV descriptions' do
107
109
  end
108
110
 
109
111
  it 'should use the provided name to index the comma format' do
110
- Bar.comma_formats.should_not be_empty
111
- Bar.comma_formats[:default].should_not be_nil
112
- Bar.comma_formats[:detailed].should_not be_nil
112
+ expect(Bar.comma_formats).not_to be_empty
113
+ expect(Bar.comma_formats[:default]).not_to be_nil
114
+ expect(Bar.comma_formats[:detailed]).not_to be_nil
113
115
  end
114
116
  end
115
117
  end
116
118
 
117
- describe Comma, 'to_comma data/headers object extensions' do
119
+ describe Comma, 'to_comma data/headers object extensions' do # rubocop:disable Metrics/BlockLength
118
120
 
119
121
  describe 'with unnamed descriptions' do
120
122
 
@@ -132,15 +134,15 @@ describe Comma, 'to_comma data/headers object extensions' do
132
134
  end
133
135
 
134
136
  it 'should return and array of data content, using the :default CSV description if none requested' do
135
- @foo.to_comma.should == %w(content)
137
+ expect(@foo.to_comma).to eq(%w[content])
136
138
  end
137
139
 
138
140
  it 'should return and array of header content, using the :default CSV description if none requested' do
139
- @foo.to_comma_headers.should == %w(Content)
141
+ expect(@foo.to_comma_headers).to eq(%w[Content])
140
142
  end
141
143
 
142
144
  it 'should return the CSV representation including header and content when called on an array' do
143
- Array(@foo).to_comma.should == "Content\ncontent\n"
145
+ expect(Array(@foo).to_comma).to eq("Content\ncontent\n")
144
146
  end
145
147
 
146
148
  end
@@ -161,26 +163,26 @@ describe Comma, 'to_comma data/headers object extensions' do
161
163
  end
162
164
 
163
165
  it 'should return and array of data content, using the :default CSV description if none requested' do
164
- @foo.to_comma(:detailed).should == %w(content)
166
+ expect(@foo.to_comma(:detailed)).to eq(%w[content])
165
167
  end
166
168
 
167
169
  it 'should return and array of header content, using the :default CSV description if none requested' do
168
- @foo.to_comma_headers(:detailed).should == %w(Content)
170
+ expect(@foo.to_comma_headers(:detailed)).to eq(%w[Content])
169
171
  end
170
172
 
171
173
  it 'should return the CSV representation including header and content when called on an array' do
172
- Array(@foo).to_comma(:detailed).should == "Content\ncontent\n"
174
+ expect(Array(@foo).to_comma(:detailed)).to eq("Content\ncontent\n")
173
175
  end
174
176
 
175
177
  it 'should raise an error if the requested description is not avaliable' do
176
- lambda { @foo.to_comma(:bad) }.should raise_error
177
- lambda { @foo.to_comma_headers(:bad) }.should raise_error
178
- lambda { Array(@foo).to_comma(:bad) }.should raise_error
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
179
181
  end
180
182
 
181
183
  end
182
184
 
183
- describe 'with block' do
185
+ describe 'with block' do # rubocop:disable BlockLength
184
186
  before do
185
187
  class Foo
186
188
  attr_accessor :content, :created_at, :updated_at
@@ -206,23 +208,23 @@ describe Comma, 'to_comma data/headers object extensions' do
206
208
  end
207
209
 
208
210
  it 'should return yielded values by block' do
209
- header, foo = Array(@foo).to_comma.split("\n")
210
- foo.should == [@content, @content[0..10], @time.to_s(:db), @time.to_s(:db), @time.to_s(:short), @time.to_s(:short)].join(',')
211
+ _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(','))
211
213
  end
212
214
 
213
215
  it 'should return headers with custom labels from block' do
214
- header, foo = Array(@foo).to_comma.split("\n")
215
- header.should == ['Content', 'Truncated Content', 'Created at', 'Updated at', 'Created Custom Label', 'Updated at Custom Label'].join(',')
216
+ 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(','))
216
218
  end
217
219
 
218
220
  it 'should put headers in place when forced' do
219
- header, foo = Array(@foo).to_comma(:write_headers => true).split("\n")
220
- header.should == ['Content', 'Truncated Content', 'Created at', 'Updated at', 'Created Custom Label', 'Updated at Custom Label'].join(',')
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(','))
221
223
  end
222
224
 
223
225
  it 'should not write headers if specified' do
224
- header, foo = Array(@foo).to_comma(:write_headers => false).split("\n")
225
- header.should == [@content, @content[0..10], @time.to_s(:db), @time.to_s(:db), @time.to_s(:short), @time.to_s(:short)].join(',')
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(','))
226
228
  end
227
229
 
228
230
  end
@@ -231,8 +233,8 @@ describe Comma, 'to_comma data/headers object extensions' do
231
233
  describe 'on an object with no comma declaration' do
232
234
 
233
235
  it 'should raise an error mentioning there is no comma description defined for that class' do
234
- lambda { 'a string'.to_comma }.should raise_error('No comma format for class String defined for style default')
235
- lambda { 'a string'.to_comma_headers }.should raise_error('No comma format for class String defined for style default')
236
+ 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')
236
238
  end
237
239
 
238
240
  end
@@ -265,11 +267,11 @@ describe Comma, 'to_comma data/headers object extensions' do
265
267
  end
266
268
 
267
269
  it 'should return and array of data content, as defined in comma block in child class' do
268
- @childComma.to_comma.should == %w(sub-content)
270
+ expect(@childComma.to_comma).to eq(%w[sub-content])
269
271
  end
270
272
 
271
273
  it 'should return and array of data content, as defined in comma block in super class, if not present in child' do
272
- @childNoComma.to_comma.should == %w(super-content)
274
+ expect(@childNoComma.to_comma).to eq(%w[super-content])
273
275
  end
274
276
 
275
277
  end
@@ -8,7 +8,7 @@ require 'spec_helper'
8
8
  # isbn :number_10 => 'ISBN-10', :number_13 => 'ISBN-13'
9
9
  # end
10
10
 
11
- describe Comma::DataExtractor do
11
+ describe Comma::DataExtractor do # rubocop:disable Metrics/BlockLength
12
12
 
13
13
  before do
14
14
  @isbn = Isbn.new('123123123', '321321321')
@@ -8,7 +8,7 @@ require 'spec_helper'
8
8
  # isbn :number_10 => 'ISBN-10', :number_13 => 'ISBN-13'
9
9
  # end
10
10
 
11
- describe Comma::HeaderExtractor do
11
+ describe Comma::HeaderExtractor do # rubocop:disable Metcirs/BlockLength
12
12
 
13
13
  before do
14
14
  @isbn = Isbn.new('123123123', '321321321')
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
 
4
4
  if defined? ActiveRecord
5
5
 
6
- describe Comma, 'generating CSV from an ActiveRecord object' do
6
+ describe Comma, 'generating CSV from an ActiveRecord object' do # rubocop:disable Metrics/BlockLength
7
7
 
8
8
  class Picture < ActiveRecord::Base
9
9
  belongs_to :imageable, :polymorphic => true
@@ -14,7 +14,7 @@ if defined? ActiveRecord
14
14
  end
15
15
 
16
16
  class Person < ActiveRecord::Base
17
- scope :teenagers, lambda { where(:age => 13..19) }
17
+ scope(:teenagers, lambda { where(:age => 13..19) })
18
18
 
19
19
  comma do
20
20
  name
@@ -149,7 +149,7 @@ if defined? ActiveRecord
149
149
  end
150
150
  end
151
151
 
152
- describe Comma, 'generating CSV from an ActiveRecord object using Single Table Inheritance' do
152
+ describe Comma, 'generating CSV from an ActiveRecord object using Single Table Inheritance' do # rubocop:disable Metrics/BlockLength
153
153
  class Animal < ActiveRecord::Base
154
154
  comma do
155
155
  name 'Name' do |name|
@@ -188,12 +188,12 @@ if defined? ActiveRecord
188
188
  end
189
189
 
190
190
  it 'should return and array of data content, as defined in comma block in child class' do
191
- @dog.to_comma.should == %w(Dog-Rex)
191
+ @dog.to_comma.should == %w[Dog-Rex]
192
192
  end
193
193
 
194
194
  #FIXME: this one is failing - the comma block from Dog is executed instead of the one from the super class
195
195
  it 'should return and array of data content, as defined in comma block in super class, if not present in child' do
196
- @cat.to_comma.should == %w(Super-Kitty)
196
+ @cat.to_comma.should == %w[Super-Kitty]
197
197
  end
198
198
 
199
199
  it 'should call definion in parent class' do
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
 
4
4
  if defined? DataMapper
5
5
 
6
- describe Comma, 'generating CSV from an DataMapper object' do
6
+ describe Comma, 'generating CSV from an DataMapper object' do # rubocop:disable Metrics/BlockLength
7
7
 
8
8
  class Person
9
9
  include DataMapper::Resource
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  if defined?(Rails)
4
4
 
5
- RSpec.describe UsersController, type: :controller do
5
+ RSpec.describe UsersController, type: :controller do # rubocop:disable Metrics/BlockLength
6
6
 
7
7
  describe "rails setup" do
8
8
 
@@ -17,7 +17,7 @@ if defined?(Rails)
17
17
 
18
18
  end
19
19
 
20
- describe "controller" do
20
+ describe "controller" do # rubocop:disable Metrics/BlockLength
21
21
  before(:all) do
22
22
  @user_1 = User.create!(:first_name => 'Fred', :last_name => 'Flintstone')
23
23
  @user_2 = User.create!(:first_name => 'Wilma', :last_name => 'Flintstone')
@@ -26,16 +26,16 @@ if defined?(Rails)
26
26
  it 'should not affect html requested' do
27
27
  get :index
28
28
 
29
- response.status.should == 200
30
- response.content_type.should == 'text/html'
29
+ response.status.should eq 200
30
+ response.content_type.should eq 'text/html'
31
31
  response.body.should == 'Users!'
32
32
  end
33
33
 
34
34
  it "should return a csv when requested" do
35
35
  get :index, :format => :csv
36
36
 
37
- response.status.should == 200
38
- response.content_type.should == 'text/csv'
37
+ response.status.should eq 200
38
+ response.content_type.should eq 'text/csv'
39
39
  response.header["Content-Disposition"].should include('filename="data.csv"')
40
40
 
41
41
  expected_content =<<-CSV.gsub(/^\s+/,'')
@@ -66,22 +66,33 @@ if defined?(Rails)
66
66
 
67
67
  end
68
68
 
69
- describe 'with custom options' do
69
+ describe 'with custom options' do # rubocop:disable Metrics/BlockLength
70
+ def is_rails_4?
71
+ Rails::VERSION::STRING =~ /^4.*/
72
+ end
73
+
74
+ def get_(name, **args)
75
+ if is_rails_4? && args[:params]
76
+ args.merge!(args[:params])
77
+ args.delete(:params)
78
+ end
79
+ get name, **args
80
+ end
70
81
 
71
82
  it 'should allow a filename to be set' do
72
- get :with_custom_options, :format => :csv, :custom_options => { :filename => 'my_custom_name' }
83
+ get_ :with_custom_options, :format => :csv, :params => { :custom_options => { :filename => 'my_custom_name' } }
73
84
 
74
- response.status.should == 200
75
- response.content_type.should == 'text/csv'
85
+ response.status.should eq 200
86
+ response.content_type.should eq 'text/csv'
76
87
  response.header["Content-Disposition"].should include('filename="my_custom_name.csv"')
77
88
  end
78
89
 
79
90
  it "should allow a custom filename with spaces" do
80
91
  require 'shellwords'
81
- get :with_custom_options, :format => :csv, :custom_options => { :filename => 'filename with a lot of spaces' }
92
+ get_ :with_custom_options, :format => :csv, :params => { :custom_options => { :filename => 'filename with a lot of spaces' } }
82
93
 
83
- response.status.should == 200
84
- response.content_type.should == 'text/csv'
94
+ response.status.should eq 200
95
+ response.content_type.should eq 'text/csv'
85
96
  response.header["Content-Disposition"].should include('filename="filename with a lot of spaces.csv"')
86
97
 
87
98
  filename_string = response.header["Content-Disposition"].split('=').last
@@ -90,26 +101,26 @@ if defined?(Rails)
90
101
  end
91
102
 
92
103
  it 'should allow a file extension to be set' do
93
- get :with_custom_options, :format => :csv, :custom_options => { :extension => :txt }
104
+ get_ :with_custom_options, :format => :csv, :params => { :custom_options => { :extension => :txt } }
94
105
 
95
- response.status.should == 200
96
- response.content_type.should == 'text/csv'
106
+ response.status.should eq 200
107
+ response.content_type.should eq 'text/csv'
97
108
  response.header["Content-Disposition"].should include('filename="data.txt"')
98
109
  end
99
110
 
100
111
  it 'should allow mime type to be set' do
101
- get :with_custom_options, :format => :csv, :custom_options => { :mime_type => Mime::TEXT }
102
- response.status.should == 200
112
+ get_ :with_custom_options, :format => :csv, :params => { :custom_options => { :mime_type => 'text/plain' } }
113
+ response.status.should eq 200
103
114
  response.content_type.should == 'text/plain'
104
115
  end
105
116
 
106
117
  describe 'headers' do
107
118
 
108
119
  it 'should allow toggling on' do
109
- get :with_custom_options, :format => :csv, :custom_options => { :write_headers => 'true' }
120
+ get_ :with_custom_options, :format => :csv, :params => { :custom_options => { :write_headers => 'true' } }
110
121
 
111
- response.status.should == 200
112
- response.content_type.should == 'text/csv'
122
+ response.status.should eq 200
123
+ response.content_type.should eq 'text/csv'
113
124
 
114
125
  expected_content =<<-CSV.gsub(/^\s+/,'')
115
126
  First name,Last name,Name
@@ -121,10 +132,10 @@ if defined?(Rails)
121
132
  end
122
133
 
123
134
  it 'should allow toggling off' do
124
- get :with_custom_options, :format => :csv, :custom_options => {:write_headers => false}
135
+ get_ :with_custom_options, :format => :csv, :params => { :custom_options => {:write_headers => false} }
125
136
 
126
- response.status.should == 200
127
- response.content_type.should == 'text/csv'
137
+ response.status.should eq 200
138
+ response.content_type.should eq 'text/csv'
128
139
 
129
140
  expected_content =<<-CSV.gsub(/^\s+/,'')
130
141
  Fred,Flintstone,Fred Flintstone
@@ -137,10 +148,10 @@ if defined?(Rails)
137
148
  end
138
149
 
139
150
  it 'should allow forcing of quotes' do
140
- get :with_custom_options, :format => :csv, :custom_options => { :force_quotes => true }
151
+ get_ :with_custom_options, :format => :csv, :params => { :custom_options => { :force_quotes => true } }
141
152
 
142
- response.status.should == 200
143
- response.content_type.should == 'text/csv'
153
+ response.status.should eq 200
154
+ response.content_type.should eq 'text/csv'
144
155
 
145
156
  expected_content =<<-CSV.gsub(/^\s+/,'')
146
157
  "First name","Last name","Name"
@@ -152,10 +163,10 @@ if defined?(Rails)
152
163
  end
153
164
 
154
165
  it 'should allow combinations of options' do
155
- get :with_custom_options, :format => :csv, :custom_options => { :write_headers => false, :force_quotes => true, :col_sep => '||', :row_sep => "ENDOFLINE\n" }
166
+ get_ :with_custom_options, :format => :csv, :params => { :custom_options => { :write_headers => false, :force_quotes => true, :col_sep => '||', :row_sep => "ENDOFLINE\n" } }
156
167
 
157
- response.status.should == 200
158
- response.content_type.should == 'text/csv'
168
+ response.status.should eq 200
169
+ response.content_type.should eq 'text/csv'
159
170
 
160
171
  expected_content =<<-CSV.gsub(/^\s+/,'')
161
172
  "Fred"||"Flintstone"||"Fred Flintstone"ENDOFLINE
@@ -28,7 +28,14 @@ class User < ActiveRecord::Base
28
28
  end
29
29
  end
30
30
 
31
- class CreateTables < ActiveRecord::Migration
31
+ MIGRATION_CLASS =
32
+ if Rails::VERSION::STRING =~ /^5.*/
33
+ ActiveRecord::Migration[4.2]
34
+ else
35
+ ActiveRecord::Migration
36
+ end
37
+
38
+ class CreateTables < MIGRATION_CLASS
32
39
  def self.up
33
40
  create_table :users do |t|
34
41
  t.string :first_name