/
legacy_fixture_mode_fixture_generation_test.rb
39 lines (31 loc) · 1.37 KB
/
legacy_fixture_mode_fixture_generation_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
create_and_blow_away_old_db
force_fixture_generation
FixtureBuilder.configure :legacy_fixtures => [test_path("legacy_fixtures/*.yml"), test_path("other_legacy_fixture_set/*.yml")] do |fbuilder|
fbuilder.factory do
MagicalCreature.create(:name => "frank", :species => "unicorn")
end
end
class LegacyFixtureModeFixtureGenerationTest < Test::Unit::TestCase
@@magical_creatures = YAML.load(File.open(test_path("fixtures/magical_creatures.yml")))
def test_legacy_fixtures_created
alice = MagicalCreature.find_by_name("alice")
assert_equal "alice", alice.name
assert_equal "mermaid", alice.species
end
def test_invalid_legacy_fixtures_created
bigfoot = MagicalCreature.find(5)
assert_equal "bigfoot", bigfoot.name
assert_equal 5, @@magical_creatures['bigfoot']['id']
assert_equal "bigfoot", @@magical_creatures['bigfoot']['name']
assert_nil @@magical_creatures['bigfoot']['species']
end
def test_new_fixtures_are_created
assert_equal "frank", @@magical_creatures['frank']['name']
assert_equal "unicorn", @@magical_creatures['frank']['species']
end
def test_legacy_fixtures_retain_fixture_name
assert_equal "alice", @@magical_creatures['alice_the_mermaid']['name']
assert_equal "mermaid", @@magical_creatures['alice_the_mermaid']['species']
end
end