Sha256: 321234570506ed35e5f548298690ef9731bd3bad450aceb74cd0335de6560790

Contents?: true

Size: 919 Bytes

Versions: 30

Compression:

Stored size: 919 Bytes

Contents

require 'test_helper'

class CreditcardTest < ActiveModel::TestCase

  test 'active merchant should not validate an invalid card' do
    card = Creditcard.new
    refute card.valid?
  end

  test 'active merchant should validate a valid card' do
    card = build(:creditcard)
    assert card.valid?
  end

  test 'error message when number is nil' do
    card = build(:creditcard, number: nil)
    refute card.valid?
    assert_equal 'Please enter credit card number', card.errors.full_messages.first
  end

  test 'error message when number is not numeric' do
    card = build(:creditcard, number: 'a')
    refute card.valid?
    assert_equal 'Please check the credit card number you entered', card.errors.full_messages.first
  end

  test 'error message when cvv is nil' do
    card = build(:creditcard, cvv: nil)
    refute card.valid?
    assert_equal 'Please enter CVV', card.errors.full_messages.first
  end

end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
nimbleshop_core-0.0.23 test/unit/creditcard_test.rb
nimbleshop_core-0.0.21 test/unit/creditcard_test.rb
nimbleshop_core-0.0.20 test/unit/creditcard_test.rb
nimbleshop_core-0.0.19 test/unit/creditcard_test.rb
nimbleshop_core-0.0.17 test/unit/creditcard_test.rb
nimbleshop_core-0.0.16 test/unit/creditcard_test.rb
nimbleshop_core-0.0.15 test/unit/creditcard_test.rb
nimbleshop_core-0.0.14 test/unit/creditcard_test.rb
nimbleshop_core-0.0.14.rc2 test/unit/creditcard_test.rb
nimbleshop_core-0.0.14.rc1 test/unit/creditcard_test.rb
nimbleshop_core-0.0.13 test/unit/creditcard_test.rb
nimbleshop_core-0.0.12 test/unit/creditcard_test.rb
nimbleshop_core-0.0.11 test/unit/creditcard_test.rb
nimbleshop_core-0.0.10 test/unit/creditcard_test.rb
nimbleshop_core-0.0.9 test/unit/creditcard_test.rb
nimbleshop_core-0.0.8 test/unit/creditcard_test.rb
nimbleshop_core-0.0.7 test/unit/creditcard_test.rb
nimbleshop_core-0.0.5 test/unit/creditcard_test.rb
nimbleshop_core-0.0.4.beta1 test/unit/creditcard_test.rb
nimbleshop_core-0.0.4 test/unit/creditcard_test.rb