Sha256: e4487a343d2ae59fd07f1454a0334580c6cf09fd8842602492fe2a41d0d989e6

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

require 'spec_helper'
require 'integration/helpers/test_model'

if (HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES)
  describe DataMapper::Predefined do
    before(:all) do
      TestModel.auto_migrate!
    end

    it "should be able to define resources of a Model" do
      test1 = TestModel.test1

      test1.should_not be_nil
      test1.name.should == 'test1'
      test1.number.should == 1
      test1.optional.should == 'yo'
      test1.body.should == %{This is a test.}
    end

    it "should be able to define resources with empty attributes" do
      test2 = TestModel.test2

      test2.should_not be_nil
      test2.name.should == 'test2'
      test2.number.should == 2
      test2.optional.should == 'hello'
      test2.body.should be_nil
    end

    it "should return existing resources" do
      first_test1 = TestModel.test1
      second_test1 = TestModel.test1

      first_test1.id.should == second_test1.id
    end

    it "should provide a generic interface for accessing resources" do
      test1 = TestModel[:test1]

      test1.name.should == 'test1'
      test1.number.should == 1
    end

    it "should raise an UnknownResource exception when accessing undefined resources" do
      lambda {
        TestModel[:test3]
      }.should raise_error(DataMapper::Predefined::UnknownResource)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dm-predefined-0.1.1 spec/integration/predefined_spec.rb