Sha256: 69fcf8fe9ce143afaf33b49df0dc59bc40aedac06a31dae5e72b3edeaeb7c7f3

Contents?: true

Size: 880 Bytes

Versions: 3

Compression:

Stored size: 880 Bytes

Contents

require "spec_helper"

class Foo < Quicken::Foundation
  ACCOUNT = {
    :number => /^N(.+)/,
    :type => /^T(.+)/
  }

  accessors_for_spec ACCOUNT
end

describe Quicken::Foundation do

  describe "when create" do

    it "should receive args and define each one as attribute" do
      foo = Foo.new({:number=>"0833_5710633", :type=>"Bank"})
      foo.number.should == "0833_5710633"
      foo.type.should == "Bank"
    end

    it "should have accessors based on his SPEC" do
      foo = Foo.new

      Foo::ACCOUNT.each do |key,item|
        foo.should respond_to(key)
        foo.should respond_to("#{key}=")
      end
    end

    it "should skip the attributes that doesn't fit in SPEC" do
      account = Foo.new({:number=>"0833_5710633", :anything=>"blabla"})
      account.number.should == "0833_5710633"
      account.should_not respond_to(:anything)
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
quicken-0.0.3 spec/quicken/foundation_spec.rb
quicken-0.0.2 spec/quicken/foundation_spec.rb
quicken-0.0.1 spec/quicken/foundation_spec.rb