blueprints 0.5.0 → 0.5.1
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/VERSION +1 -1
- data/blueprints.gemspec +2 -2
- data/lib/blueprints/database_backends/none.rb +1 -1
- data/script/rspec_to_test +3 -0
- data/test/blueprints_test.rb +73 -3
- data/test/test_helper.rb +6 -1
- metadata +2 -2
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0.5. | 
| 1 | 
            +
            0.5.1
         | 
    
        data/blueprints.gemspec
    CHANGED
    
    | @@ -5,11 +5,11 @@ | |
| 5 5 |  | 
| 6 6 | 
             
            Gem::Specification.new do |s|
         | 
| 7 7 | 
             
              s.name = %q{blueprints}
         | 
| 8 | 
            -
              s.version = "0.5. | 
| 8 | 
            +
              s.version = "0.5.1"
         | 
| 9 9 |  | 
| 10 10 | 
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 11 11 | 
             
              s.authors = ["Andrius Chamentauskas"]
         | 
| 12 | 
            -
              s.date = %q{2010-02- | 
| 12 | 
            +
              s.date = %q{2010-02-24}
         | 
| 13 13 | 
             
              s.description = %q{Another replacement for factories and fixtures. The library that lazy typists will love}
         | 
| 14 14 | 
             
              s.email = %q{sinsiliux@gmail.com}
         | 
| 15 15 | 
             
              s.extra_rdoc_files = [
         | 
    
        data/script/rspec_to_test
    CHANGED
    
    | @@ -9,6 +9,9 @@ data.gsub!("describe Blueprints do", 'class BlueprintsTest < ActiveSupport::Test | |
| 9 9 | 
             
            #   hornsby_clear :undo => :just_orange
         | 
| 10 10 | 
             
            # }.should raise_error(ArgumentError)
         | 
| 11 11 | 
             
            data.gsub!(/(\s+)lambda \{\n(.*)\n(\s+)\}.should raise_error\((.*)\)/, "\\1assert_raise(\\4) do\n\\2\n\\3end")
         | 
| 12 | 
            +
            # should =~ => assert_similar
         | 
| 13 | 
            +
            data.gsub!(/^(\s+)(.*)\.should\s*=~\s*(.*)/, '\1assert_similar(\2, \3)')
         | 
| 14 | 
            +
             | 
| 12 15 | 
             
            # .should_not => assert(!())
         | 
| 13 16 | 
             
            data.gsub!(/^(\s+)(.*)\.should_not(.*)/, '\1assert(!(\2\3))')
         | 
| 14 17 | 
             
            # .should => assert()
         | 
    
        data/test/blueprints_test.rb
    CHANGED
    
    | @@ -7,7 +7,7 @@ class BlueprintsTest < ActiveSupport::TestCase | |
| 7 7 | 
             
                end
         | 
| 8 8 |  | 
| 9 9 | 
             
                should "support required ORMS" do
         | 
| 10 | 
            -
                   | 
| 10 | 
            +
                  assert_similar(Blueprints.supported_orms, [:active_record, :none])
         | 
| 11 11 | 
             
                end
         | 
| 12 12 | 
             
              end
         | 
| 13 13 |  | 
| @@ -219,7 +219,7 @@ class BlueprintsTest < ActiveSupport::TestCase | |
| 219 219 |  | 
| 220 220 | 
             
                should "raise ArgumentError when unknown ORM specified" do
         | 
| 221 221 | 
             
                  Blueprints::Namespace.root.expects(:empty?).returns(true)
         | 
| 222 | 
            -
                  assert_raise(ArgumentError, "Unsupported ORM unknown. Blueprints supports only  | 
| 222 | 
            +
                  assert_raise(ArgumentError, "Unsupported ORM unknown. Blueprints supports only #{Blueprints.supported_orms.join(', ')}") do
         | 
| 223 223 | 
             
                    Blueprints.load(:orm => :unknown)
         | 
| 224 224 | 
             
                  end
         | 
| 225 225 | 
             
                end
         | 
| @@ -246,6 +246,18 @@ class BlueprintsTest < ActiveSupport::TestCase | |
| 246 246 | 
             
                  assert(!(@acorn.nil?))
         | 
| 247 247 | 
             
                  assert(@acorn.tree == @oak)
         | 
| 248 248 | 
             
                end
         | 
| 249 | 
            +
             | 
| 250 | 
            +
                should "allow updating object using blueprint method" do
         | 
| 251 | 
            +
                  build :oak
         | 
| 252 | 
            +
                  @oak.blueprint(:size => 'updated')
         | 
| 253 | 
            +
                  assert(@oak.reload.size == 'updated')
         | 
| 254 | 
            +
                end
         | 
| 255 | 
            +
             | 
| 256 | 
            +
                should "automatically merge passed options" do
         | 
| 257 | 
            +
                  build :oak => {:size => 'optional'}
         | 
| 258 | 
            +
                  assert(@oak.name == 'Oak')
         | 
| 259 | 
            +
                  assert(@oak.size == 'optional')
         | 
| 260 | 
            +
                end
         | 
| 249 261 | 
             
              end
         | 
| 250 262 |  | 
| 251 263 | 
             
              context "with pitted namespace" do
         | 
| @@ -272,7 +284,7 @@ class BlueprintsTest < ActiveSupport::TestCase | |
| 272 284 | 
             
                  assert(!(@pitted_peach.nil?))
         | 
| 273 285 | 
             
                  assert(!(@pitted_acorn.nil?))
         | 
| 274 286 | 
             
                  assert(!(@pitted_red_apple.nil?))
         | 
| 275 | 
            -
                   | 
| 287 | 
            +
                  assert_similar(@pitted, [@pitted_peach_tree, @pitted_peach, @pitted_acorn, [@pitted_red_apple]])
         | 
| 276 288 | 
             
                end
         | 
| 277 289 |  | 
| 278 290 | 
             
                context "with red namespace" do
         | 
| @@ -294,5 +306,63 @@ class BlueprintsTest < ActiveSupport::TestCase | |
| 294 306 | 
             
                  end
         | 
| 295 307 | 
             
                end
         | 
| 296 308 | 
             
              end
         | 
| 309 | 
            +
             | 
| 310 | 
            +
              context 'extra parameters' do
         | 
| 311 | 
            +
                should "allow passing extra parameters when building" do
         | 
| 312 | 
            +
                  build :apple_with_params => {:average_diameter => 14}
         | 
| 313 | 
            +
                  assert(@apple_with_params.average_diameter == 14)
         | 
| 314 | 
            +
                  assert(@apple_with_params.species == 'apple')
         | 
| 315 | 
            +
                end
         | 
| 316 | 
            +
             | 
| 317 | 
            +
                should "allow set options to empty hash if no parameters are passed" do
         | 
| 318 | 
            +
                  build :apple_with_params
         | 
| 319 | 
            +
                  assert(@apple_with_params.average_diameter == nil)
         | 
| 320 | 
            +
                  assert(@apple_with_params.species == 'apple')
         | 
| 321 | 
            +
                end
         | 
| 322 | 
            +
             | 
| 323 | 
            +
                should "use extra params only on blueprints specified" do
         | 
| 324 | 
            +
                  build :acorn => {:average_diameter => 5}
         | 
| 325 | 
            +
                  assert(@acorn.average_diameter == 5)
         | 
| 326 | 
            +
                end
         | 
| 327 | 
            +
             | 
| 328 | 
            +
                should "allow passing extra params for each blueprint individually" do
         | 
| 329 | 
            +
                  build :acorn => {:average_diameter => 3}, :apple_with_params => {:average_diameter => 2}
         | 
| 330 | 
            +
                  assert(@acorn.average_diameter == 3)
         | 
| 331 | 
            +
                  assert(@apple_with_params.average_diameter == 2)
         | 
| 332 | 
            +
                end
         | 
| 333 | 
            +
             | 
| 334 | 
            +
                should "allow passing options for some blueprints only" do
         | 
| 335 | 
            +
                  assert(build(:acorn, :apple_with_params => {:average_diameter => 2}) == @apple_with_params)
         | 
| 336 | 
            +
                  assert(@acorn.average_diameter == nil)
         | 
| 337 | 
            +
                  assert(@apple_with_params.average_diameter == 2)
         | 
| 338 | 
            +
                end
         | 
| 339 | 
            +
              end
         | 
| 340 | 
            +
             | 
| 341 | 
            +
              should "overwrite auto created instance variable with another auto created one" do
         | 
| 342 | 
            +
                build :acorn => {:average_diameter => 3}
         | 
| 343 | 
            +
                demolish :fruits, :undo => :acorn
         | 
| 344 | 
            +
                assert(@acorn.average_diameter == 3)
         | 
| 345 | 
            +
             | 
| 346 | 
            +
                build :acorn => {:average_diameter => 5}
         | 
| 347 | 
            +
                assert(@acorn.average_diameter == 5)
         | 
| 348 | 
            +
              end
         | 
| 349 | 
            +
             | 
| 350 | 
            +
              context "extending blueprints" do
         | 
| 351 | 
            +
                should "allow to call build method inside blueprint body" do
         | 
| 352 | 
            +
                  build :small_acorn
         | 
| 353 | 
            +
                  assert(@small_acorn.average_diameter == 1)
         | 
| 354 | 
            +
                  assert(@small_acorn == @acorn)
         | 
| 355 | 
            +
                end
         | 
| 356 | 
            +
             | 
| 357 | 
            +
                should "allow to use shortcut to extend blueprint" do
         | 
| 358 | 
            +
                  build :huge_acorn
         | 
| 359 | 
            +
                  assert(@huge_acorn.average_diameter == 100)
         | 
| 360 | 
            +
                end
         | 
| 361 | 
            +
             | 
| 362 | 
            +
                should "allow extended blueprint be dependency and associated object" do
         | 
| 363 | 
            +
                  build :huge_acorn
         | 
| 364 | 
            +
                  assert(@huge_acorn.tree.size == 'huge')
         | 
| 365 | 
            +
                end
         | 
| 366 | 
            +
              end
         | 
| 297 367 | 
             
            end
         | 
| 298 368 |  | 
    
        data/test/test_helper.rb
    CHANGED
    
    | @@ -1,5 +1,5 @@ | |
| 1 1 | 
             
            require 'rubygems'
         | 
| 2 | 
            -
            require ' | 
| 2 | 
            +
            require 'active_record'
         | 
| 3 3 | 
             
            require 'test/unit'
         | 
| 4 4 | 
             
            require 'active_record/test_case'
         | 
| 5 5 | 
             
            require 'shoulda'
         | 
| @@ -23,4 +23,9 @@ require 'spec/active_record/fixtures/tree' | |
| 23 23 |  | 
| 24 24 | 
             
            class ActiveSupport::TestCase
         | 
| 25 25 | 
             
              enable_blueprints :root => File.join(File.dirname(__FILE__), '..'), :prebuild => :big_cherry, :filename => 'spec/active_record/blueprint.rb'
         | 
| 26 | 
            +
             | 
| 27 | 
            +
              def assert_similar(array1, array2)
         | 
| 28 | 
            +
                assert (array1 - array2).empty?, "Extra elements #{array1 - array2}"
         | 
| 29 | 
            +
                assert (array2 - array1).empty?, "Missing elements #{array2 - array1}"
         | 
| 30 | 
            +
              end
         | 
| 26 31 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: blueprints
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              version: 0.5. | 
| 4 | 
            +
              version: 0.5.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors: 
         | 
| 7 7 | 
             
            - Andrius Chamentauskas
         | 
| @@ -9,7 +9,7 @@ autorequire: | |
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 11 |  | 
| 12 | 
            -
            date: 2010-02- | 
| 12 | 
            +
            date: 2010-02-24 00:00:00 +02:00
         | 
| 13 13 | 
             
            default_executable: 
         | 
| 14 14 | 
             
            dependencies: []
         | 
| 15 15 |  |