Sha256: 6126d388741e0481a516a309e7794e5d6315f508d89411e733f0e15afcb3dfd6

Contents?: true

Size: 1.43 KB

Versions: 7

Compression:

Stored size: 1.43 KB

Contents

= test_dummy

Test Dummy is an easy fake data generator library with the ability to create
fake models or entirely faked data structures on-demand.

After installing the gem, methods to declare how to fake data are made
available within ActiveRecord-derived models. There are several ways to
declare how to dummy something:

    class MyModel < ActiveRecord::Base
      # Pass a block that defines how to dummy this attribute
      dummy :name do
        "user%d" % rand(10e6)
      end
      
      # Pass a block that defines how to dummy several attributes
      dummy :password, :password_confirmation do
        'tester'
      end
      
      # Use one of the pre-defined helper methods to dummy this attribute
      dummy :nickname, :use => :random_phonetic_string
    end

Dummy configuration can also be stored in test/dummy to avoid cluttering
your models up with generators. An equivalent external declaration would look
like this:

    TestDummy.declare(MyModel) do
      dummy :name do
        "user%d" % rand(10e6)
      end
    
      dummy :password, :password_confirmation do
        'tester'
      end
    
      dummy :nickname, :use => :random_phonetic_string
    end

The name of the test/dummy file should be the same as the main model
defined in app/models. For instance, app/models/my_model.rb would have a
corresponding test/dummy/my_model.rb that would be loaded as required.

== Copyright

Copyright (c) 2010 Scott Tadman, The Working Group

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
test_dummy-0.2.8 README.rdoc
test_dummy-0.2.7 README.rdoc
test_dummy-0.2.6 README.rdoc
test_dummy-0.2.5 README.rdoc
test_dummy-0.2.4 README.rdoc
test_dummy-0.2.3 README.rdoc
test_dummy-0.2.2 README.rdoc