This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
Botanicus (author)
Sun Aug 24 01:06:35 -0700 2008
commit 2bccd4ea710d6c19fbd5a93d722338b33adffe45
tree 4a673a395eb50b02882222615d3dca47dee9faf4
parent 9b125fa723a188385feb11d7c533657dbe3810d3
tree 4a673a395eb50b02882222615d3dca47dee9faf4
parent 9b125fa723a188385feb11d7c533657dbe3810d3
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Sat Jun 21 08:25:37 -0700 2008 | |
| |
LICENSE | Sat Jun 21 04:54:00 -0700 2008 | |
| |
README | ||
| |
Rakefile | ||
| |
TODO | ||
| |
lib/ | ||
| |
spec/ |
README
=== About ===
Fixtures is Merb plugin which provides fixture system for Merb.
1) Fixtures are written in Ruby, not in YAML, so it's more powerful than YAML one. For example it's much easier to add
HABTM relationships.
2) Fixtures aren't just for testing, but they are useful for development and even for migrations
=== Setup ===
git clone git://github.com/botanicus/merb-fixtures.git
cd merb-fixtures
rake install
# config/init.rb
dependency 'merb-fixtures'
By default, fixtures folder is app/fixtures. If you like to puts your fixtures on other place, feel free to change it in
your init.rb:
# config/init.rb
Merb::Plugins.config[:fixtures] = {
:directory => Merb.root / "app" / "fixtures"
}
=== Writing fixtures ===
First you must write a fixture:
# app/fixtures/author.rb
fixture_for(Author, :botanicus) do
self.first_name = "Jakub"
self.last_name = "Šťastný"
self.nickname = "Botanicus"
self.homepage = "http://botablog.cz"
self.posts = [ ... ]
end
=== Usage from merb console or specs ===
Now you can use it - from your specs or just from merb console:
# Get fixture named :botanicus
Author.fixture(:botanicus)
=> #<Author last_name="Šťastný" homepage="http://botablog.cz" first_name="Jakub" nickname="Botanicus">
# Get all the author's fixtures
Author.fixtures
=> [#<Author last_name="Šťastný" homepage="http://botablog.cz" first_name="Jakub" nickname="Botanicus">]
=== Usage in migrations ===
# Usage in migrations
migration 1, "Add default author" do
up do
Author.fixture(:botanicus).save
end
down do
# foo
end
end
=== FAQ ===
== HABTM ==
# TODO: describe different types of associations
class ModelOne
has 0..n, :model_two
end
class ModelTwo
belongs_to :model_one
# model_one_id
end
fixture_for(ModelOne, :one) do
# foo bar
end
require_fixtures :model_one
fixture_for(ModelTwo, :two) do
self.model_one = ModelOne.fixture(:model_one)
end
1) save ModelOne







