spec/config_spec.rb in csv_shaper-1.1.0 vs spec/config_spec.rb in csv_shaper-1.1.1
- old
+ new
@@ -11,9 +11,23 @@
it "should assign options to config" do
expect(config.options).to eq({ write_headers: false, col_sep: "\t", header_inflector: :titleize })
end
+ it "does not require setting up the config before generating a CSV file" do
+ shaper = CsvShaper::Shaper.new do |csv|
+ csv.headers :name, :age, :gender
+
+ csv.row do |csv|
+ csv.cell :name, 'Paul'
+ csv.cell :age, '27'
+ csv.cell :gender, 'Male'
+ end
+ end
+
+ expect(shaper.to_csv).to eq "Name,Age,Gender\nPaul,27,Male\n"
+ end
+
it "should exclude the headers if specified" do
CsvShaper::Shaper.config = config
shaper = CsvShaper::Shaper.new do |csv|
csv.headers :name, :age, :gender