Sha256: 9448e82494bb0faeabfe82cd651aedd115f89ab932e2b63a02d0b2ef96072c2c

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

require './spec/spec_helper'
require "./lib/mass_insert"

describe "String" do

  before :each do
    @values, @options  = [{:name => "some name"}], {}
  end

  context "when exist in values hashes" do
    context "when contains a string" do
      it "should be saved correctly" do
        User.mass_insert(@values, @options)
        User.last.name.should eq("some name")
      end
    end

    context "when contains a integer" do
      it "should convert integer value to string" do
        @values.first.merge!(:name => 10)
        User.mass_insert(@values, @options)
        User.last.name.should eq("10")
      end
    end

    context "when contains a decimal" do
      it "should convert decimal value to string" do
        @values.first.merge!(:name => 25.69)
        User.mass_insert(@values, @options)
        User.last.name.should eq("25.69")
      end
    end

    context "when contains a boolean" do
      it "should convert boolean value to string" do
        @values.first.merge!(:name => true)
        User.mass_insert(@values, @options)
        User.last.name.should eq("true")
      end
    end
  end

  context "when not exist in values hashes" do
    it "should save the default value" do
      @values.first.delete(:name)
      User.mass_insert(@values, @options)
      User.last.name.should eq(nil)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mass_insert-0.0.3 spec/active_record_models/column_types/string_spec.rb
mass_insert-0.0.2 spec/active_record_models/column_types/string_spec.rb
mass_insert-0.0.1 spec/active_record_models/column_types/string_spec.rb