• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Machinist
 

Machinist

on

  • 2,216 views

 

Statistics

Views

Total Views
2,216
Views on SlideShare
2,206
Embed Views
10

Actions

Likes
0
Downloads
13
Comments
0

3 Embeds 10

http://www.slideshare.net 8
http://webcache.googleusercontent.com 1
http://coderwall.com 1

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Machinist Machinist Presentation Transcript

  • Faking it with Machinist Create realistic, repeatable, datasets for testing and development Adam Dill www.isotope11.com
  • Why? • Make tests shorter, simpler • Dependable development data • Easy to make changes • rake db:reset calls db/seeds.rb • works great in console for playing with requests: u = user.make
  • Setup The Resets make them start over after each rollback
  • Machinist http://github.com/notahat/machinist “create test data within your tests. It generates data for the fields you don't care about, and constructs any necessary associated objects” Like (and inspired by) Factory Girl, but with a cleaner DSL Extends active_record with make, make_unsaved
  • make & make_unsaved Both generate the object, but make_unsaved doesn’t call valid? or save or create, ect.
  • blueprint.rb Shams Sham: random but repeatable unique attributes values
  • a blueprint Call shams to generate data or you can specify fields you always to be the same Or create named blueprints, they inherent from their master blueprint
  • Creating # make a generic User instance User.make User.make_unsaved Post.make(:city => "Atlanta") # make a named instance User.make(:inactive_bob) User.make_unsaved(:inactive_bob) # or override a field User.make(:city => "Atlanta")
  • AR Inheritance Simple, or you can use over rides like before. I like writing test helpers
  • Faker http://faker.rubyforge.org/ A port of Perl‘s Data::Faker library that generates fake data. How much Fake could a faker fake if a faker could ... forget it
  • How much Fake? Notice the uniques on the shams, this is a gotcha after you generate all possible (or run out of Faker data) then it will error out. if this is a problem, add an index (see the email field)
  • Faker Example
  • seeds.rb Remember Account generated users also. so we have 100 users with accounts in our development.rb that aside from random generators are the _exact_ same every time. Its also fast
  • Adam Dill Senior Developer www.isotope11.com adam@isotope11.com