dm-types 0.10.2 → 1.0.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +36 -0
- data/Gemfile +147 -0
- data/Rakefile +7 -8
- data/VERSION +1 -1
- data/dm-types.gemspec +61 -20
- data/lib/dm-types.rb +24 -19
- data/lib/dm-types/bcrypt_hash.rb +17 -13
- data/lib/dm-types/comma_separated_list.rb +11 -16
- data/lib/dm-types/csv.rb +11 -11
- data/lib/dm-types/enum.rb +33 -50
- data/lib/dm-types/epoch_time.rb +11 -11
- data/lib/dm-types/file_path.rb +13 -10
- data/lib/dm-types/flag.rb +17 -25
- data/lib/dm-types/ip_address.rb +15 -11
- data/lib/dm-types/json.rb +17 -14
- data/lib/dm-types/paranoid/base.rb +38 -0
- data/lib/dm-types/paranoid_boolean.rb +23 -0
- data/lib/dm-types/paranoid_datetime.rb +22 -0
- data/lib/dm-types/regexp.rb +8 -8
- data/lib/dm-types/slug.rb +7 -12
- data/lib/dm-types/uri.rb +21 -9
- data/lib/dm-types/uuid.rb +18 -11
- data/lib/dm-types/yaml.rb +12 -10
- data/spec/fixtures/article.rb +0 -2
- data/spec/fixtures/bookmark.rb +0 -2
- data/spec/fixtures/network_node.rb +0 -2
- data/spec/fixtures/person.rb +0 -2
- data/spec/fixtures/software_package.rb +0 -2
- data/spec/fixtures/ticket.rb +2 -4
- data/spec/fixtures/tshirt.rb +3 -5
- data/spec/integration/bcrypt_hash_spec.rb +33 -31
- data/spec/integration/comma_separated_list_spec.rb +55 -53
- data/spec/integration/enum_spec.rb +55 -53
- data/spec/integration/file_path_spec.rb +105 -103
- data/spec/integration/flag_spec.rb +42 -40
- data/spec/integration/ip_address_spec.rb +91 -89
- data/spec/integration/json_spec.rb +41 -39
- data/spec/integration/slug_spec.rb +36 -34
- data/spec/integration/uri_spec.rb +82 -79
- data/spec/integration/uuid_spec.rb +63 -61
- data/spec/integration/yaml_spec.rb +37 -35
- data/spec/spec_helper.rb +7 -36
- data/spec/unit/bcrypt_hash_spec.rb +18 -10
- data/spec/unit/csv_spec.rb +92 -80
- data/spec/unit/enum_spec.rb +27 -42
- data/spec/unit/epoch_time_spec.rb +18 -7
- data/spec/unit/file_path_spec.rb +15 -10
- data/spec/unit/flag_spec.rb +13 -36
- data/spec/unit/ip_address_spec.rb +13 -10
- data/spec/unit/json_spec.rb +21 -14
- data/spec/unit/paranoid_boolean_spec.rb +138 -0
- data/spec/unit/paranoid_datetime_spec.rb +143 -0
- data/spec/unit/regexp_spec.rb +15 -5
- data/spec/unit/uri_spec.rb +13 -9
- data/spec/unit/yaml_spec.rb +16 -9
- data/tasks/local_gemfile.rake +18 -0
- data/tasks/spec.rake +0 -3
- metadata +122 -52
| @@ -5,73 +5,75 @@ try_spec do | |
| 5 5 | 
             
              require './spec/fixtures/ticket'
         | 
| 6 6 |  | 
| 7 7 | 
             
              describe DataMapper::Types::Fixtures::Ticket do
         | 
| 8 | 
            -
                 | 
| 9 | 
            -
                   | 
| 10 | 
            -
                     | 
| 11 | 
            -
                       | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 8 | 
            +
                supported_by :all do
         | 
| 9 | 
            +
                  describe 'that is dumped and then loaded' do
         | 
| 10 | 
            +
                    before :all do
         | 
| 11 | 
            +
                      @resource = DataMapper::Types::Fixtures::Ticket.new(
         | 
| 12 | 
            +
                        :title  => "Can't order by aggregated fields",
         | 
| 13 | 
            +
                        :id     => 789,
         | 
| 14 | 
            +
                        :body   => "I'm trying to use the aggregate method and sort the results by a summed field, but it doesn't work.",
         | 
| 15 | 
            +
                        :status => 'confirmed'
         | 
| 16 | 
            +
                      )
         | 
| 16 17 |  | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 18 | 
            +
                      @resource.save.should be_true
         | 
| 19 | 
            +
                      @resource.reload
         | 
| 20 | 
            +
                    end
         | 
| 20 21 |  | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 22 | 
            +
                    it 'preserves property value' do
         | 
| 23 | 
            +
                      @resource.status.should == :confirmed
         | 
| 24 | 
            +
                    end
         | 
| 23 25 | 
             
                  end
         | 
| 24 | 
            -
                end
         | 
| 25 26 |  | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 27 | 
            +
                  describe 'that is supplied a matching enumeration value' do
         | 
| 28 | 
            +
                    before :all do
         | 
| 29 | 
            +
                      @resource = DataMapper::Types::Fixtures::Ticket.new(:status => :assigned)
         | 
| 30 | 
            +
                    end
         | 
| 30 31 |  | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 32 | 
            +
                    it 'typecasts it for outside reader' do
         | 
| 33 | 
            +
                      @resource.status.should == :assigned
         | 
| 34 | 
            +
                    end
         | 
| 33 35 | 
             
                  end
         | 
| 34 | 
            -
                end
         | 
| 35 36 |  | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 42 | 
            -
             | 
| 43 | 
            -
             | 
| 44 | 
            -
             | 
| 45 | 
            -
             | 
| 37 | 
            +
                  describe '#get' do
         | 
| 38 | 
            +
                    before :all do
         | 
| 39 | 
            +
                      @resource = DataMapper::Types::Fixtures::Ticket.new(
         | 
| 40 | 
            +
                        :title  => '"sudo make install" of drizzle fails because it tries to chown mysql',
         | 
| 41 | 
            +
                        :id     => 257497,
         | 
| 42 | 
            +
                        :body   => "Note that at the very least, there should be a check to see whether or not the user is created before chown'ing a file to the user.",
         | 
| 43 | 
            +
                        :status => 'confirmed'
         | 
| 44 | 
            +
                      )
         | 
| 45 | 
            +
                      @resource.save.should be_true
         | 
| 46 | 
            +
                    end
         | 
| 46 47 |  | 
| 47 | 
            -
             | 
| 48 | 
            -
             | 
| 49 | 
            -
             | 
| 50 | 
            -
             | 
| 48 | 
            +
                    it 'supports queries with equality operator on enumeration property' do
         | 
| 49 | 
            +
                      DataMapper::Types::Fixtures::Ticket.all(:status => :confirmed).
         | 
| 50 | 
            +
                        should include(@resource)
         | 
| 51 | 
            +
                    end
         | 
| 51 52 |  | 
| 52 | 
            -
             | 
| 53 | 
            -
             | 
| 54 | 
            -
             | 
| 53 | 
            +
                    it 'supports queries with inequality operator on enumeration property' do
         | 
| 54 | 
            +
                      DataMapper::Types::Fixtures::Ticket.all(:status.not => :confirmed).
         | 
| 55 | 
            +
                        should_not include(@resource)
         | 
| 56 | 
            +
                    end
         | 
| 55 57 | 
             
                  end
         | 
| 56 | 
            -
                end
         | 
| 57 58 |  | 
| 58 | 
            -
             | 
| 59 | 
            -
             | 
| 60 | 
            -
             | 
| 61 | 
            -
             | 
| 59 | 
            +
                  describe 'with value unknown to enumeration property' do
         | 
| 60 | 
            +
                    before :all do
         | 
| 61 | 
            +
                      @resource = DataMapper::Types::Fixtures::Ticket.new(:status => :undecided)
         | 
| 62 | 
            +
                    end
         | 
| 62 63 |  | 
| 63 | 
            -
             | 
| 64 | 
            -
             | 
| 65 | 
            -
             | 
| 66 | 
            -
             | 
| 67 | 
            -
             | 
| 64 | 
            +
                    # TODO: consider sharing shared spec exampels with dm-validations,
         | 
| 65 | 
            +
                    #       which has 'invalid model' shared group
         | 
| 66 | 
            +
                    it 'is invalid (auto validation for :within kicks in)' do
         | 
| 67 | 
            +
                      @resource.should_not be_valid
         | 
| 68 | 
            +
                    end
         | 
| 68 69 |  | 
| 69 | 
            -
             | 
| 70 | 
            -
             | 
| 71 | 
            -
             | 
| 70 | 
            +
                    it 'has errors' do
         | 
| 71 | 
            +
                      @resource.errors.should_not be_empty
         | 
| 72 | 
            +
                    end
         | 
| 72 73 |  | 
| 73 | 
            -
             | 
| 74 | 
            -
             | 
| 74 | 
            +
                    it 'has a meaningful error message on invalid property' do
         | 
| 75 | 
            +
                      @resource.errors.on(:status).should include('Status must be one of unconfirmed, confirmed, assigned, resolved, not_applicable')
         | 
| 76 | 
            +
                    end
         | 
| 75 77 | 
             
                  end
         | 
| 76 78 | 
             
                end
         | 
| 77 79 | 
             
              end
         | 
| @@ -5,152 +5,154 @@ try_spec do | |
| 5 5 | 
             
              require './spec/fixtures/software_package'
         | 
| 6 6 |  | 
| 7 7 | 
             
              describe DataMapper::Types::Fixtures::SoftwarePackage do
         | 
| 8 | 
            -
                 | 
| 9 | 
            -
                   | 
| 10 | 
            -
                    @source_path = '/var/cache/apt/archives/linux-libc-dev_2.6.28-11.40_i386.deb'
         | 
| 11 | 
            -
                    @resource    = DataMapper::Types::Fixtures::SoftwarePackage.new(:source_path => @source_path)
         | 
| 12 | 
            -
                  end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
                  describe 'when is a new record' do
         | 
| 8 | 
            +
                supported_by :all do
         | 
| 9 | 
            +
                  describe 'with source path at /var/cache/apt/archives/linux-libc-dev_2.6.28-11.40_i386.deb' do
         | 
| 15 10 | 
             
                    before :all do
         | 
| 11 | 
            +
                      @source_path = '/var/cache/apt/archives/linux-libc-dev_2.6.28-11.40_i386.deb'
         | 
| 12 | 
            +
                      @resource    = DataMapper::Types::Fixtures::SoftwarePackage.new(:source_path => @source_path)
         | 
| 16 13 | 
             
                    end
         | 
| 17 14 |  | 
| 18 | 
            -
                     | 
| 19 | 
            -
                       | 
| 20 | 
            -
             | 
| 15 | 
            +
                    describe 'when is a new record' do
         | 
| 16 | 
            +
                      before :all do
         | 
| 17 | 
            +
                      end
         | 
| 21 18 |  | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 19 | 
            +
                      it 'points to original path' do
         | 
| 20 | 
            +
                        @resource.source_path.to_s.should == @source_path
         | 
| 21 | 
            +
                      end
         | 
| 25 22 |  | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 23 | 
            +
                      it 'responds to :directory?' do
         | 
| 24 | 
            +
                        @resource.source_path.should respond_to(:directory?)
         | 
| 25 | 
            +
                      end
         | 
| 29 26 |  | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 27 | 
            +
                      it 'responds to :file?' do
         | 
| 28 | 
            +
                        @resource.source_path.should respond_to(:file?)
         | 
| 29 | 
            +
                      end
         | 
| 33 30 |  | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 31 | 
            +
                      it 'responds to :dirname' do
         | 
| 32 | 
            +
                        @resource.source_path.should respond_to(:dirname)
         | 
| 33 | 
            +
                      end
         | 
| 37 34 |  | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 35 | 
            +
                      it 'responds to :absolute?' do
         | 
| 36 | 
            +
                        @resource.source_path.should respond_to(:absolute?)
         | 
| 37 | 
            +
                      end
         | 
| 41 38 |  | 
| 42 | 
            -
             | 
| 43 | 
            -
             | 
| 44 | 
            -
             | 
| 45 | 
            -
                  end
         | 
| 46 | 
            -
                end
         | 
| 39 | 
            +
                      it 'responds to :readable?' do
         | 
| 40 | 
            +
                        @resource.source_path.should respond_to(:readable?)
         | 
| 41 | 
            +
                      end
         | 
| 47 42 |  | 
| 48 | 
            -
             | 
| 49 | 
            -
             | 
| 50 | 
            -
             | 
| 51 | 
            -
                     | 
| 43 | 
            +
                      it 'responds to :size' do
         | 
| 44 | 
            +
                        @resource.source_path.should respond_to(:size)
         | 
| 45 | 
            +
                      end
         | 
| 46 | 
            +
                    end
         | 
| 52 47 | 
             
                  end
         | 
| 53 48 |  | 
| 54 | 
            -
                  describe ' | 
| 49 | 
            +
                  describe 'with destination path at /usr/local' do
         | 
| 55 50 | 
             
                    before :all do
         | 
| 56 | 
            -
                      @ | 
| 57 | 
            -
                      @resource. | 
| 51 | 
            +
                      @destination_path = '/usr/local'
         | 
| 52 | 
            +
                      @resource         = DataMapper::Types::Fixtures::SoftwarePackage.new(:destination_path => @destination_path)
         | 
| 58 53 | 
             
                    end
         | 
| 59 54 |  | 
| 60 | 
            -
                     | 
| 61 | 
            -
                       | 
| 62 | 
            -
             | 
| 55 | 
            +
                    describe 'when saved and reloaded' do
         | 
| 56 | 
            +
                      before :all do
         | 
| 57 | 
            +
                        @resource.save.should be_true
         | 
| 58 | 
            +
                        @resource.reload
         | 
| 59 | 
            +
                      end
         | 
| 63 60 |  | 
| 64 | 
            -
             | 
| 65 | 
            -
             | 
| 66 | 
            -
             | 
| 61 | 
            +
                      it 'points to original path' do
         | 
| 62 | 
            +
                        @resource.destination_path.to_s.should == @destination_path
         | 
| 63 | 
            +
                      end
         | 
| 67 64 |  | 
| 68 | 
            -
             | 
| 69 | 
            -
             | 
| 70 | 
            -
             | 
| 65 | 
            +
                      it 'responds to :directory?' do
         | 
| 66 | 
            +
                        @resource.destination_path.should respond_to(:directory?)
         | 
| 67 | 
            +
                      end
         | 
| 71 68 |  | 
| 72 | 
            -
             | 
| 73 | 
            -
             | 
| 74 | 
            -
             | 
| 69 | 
            +
                      it 'responds to :file?' do
         | 
| 70 | 
            +
                        @resource.destination_path.should respond_to(:file?)
         | 
| 71 | 
            +
                      end
         | 
| 75 72 |  | 
| 76 | 
            -
             | 
| 77 | 
            -
             | 
| 78 | 
            -
             | 
| 73 | 
            +
                      it 'responds to :dirname' do
         | 
| 74 | 
            +
                        @resource.destination_path.should respond_to(:dirname)
         | 
| 75 | 
            +
                      end
         | 
| 79 76 |  | 
| 80 | 
            -
             | 
| 81 | 
            -
             | 
| 82 | 
            -
             | 
| 77 | 
            +
                      it 'responds to :absolute?' do
         | 
| 78 | 
            +
                        @resource.destination_path.should respond_to(:absolute?)
         | 
| 79 | 
            +
                      end
         | 
| 83 80 |  | 
| 84 | 
            -
             | 
| 85 | 
            -
             | 
| 86 | 
            -
             | 
| 87 | 
            -
                  end
         | 
| 88 | 
            -
                end
         | 
| 81 | 
            +
                      it 'responds to :readable?' do
         | 
| 82 | 
            +
                        @resource.destination_path.should respond_to(:readable?)
         | 
| 83 | 
            +
                      end
         | 
| 89 84 |  | 
| 90 | 
            -
             | 
| 91 | 
            -
             | 
| 92 | 
            -
             | 
| 93 | 
            -
                     | 
| 85 | 
            +
                      it 'responds to :size' do
         | 
| 86 | 
            +
                        @resource.destination_path.should respond_to(:size)
         | 
| 87 | 
            +
                      end
         | 
| 88 | 
            +
                    end
         | 
| 94 89 | 
             
                  end
         | 
| 95 90 |  | 
| 96 | 
            -
                  describe ' | 
| 91 | 
            +
                  describe 'with no (nil) source path' do
         | 
| 97 92 | 
             
                    before :all do
         | 
| 98 | 
            -
                      @ | 
| 99 | 
            -
                      @resource. | 
| 93 | 
            +
                      @source_path = nil
         | 
| 94 | 
            +
                      @resource    = DataMapper::Types::Fixtures::SoftwarePackage.new(:source_path => @source_path)
         | 
| 100 95 | 
             
                    end
         | 
| 101 96 |  | 
| 102 | 
            -
                     | 
| 103 | 
            -
                       | 
| 104 | 
            -
             | 
| 105 | 
            -
             | 
| 106 | 
            -
             | 
| 97 | 
            +
                    describe 'when saved and reloaded' do
         | 
| 98 | 
            +
                      before :all do
         | 
| 99 | 
            +
                        @resource.save.should be_true
         | 
| 100 | 
            +
                        @resource.reload
         | 
| 101 | 
            +
                      end
         | 
| 107 102 |  | 
| 108 | 
            -
             | 
| 109 | 
            -
             | 
| 110 | 
            -
             | 
| 111 | 
            -
                     | 
| 103 | 
            +
                      it 'has nil source path' do
         | 
| 104 | 
            +
                        @resource.source_path.should be_nil
         | 
| 105 | 
            +
                      end
         | 
| 106 | 
            +
                    end
         | 
| 112 107 | 
             
                  end
         | 
| 113 108 |  | 
| 114 | 
            -
                  describe ' | 
| 109 | 
            +
                  describe 'with a blank source path' do
         | 
| 115 110 | 
             
                    before :all do
         | 
| 116 | 
            -
                      @ | 
| 117 | 
            -
                      @resource. | 
| 111 | 
            +
                      @source_path = ''
         | 
| 112 | 
            +
                      @resource    = DataMapper::Types::Fixtures::SoftwarePackage.new(:source_path => @source_path)
         | 
| 118 113 | 
             
                    end
         | 
| 119 114 |  | 
| 120 | 
            -
                     | 
| 121 | 
            -
                       | 
| 122 | 
            -
             | 
| 123 | 
            -
             | 
| 124 | 
            -
             | 
| 115 | 
            +
                    describe 'when saved and reloaded' do
         | 
| 116 | 
            +
                      before :all do
         | 
| 117 | 
            +
                        @resource.save.should be_true
         | 
| 118 | 
            +
                        @resource.reload
         | 
| 119 | 
            +
                      end
         | 
| 125 120 |  | 
| 126 | 
            -
             | 
| 127 | 
            -
             | 
| 128 | 
            -
             | 
| 129 | 
            -
                     | 
| 121 | 
            +
                      it 'has nil source path' do
         | 
| 122 | 
            +
                        @resource.source_path.should be_nil
         | 
| 123 | 
            +
                      end
         | 
| 124 | 
            +
                    end
         | 
| 130 125 | 
             
                  end
         | 
| 131 126 |  | 
| 132 | 
            -
                  describe ' | 
| 127 | 
            +
                  describe 'with a source path assigned to an empty array' do
         | 
| 133 128 | 
             
                    before :all do
         | 
| 134 | 
            -
                      @ | 
| 135 | 
            -
                      @resource. | 
| 129 | 
            +
                      @source_path = []
         | 
| 130 | 
            +
                      @resource    = DataMapper::Types::Fixtures::SoftwarePackage.new(:source_path => @source_path)
         | 
| 136 131 | 
             
                    end
         | 
| 137 132 |  | 
| 138 | 
            -
                     | 
| 139 | 
            -
                       | 
| 133 | 
            +
                    describe 'when saved and reloaded' do
         | 
| 134 | 
            +
                      before :all do
         | 
| 135 | 
            +
                        @resource.save.should be_true
         | 
| 136 | 
            +
                        @resource.reload
         | 
| 137 | 
            +
                      end
         | 
| 138 | 
            +
             | 
| 139 | 
            +
                      it 'has nil source path' do
         | 
| 140 | 
            +
                        @resource.source_path.should be_nil
         | 
| 141 | 
            +
                      end
         | 
| 140 142 | 
             
                    end
         | 
| 141 143 | 
             
                  end
         | 
| 142 | 
            -
                end
         | 
| 143 144 |  | 
| 144 | 
            -
             | 
| 145 | 
            -
             | 
| 146 | 
            -
             | 
| 147 | 
            -
             | 
| 145 | 
            +
                  describe 'with a source path assigned to a Hash' do
         | 
| 146 | 
            +
                    before :all do
         | 
| 147 | 
            +
                      @source_path = { :guitar => 'Joe Satriani' }
         | 
| 148 | 
            +
                    end
         | 
| 148 149 |  | 
| 149 | 
            -
             | 
| 150 | 
            -
             | 
| 151 | 
            -
             | 
| 152 | 
            -
             | 
| 153 | 
            -
             | 
| 150 | 
            +
                    describe 'when instantiated' do
         | 
| 151 | 
            +
                      it 'raises an exception' do
         | 
| 152 | 
            +
                        lambda do
         | 
| 153 | 
            +
                          DataMapper::Types::Fixtures::SoftwarePackage.new(:source_path => @source_path)
         | 
| 154 | 
            +
                        end.should raise_error(TypeError)
         | 
| 155 | 
            +
                      end
         | 
| 154 156 | 
             
                    end
         | 
| 155 157 | 
             
                  end
         | 
| 156 158 | 
             
                end
         | 
| @@ -5,59 +5,61 @@ try_spec do | |
| 5 5 | 
             
              require './spec/fixtures/tshirt'
         | 
| 6 6 |  | 
| 7 7 | 
             
              describe DataMapper::Types::Fixtures::TShirt do
         | 
| 8 | 
            -
                 | 
| 9 | 
            -
                   | 
| 10 | 
            -
                     | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 8 | 
            +
                supported_by :all do
         | 
| 9 | 
            +
                  before do
         | 
| 10 | 
            +
                    @resource = DataMapper::Types::Fixtures::TShirt.new(
         | 
| 11 | 
            +
                      :writing     => 'Fork you',
         | 
| 12 | 
            +
                      :has_picture => true,
         | 
| 13 | 
            +
                      :picture     => :octocat,
         | 
| 14 | 
            +
                      :color       => :white,
         | 
| 15 | 
            +
                      :size        => [ :xs, :medium ]
         | 
| 16 | 
            +
                    )
         | 
| 17 | 
            +
                  end
         | 
| 17 18 |  | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 19 | 
            +
                  describe 'with multiple sizes' do
         | 
| 20 | 
            +
                    describe 'dumped and loaded' do
         | 
| 21 | 
            +
                      before do
         | 
| 22 | 
            +
                        @resource.save.should be_true
         | 
| 23 | 
            +
                        @resource.reload
         | 
| 24 | 
            +
                      end
         | 
| 24 25 |  | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 26 | 
            +
                      it 'returns size as array' do
         | 
| 27 | 
            +
                        @resource.size.should == [ :xs, :medium ]
         | 
| 28 | 
            +
                      end
         | 
| 27 29 | 
             
                    end
         | 
| 28 30 | 
             
                  end
         | 
| 29 | 
            -
                end
         | 
| 30 | 
            -
             | 
| 31 | 
            -
                describe 'with a single size' do
         | 
| 32 | 
            -
                  before do
         | 
| 33 | 
            -
                    @resource.size = :large
         | 
| 34 | 
            -
                  end
         | 
| 35 31 |  | 
| 36 | 
            -
                  describe ' | 
| 32 | 
            +
                  describe 'with a single size' do
         | 
| 37 33 | 
             
                    before do
         | 
| 38 | 
            -
                      @resource. | 
| 39 | 
            -
                      @resource.reload
         | 
| 34 | 
            +
                      @resource.size = :large
         | 
| 40 35 | 
             
                    end
         | 
| 41 36 |  | 
| 42 | 
            -
                     | 
| 43 | 
            -
                       | 
| 37 | 
            +
                    describe 'dumped and loaded' do
         | 
| 38 | 
            +
                      before do
         | 
| 39 | 
            +
                        @resource.save.should be_true
         | 
| 40 | 
            +
                        @resource.reload
         | 
| 41 | 
            +
                      end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                      it 'returns size as array with a single value' do
         | 
| 44 | 
            +
                        @resource.size.should == [:large]
         | 
| 45 | 
            +
                      end
         | 
| 44 46 | 
             
                    end
         | 
| 45 47 | 
             
                  end
         | 
| 46 | 
            -
                end
         | 
| 47 48 |  | 
| 48 | 
            -
             | 
| 49 | 
            -
             | 
| 50 | 
            -
             | 
| 51 | 
            -
             | 
| 52 | 
            -
             | 
| 53 | 
            -
             | 
| 49 | 
            +
                  # Flag does not add any auto validations
         | 
| 50 | 
            +
                  describe 'without size' do
         | 
| 51 | 
            +
                    before do
         | 
| 52 | 
            +
                      @resource.should be_valid
         | 
| 53 | 
            +
                      @resource.size = nil
         | 
| 54 | 
            +
                    end
         | 
| 54 55 |  | 
| 55 | 
            -
             | 
| 56 | 
            -
             | 
| 57 | 
            -
             | 
| 56 | 
            +
                    it 'is valid' do
         | 
| 57 | 
            +
                      @resource.should be_valid
         | 
| 58 | 
            +
                    end
         | 
| 58 59 |  | 
| 59 | 
            -
             | 
| 60 | 
            -
             | 
| 60 | 
            +
                    it 'has no errors' do
         | 
| 61 | 
            +
                      @resource.errors.should be_blank
         | 
| 62 | 
            +
                    end
         | 
| 61 63 | 
             
                  end
         | 
| 62 64 | 
             
                end
         | 
| 63 65 | 
             
              end
         |