fixture_replacement 3.0.1 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.rdoc +5 -0
  3. data/README.rdoc +2 -14
  4. data/VERSION +1 -1
  5. data/lib/fixture_replacement/attribute_builder.rb +5 -3
  6. data/lib/fixture_replacement/class_methods.rb +10 -2
  7. data/lib/fixture_replacement/version.rb +2 -2
  8. data/lib/fixture_replacement.rb +0 -1
  9. metadata +26 -109
  10. data/.gitignore +0 -2
  11. data/Rakefile +0 -8
  12. data/etc/bug_reports/2007_09_28_linoj.txt +0 -51
  13. data/etc/google_analytics +0 -6
  14. data/etc/patches/2007_09_14_default_model_name_with_arguments.diff +0 -26
  15. data/etc/patches/2007_10_14_active_record_specs.diff +0 -396
  16. data/etc/patches/2007_10_14_protected_attributes.diff +0 -26
  17. data/etc/patches/2007_10_14_send_patch.diff +0 -79
  18. data/etc/patches/2007_10_14_spelling_error_in_comments.diff +0 -13
  19. data/etc/patches/2007_10_17_protected_attributes_second_go.diff +0 -212
  20. data/etc/patches/2007_10_18_README.diff +0 -137
  21. data/etc/patches/2007_10_19_readme_tweak.diff +0 -12
  22. data/etc/patches/2007_10_19_silence_migration.diff +0 -12
  23. data/etc/patches/2007_10_25_changed_classify_to_camelize.diff +0 -38
  24. data/etc/patches/2007_11_20_fixture_replacement_generator_should_not_reload_environment_or_boot.patch +0 -13
  25. data/etc/patches/2007_11_20_string_random_refactor_and_extension.patch +0 -104
  26. data/etc/patches/2007_11_20_string_random_refactor_and_extension_v2.patch +0 -108
  27. data/fixture_replacement.gemspec +0 -126
  28. data/rake_tasks/code_quality.rb +0 -37
  29. data/rake_tasks/docs.rb +0 -59
  30. data/rake_tasks/gem.rb +0 -27
  31. data/rake_tasks/specs.rb +0 -7
  32. data/rake_tasks/tests.rb +0 -7
  33. data/rake_tasks/website.rb +0 -11
  34. data/spec/fixture_replacement/attribute_builder_spec.rb +0 -162
  35. data/spec/fixture_replacement/fixture_replacement_spec.rb +0 -96
  36. data/spec/fixture_replacement/fixtures/classes.rb +0 -78
  37. data/spec/fixture_replacement/fr_spec.rb +0 -7
  38. data/spec/fixture_replacement/integration/attr_protected_attributes_spec.rb +0 -71
  39. data/spec/fixture_replacement/integration/attributes_for_with_invalid_keys_spec.rb +0 -14
  40. data/spec/fixture_replacement/integration/attributes_from_spec_without_block.rb +0 -52
  41. data/spec/fixture_replacement/integration/create_method_spec.rb +0 -61
  42. data/spec/fixture_replacement/integration/cyclic_dependency_spec.rb +0 -32
  43. data/spec/fixture_replacement/integration/default_warnings_spec.rb +0 -29
  44. data/spec/fixture_replacement/integration/extend_spec.rb +0 -37
  45. data/spec/fixture_replacement/integration/has_and_belongs_to_many_spec.rb +0 -64
  46. data/spec/fixture_replacement/integration/new_method_spec.rb +0 -96
  47. data/spec/fixture_replacement/integration/private_methods_spec.rb +0 -43
  48. data/spec/fixture_replacement/integration/public_methods_spec.rb +0 -21
  49. data/spec/fixture_replacement/integration/valid_attributes_spec.rb +0 -41
  50. data/spec/fixture_replacement/integration/validation_spec.rb +0 -54
  51. data/spec/fixture_replacement/regressions/2008_01_21_random_string_with_sti_spec.rb +0 -71
  52. data/spec/fixture_replacement/version_spec.rb +0 -7
  53. data/spec/spec.opts +0 -1
  54. data/spec/spec_helper.rb +0 -16
  55. data/spec/spec_helpers.rb +0 -117
  56. data/test/test_helper.rb +0 -21
  57. data/test/unit/user_test.rb +0 -57
@@ -1,126 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{fixture_replacement}
8
- s.version = "3.0.1"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Scott Taylor"]
12
- s.date = %q{2009-11-21}
13
- s.description = %q{FixtureReplacement is a Rails plugin that provides a simple way to
14
- quickly populate your test database with model objects without having to manage multiple,
15
- brittle fixture files. You can easily set up complex object graphs (with models which
16
- reference other models) and add new objects on the fly.
17
- }
18
- s.email = %q{scott@railsnewbie.com}
19
- s.extra_rdoc_files = [
20
- "README.rdoc"
21
- ]
22
- s.files = [
23
- ".gitignore",
24
- "CHANGELOG.rdoc",
25
- "GPL_LICENSE",
26
- "MIT_LICENSE",
27
- "README.rdoc",
28
- "Rakefile",
29
- "TODO.rdoc",
30
- "VERSION",
31
- "contributions.rdoc",
32
- "etc/bug_reports/2007_09_28_linoj.txt",
33
- "etc/google_analytics",
34
- "etc/patches/2007_09_14_default_model_name_with_arguments.diff",
35
- "etc/patches/2007_10_14_active_record_specs.diff",
36
- "etc/patches/2007_10_14_protected_attributes.diff",
37
- "etc/patches/2007_10_14_send_patch.diff",
38
- "etc/patches/2007_10_14_spelling_error_in_comments.diff",
39
- "etc/patches/2007_10_17_protected_attributes_second_go.diff",
40
- "etc/patches/2007_10_18_README.diff",
41
- "etc/patches/2007_10_19_readme_tweak.diff",
42
- "etc/patches/2007_10_19_silence_migration.diff",
43
- "etc/patches/2007_10_25_changed_classify_to_camelize.diff",
44
- "etc/patches/2007_11_20_fixture_replacement_generator_should_not_reload_environment_or_boot.patch",
45
- "etc/patches/2007_11_20_string_random_refactor_and_extension.patch",
46
- "etc/patches/2007_11_20_string_random_refactor_and_extension_v2.patch",
47
- "fixture_replacement.gemspec",
48
- "lib/fixture_replacement.rb",
49
- "lib/fixture_replacement/attribute_builder.rb",
50
- "lib/fixture_replacement/class_methods.rb",
51
- "lib/fixture_replacement/method_generator.rb",
52
- "lib/fixture_replacement/version.rb",
53
- "lib/fr.rb",
54
- "philosophy_and_bugs.rdoc",
55
- "rake_tasks/code_quality.rb",
56
- "rake_tasks/docs.rb",
57
- "rake_tasks/gem.rb",
58
- "rake_tasks/specs.rb",
59
- "rake_tasks/tests.rb",
60
- "rake_tasks/website.rb",
61
- "spec/fixture_replacement/attribute_builder_spec.rb",
62
- "spec/fixture_replacement/fixture_replacement_spec.rb",
63
- "spec/fixture_replacement/fixtures/classes.rb",
64
- "spec/fixture_replacement/fr_spec.rb",
65
- "spec/fixture_replacement/integration/attr_protected_attributes_spec.rb",
66
- "spec/fixture_replacement/integration/attributes_for_with_invalid_keys_spec.rb",
67
- "spec/fixture_replacement/integration/attributes_from_spec_without_block.rb",
68
- "spec/fixture_replacement/integration/create_method_spec.rb",
69
- "spec/fixture_replacement/integration/cyclic_dependency_spec.rb",
70
- "spec/fixture_replacement/integration/default_warnings_spec.rb",
71
- "spec/fixture_replacement/integration/extend_spec.rb",
72
- "spec/fixture_replacement/integration/has_and_belongs_to_many_spec.rb",
73
- "spec/fixture_replacement/integration/new_method_spec.rb",
74
- "spec/fixture_replacement/integration/private_methods_spec.rb",
75
- "spec/fixture_replacement/integration/public_methods_spec.rb",
76
- "spec/fixture_replacement/integration/valid_attributes_spec.rb",
77
- "spec/fixture_replacement/integration/validation_spec.rb",
78
- "spec/fixture_replacement/regressions/2008_01_21_random_string_with_sti_spec.rb",
79
- "spec/fixture_replacement/version_spec.rb",
80
- "spec/spec.opts",
81
- "spec/spec_helper.rb",
82
- "spec/spec_helpers.rb",
83
- "test/test_helper.rb",
84
- "test/unit/user_test.rb"
85
- ]
86
- s.homepage = %q{http://replacefixtures.rubyforge.org}
87
- s.rdoc_options = ["--charset=UTF-8"]
88
- s.require_paths = ["lib"]
89
- s.rubygems_version = %q{1.3.5}
90
- s.summary = %q{The original fixture replacement solution for rails}
91
- s.test_files = [
92
- "spec/fixture_replacement/attribute_builder_spec.rb",
93
- "spec/fixture_replacement/fixture_replacement_spec.rb",
94
- "spec/fixture_replacement/fixtures/classes.rb",
95
- "spec/fixture_replacement/fr_spec.rb",
96
- "spec/fixture_replacement/integration/attr_protected_attributes_spec.rb",
97
- "spec/fixture_replacement/integration/attributes_for_with_invalid_keys_spec.rb",
98
- "spec/fixture_replacement/integration/attributes_from_spec_without_block.rb",
99
- "spec/fixture_replacement/integration/create_method_spec.rb",
100
- "spec/fixture_replacement/integration/cyclic_dependency_spec.rb",
101
- "spec/fixture_replacement/integration/default_warnings_spec.rb",
102
- "spec/fixture_replacement/integration/extend_spec.rb",
103
- "spec/fixture_replacement/integration/has_and_belongs_to_many_spec.rb",
104
- "spec/fixture_replacement/integration/new_method_spec.rb",
105
- "spec/fixture_replacement/integration/private_methods_spec.rb",
106
- "spec/fixture_replacement/integration/public_methods_spec.rb",
107
- "spec/fixture_replacement/integration/valid_attributes_spec.rb",
108
- "spec/fixture_replacement/integration/validation_spec.rb",
109
- "spec/fixture_replacement/regressions/2008_01_21_random_string_with_sti_spec.rb",
110
- "spec/fixture_replacement/version_spec.rb",
111
- "spec/spec_helper.rb",
112
- "spec/spec_helpers.rb",
113
- "test/test_helper.rb",
114
- "test/unit/user_test.rb"
115
- ]
116
-
117
- if s.respond_to? :specification_version then
118
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
119
- s.specification_version = 3
120
-
121
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
122
- else
123
- end
124
- else
125
- end
126
- end
@@ -1,37 +0,0 @@
1
- require 'spec/rake/spectask'
2
- require 'spec/rake/verify_rcov'
3
-
4
- desc "Run all examples with RCov"
5
- Spec::Rake::SpecTask.new(:rcov) do |t|
6
- t.rcov = true
7
- t.rcov_opts = ['--exclude', 'spec', '--exclude', 'gems']
8
- t.rcov_dir = "doc/rcov"
9
- end
10
-
11
- desc "Feel the pain of my code, and submit a refactoring patch"
12
- task :flog do
13
- puts %x(find lib | grep ".rb$" | xargs flog)
14
- end
15
-
16
- task :flog_to_disk => :create_doc_directory do
17
- puts "Flogging..."
18
- %x(find lib | grep ".rb$" | xargs flog > doc/flog.txt)
19
- puts "Done Flogging...\n"
20
- end
21
-
22
- def sloc
23
- `sloccount #{File.dirname(__FILE__)}/lib`
24
- end
25
-
26
- desc "Output sloccount report. You'll need sloccount installed."
27
- task :sloc do
28
- puts "Counting lines of code"
29
- puts sloc
30
- end
31
-
32
- desc "Write sloccount report"
33
- task :output_sloc => :create_doc_directory do
34
- File.open(File.dirname(__FILE__) + "/doc/lines_of_code.txt", "w") do |f|
35
- f << sloc
36
- end
37
- end
data/rake_tasks/docs.rb DELETED
@@ -1,59 +0,0 @@
1
- require 'hanna/rdoctask'
2
-
3
- def doc_directory
4
- "doc"
5
- end
6
-
7
- desc 'Generate documentation for the fixture_replacement plugin.'
8
- Rake::RDocTask.new(:rdoc_without_analytics) do |rdoc|
9
- rdoc.rdoc_dir = doc_directory
10
- rdoc.title = 'FixtureReplacement'
11
- rdoc.options << '--line-numbers' << '--inline-source'
12
-
13
- rdoc.options << '--webcvs=http://github.com/smtlaissezfaire/fixturereplacement/tree/master/'
14
-
15
- [
16
- "README.rdoc",
17
- "CHANGELOG.rdoc",
18
- "GPL_LICENSE",
19
- "MIT_LICENSE",
20
- "contributions.rdoc",
21
- "philosophy_and_bugs.rdoc",
22
- "lib/**/*.rb"
23
- ].each do |file|
24
- rdoc.rdoc_files.include(file)
25
- end
26
- end
27
-
28
- task :rdoc => [:rdoc_without_analytics] do
29
- google_analytics = File.read(File.dirname(__FILE__) + "/etc/google_analytics")
30
- rdoc_index = File.dirname(__FILE__) + "/#{doc_directory}/index.html"
31
-
32
- contents = File.read(rdoc_index)
33
- contents.gsub!("</head>", "#{google_analytics}\n</head>")
34
-
35
- File.open(rdoc_index, "r+") do |file|
36
- file.write(contents)
37
- end
38
- end
39
-
40
- task :rerdoc => [:clobber_rdoc, :rdoc]
41
- task :clobber_rdoc => [:clobber_rdoc_without_analytics]
42
-
43
- def create_doc_directory
44
- unless File.exists?(doc_directory)
45
- `mkdir doc`
46
- end
47
- end
48
-
49
- task :create_doc_directory do
50
- create_doc_directory
51
- end
52
-
53
- desc "Create the html specdoc"
54
- Spec::Rake::SpecTask.new(:specdoc => :create_doc_directory) do |t|
55
- t.spec_opts = ["--format", "html:doc/specdoc.html"]
56
- end
57
-
58
- desc 'Create the specdoc + rdoc'
59
- task :build_docs => [:rerdoc, :specdoc, :rcov, :flog_to_disk]
data/rake_tasks/gem.rb DELETED
@@ -1,27 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../lib/fixture_replacement")
2
-
3
- begin
4
- require 'jeweler'
5
-
6
- Jeweler::Tasks.new do |gemspec|
7
- File.open(File.expand_path(File.dirname(__FILE__) + "/../VERSION"), "w") do |f|
8
- f << FixtureReplacement::Version::VERSION
9
- end
10
-
11
- gemspec.name = "fixture_replacement"
12
- gemspec.summary = "The original fixture replacement solution for rails"
13
- gemspec.email = "scott@railsnewbie.com"
14
- gemspec.homepage = "http://replacefixtures.rubyforge.org"
15
- gemspec.authors = ["Scott Taylor"]
16
- gemspec.description = <<-DESC
17
- FixtureReplacement is a Rails plugin that provides a simple way to
18
- quickly populate your test database with model objects without having to manage multiple,
19
- brittle fixture files. You can easily set up complex object graphs (with models which
20
- reference other models) and add new objects on the fly.
21
- DESC
22
- end
23
-
24
- Jeweler::GemcutterTasks.new
25
- rescue LoadError
26
- puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
27
- end
data/rake_tasks/specs.rb DELETED
@@ -1,7 +0,0 @@
1
- require 'spec/rake/spectask'
2
-
3
- desc 'Run the specs'
4
- Spec::Rake::SpecTask.new do |t|
5
- t.warning = false
6
- t.spec_opts = ["--color"]
7
- end
data/rake_tasks/tests.rb DELETED
@@ -1,7 +0,0 @@
1
- require 'rake/testtask'
2
-
3
- Rake::TestTask.new do |t|
4
- t.libs << "test"
5
- t.test_files = FileList['test/**/*test*.rb']
6
- t.verbose = true
7
- end
@@ -1,11 +0,0 @@
1
- require 'rake/contrib/rubyforgepublisher'
2
-
3
- desc 'Publish the website, building the docs first'
4
- task :publish_website => [:build_docs] do
5
- publisher = Rake::SshDirPublisher.new(
6
- "smtlaissezfaire@rubyforge.org",
7
- "/var/www/gforge-projects/replacefixtures/",
8
- "doc"
9
- )
10
- publisher.upload
11
- end
@@ -1,162 +0,0 @@
1
- require File.dirname(__FILE__) + "/../spec_helper"
2
-
3
- module FixtureReplacement
4
- describe AttributeBuilder do
5
- before do
6
- AttributeBuilder.clear_out_instances!
7
- end
8
-
9
- it "should add the instance to the global attributes" do
10
- a = AttributeBuilder.new(:foo)
11
- AttributeBuilder.instances.should == [a]
12
- end
13
-
14
- it "should have no instances when none have been created" do
15
- AttributeBuilder.instances.should == []
16
- end
17
-
18
- it "should have two instances when two have been created" do
19
- a1 = AttributeBuilder.new(:foo)
20
- a2 = AttributeBuilder.new(:foo)
21
- AttributeBuilder.instances.should == [a1, a2]
22
- end
23
-
24
- it "should have the fixture name as accessible" do
25
- a1 = AttributeBuilder.new(:foo)
26
- a1.fixture_name.should == :foo
27
- end
28
-
29
- it "should have the from attribute as nil, if none provided" do
30
- a1 = AttributeBuilder.new(:foo)
31
- a1.from.should be_nil
32
- end
33
-
34
- it "should have the from attribute as the symbol of the attribute from which it derives" do
35
- a1 = AttributeBuilder.new(:foo, :from => :bar)
36
- a1.from.should == :bar
37
- end
38
-
39
- it "should be able to find the Attribute by fixture name" do
40
- a = AttributeBuilder.new(:baz)
41
- AttributeBuilder.find_by_fixture_name(:baz).should == a
42
- end
43
-
44
- it "should find no attributes for fixture_name :baz, if it was never created" do
45
- a = AttributeBuilder.new(:bar)
46
- AttributeBuilder.find_by_fixture_name(:baz).should be_nil
47
- end
48
-
49
- it "should find no attributes for fixture_name :baz, if no fixture at all was ever created" do
50
- AttributeBuilder.find_by_fixture_name(:baz).should be_nil
51
- end
52
-
53
- it "should have the class name if specified" do
54
- AttributeBuilder.new(:foo, :class => Object).active_record_class.should == Object
55
- end
56
-
57
- it "should use the class name of the fixture_name, camel-cased, if the class is unspecified, and the fixture uninherited" do
58
- AttributeBuilder.new(:object).active_record_class.should == Object
59
- end
60
-
61
- it "should use the class name of the inherited attribute, if specified" do
62
- AttributeBuilder.new(:foo, :class => Object)
63
- AttributeBuilder.new(:bar, :from => :foo).active_record_class.should == Bar
64
- end
65
-
66
- it "should prefer the constantized name to the derived name" do
67
- AttributeBuilder.new(:user)
68
- AttributeBuilder.new(:admin, :from => :user).active_record_class.should == Admin
69
- end
70
-
71
- it "should use the derived name if the constantized name fails (doesn't exist)" do
72
- AttributeBuilder.new(:foo)
73
- no_constant = AttributeBuilder.new(:no_constant, :from => :foo)
74
- no_constant.active_record_class.should == Foo
75
- end
76
-
77
- it "should raise a name error if it has no class, the name can't be constantized, and is derived, but the derived class can't be constantized" do
78
- builder_one = AttributeBuilder.new(:does_not_exist)
79
- builder_two = AttributeBuilder.new(:also_does_not_exist, :from => :does_not_exist)
80
-
81
- lambda {
82
- builder_two.active_record_class
83
- }.should raise_error(NameError)
84
- end
85
-
86
- it "should not raise an error if the model ends with 's'" do
87
- AttributeBuilder.new(:actress).active_record_class.should == Actress
88
- end
89
-
90
- it "should allow a string key" do
91
- AttributeBuilder.new(:admin, "from" => :user).active_record_class.should == Admin
92
- end
93
-
94
- it "should allow a string name for the builder" do
95
- AttributeBuilder.new("admin").active_record_class.should == Admin
96
- end
97
-
98
- it "should store the from key as a symbol, even when passed a string" do
99
- builder = AttributeBuilder.new(:admin, "from" => "user")
100
- builder.from.should == :user
101
- end
102
-
103
- it "should convert the fixture name to a symbol" do
104
- builder = AttributeBuilder.new("admin")
105
- builder.fixture_name.should == :admin
106
- end
107
-
108
- describe "validating all instances" do
109
- it "should return true if there are no instances" do
110
- AttributeBuilder.validate_instances!.should be_true
111
- end
112
-
113
- it "should raise an error if an instance is not valid" do
114
- AttributeBuilder.new(:validate_name)
115
-
116
- lambda {
117
- AttributeBuilder.validate_instances!
118
- }.should raise_error
119
- end
120
-
121
- it "should not raise an error if there is only one instance, and it is valid" do
122
- AttributeBuilder.new(:event)
123
-
124
- lambda {
125
- AttributeBuilder.validate_instances!
126
- }.should_not raise_error
127
- end
128
-
129
- it "should raise an error, giving the fixture name, and the error" do
130
- AttributeBuilder.new(:validate_name)
131
-
132
- lambda {
133
- AttributeBuilder.validate_instances!
134
- }.should raise_error(FixtureReplacement::InvalidInstance, "new_validate_name is not valid! - Errors: [name: can't be blank]")
135
- end
136
-
137
- it "should use the correct name" do
138
- AttributeBuilder.new(:validate_name_two)
139
-
140
- lambda {
141
- AttributeBuilder.validate_instances!
142
- }.should raise_error(FixtureReplacement::InvalidInstance, "new_validate_name_two is not valid! - Errors: [name: can't be blank]")
143
- end
144
-
145
- it "should use the correct errors" do
146
- AttributeBuilder.new(:address_with_valid_city)
147
-
148
- lambda {
149
- AttributeBuilder.validate_instances!
150
- }.should raise_error(FixtureReplacement::InvalidInstance, "new_address_with_valid_city is not valid! - Errors: [city: can't be blank]")
151
- end
152
-
153
- it "should use multiple errors on a single model" do
154
- AttributeBuilder.new(:address_with_valid_city_and_state)
155
-
156
- lambda {
157
- AttributeBuilder.validate_instances!
158
- }.should raise_error(FixtureReplacement::InvalidInstance, "new_address_with_valid_city_and_state is not valid! - Errors: [city: can't be blank], [state: can't be blank]")
159
- end
160
- end
161
- end
162
- end
@@ -1,96 +0,0 @@
1
- require File.dirname(__FILE__) + "/../spec_helper"
2
-
3
- describe FixtureReplacement do
4
- describe "random_string" do
5
- before do
6
- @fr = FixtureReplacement
7
- end
8
-
9
- it "should not be the same as another randomly generated string" do
10
- @fr.random_string.should_not == @fr.random_string
11
- end
12
-
13
- it "should by default be 10 characters long" do
14
- @fr.random_string.size.should == 10
15
- end
16
-
17
- it "should be able to specify the length of the random string" do
18
- @fr.random_string(100).size.should == 100
19
- end
20
-
21
- it "should only generate lowercase letters" do
22
- s = @fr.random_string(100)
23
- s.upcase.should == s.swapcase
24
- end
25
- end
26
-
27
- describe "requiring the fixtures file" do
28
- before do
29
- FixtureReplacement.stub!(:load)
30
- end
31
-
32
- it "should require db/example_data" do
33
- FixtureReplacement.stub!(:rails_root).and_return "/foo/bar"
34
- FixtureReplacement.should_receive(:load).with("/foo/bar/db/example_data.rb")
35
-
36
- FixtureReplacement.load_example_data
37
- end
38
-
39
- it "should use the correct rails root" do
40
- FixtureReplacement.stub!(:rails_root).and_return "/rails/root"
41
- FixtureReplacement.should_receive(:load).with("/rails/root/db/example_data.rb")
42
-
43
- FixtureReplacement.load_example_data
44
- end
45
-
46
- it "should not blow up if the file is not found" do
47
- FixtureReplacement.stub!(:load).and_raise LoadError
48
-
49
- lambda {
50
- FixtureReplacement.load_example_data
51
- }.should_not raise_error
52
- end
53
- end
54
-
55
- describe "rails_root" do
56
- def use_rails_root(rails_root, &block)
57
- silence_warnings do
58
- Object.const_set(:RAILS_ROOT, rails_root)
59
- end
60
- block.call
61
- ensure
62
- Object.send :remove_const, :RAILS_ROOT
63
- end
64
-
65
- it "should be the RAILS_ROOT constant if given" do
66
- use_rails_root "/rails/root" do
67
- FR.rails_root.should == "/rails/root"
68
- end
69
- end
70
-
71
- it "should use the correct RAILS_ROOT" do
72
- use_rails_root "/foo/bar" do
73
- FR.rails_root.should == "/foo/bar"
74
- end
75
- end
76
-
77
- it "should be '.' if not defined" do
78
- FR.rails_root.should == "."
79
- end
80
- end
81
-
82
- describe "reload!" do
83
- it "should call load on the main fixture replacement file" do
84
- file_path = File.expand_path(File.dirname(__FILE__) + "/../../lib/fixture_replacement.rb")
85
- FixtureReplacement.should_receive(:load).with(file_path)
86
-
87
- FixtureReplacement.reload!
88
- end
89
- end
90
-
91
- describe "method_added" do
92
- it "should be private" do
93
- FixtureReplacement.should_not respond_to(:method_added)
94
- end
95
- end
96
- end
@@ -1,78 +0,0 @@
1
- unless defined?(User)
2
- class User < ActiveRecord::Base
3
- belongs_to :gender
4
- end
5
-
6
- class Member < ActiveRecord::Base; end
7
-
8
- class Post < ActiveRecord::Base
9
- has_many :comments
10
- end
11
-
12
- class Comment < ActiveRecord::Base
13
- belongs_to :post
14
- end
15
-
16
- class Player < ActiveRecord::Base
17
- end
18
-
19
- class Alien < ActiveRecord::Base
20
- belongs_to :gender
21
- end
22
-
23
- class Admin < ActiveRecord::Base
24
- attr_protected :admin_status
25
- end
26
-
27
- class Gender < ActiveRecord::Base; end
28
- class Actress < ActiveRecord::Base; end
29
-
30
- class Item < ActiveRecord::Base
31
- belongs_to :category
32
- end
33
-
34
- class Writing < Item; end
35
-
36
- class Category < ActiveRecord::Base
37
- has_many :items
38
- end
39
-
40
- class Subscriber < ActiveRecord::Base
41
- has_and_belongs_to_many :subscriptions
42
- end
43
-
44
- class Subscription < ActiveRecord::Base
45
- has_and_belongs_to_many :subscribers
46
- end
47
-
48
- class Event < ActiveRecord::Base
49
- has_one :schedule
50
- end
51
-
52
- class Schedule < ActiveRecord::Base
53
- belongs_to :event
54
- end
55
-
56
- class Foo; end
57
- class Bar; end
58
-
59
- class NoValidation < ActiveRecord::Base
60
- end
61
-
62
- class ValidateName < ActiveRecord::Base
63
- validates_presence_of :name
64
- end
65
-
66
- class ValidateNameTwo < ActiveRecord::Base
67
- validates_presence_of :name
68
- end
69
-
70
- class AddressWithValidCity < ActiveRecord::Base
71
- validates_presence_of :city
72
- end
73
-
74
- class AddressWithValidCityAndState < ActiveRecord::Base
75
- validates_presence_of :city
76
- validates_presence_of :state
77
- end
78
- end
@@ -1,7 +0,0 @@
1
- require File.dirname(__FILE__) + "/../spec_helper"
2
-
3
- describe FR do
4
- it "should alias FixtureReplacement" do
5
- FR.should equal(FixtureReplacement)
6
- end
7
- end