Sha256: 1588ddcda02302afd828d0e7a197a8bf3b8f0a6f2b36f88fa0c0560af553bbd4

Contents?: true

Size: 911 Bytes

Versions: 5

Compression:

Stored size: 911 Bytes

Contents

require 'test_helper'

describe Charge do
  describe "validations" do
    subject { Charge.new }
    it "amount is required" do
      subject.valid?

      subject.errors[:amount][0].must_equal "can't be blank"
    end

    it "min amount is required" do
      subject.amount = 0
      subject.valid?

      subject.errors[:amount][0].must_equal "must be greater than or equal to 1"

      subject.amount = 100
      subject.valid?.must_equal true
    end
  end

  describe "states" do
    subject { Charge.create!({user_id: 1, amount: 10}, without_protection: true) }

    describe "initial state" do
      it "initial state is new" do
        Charge.new.state_name.must_equal :new
      end
    end

    describe "#approve" do
      it "changes state and real_amount" do
        subject.approve(5)

        subject.real_amount.must_equal 5
        subject.state_name.must_equal :ok
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
supercharged-2.0.4 test/supercharged/models/charge_test.rb
supercharged-2.0.3 test/supercharged/models/charge_test.rb
supercharged-2.0.2 test/supercharged/models/charge_test.rb
supercharged-2.0.1 test/supercharged/models/charge_test.rb
supercharged-2.0.0 test/supercharged/models/charge_test.rb