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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9639be9a13dc9d214ce4bec09d30d6db2fb474da7da46a9cfb1e342d634dbc9d
4
+ data.tar.gz: 05bbb4be36f092820dfabbef75df7f6e08dc9bc944ba42de8d7e4bb73eaa5cdf
5
+ SHA512:
6
+ metadata.gz: 1d571d591cc6db036d8832ab0833bb2738e95cb4677584c6de56d04136b72ca52c2b9f30d90b11820435e89bfae82e8a311e05346fc10b4ea9d08b5ff3f8442e
7
+ data.tar.gz: ada4710268617f3654d5ee829005df56c9606a412e5b0905aa4203cded58bdbacb13eb9145c3e64b1099d35abdd87dc752e34d9bce0f78a1650785d8dc7a1597
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,8 @@
1
+ == 4.0.0
2
+
3
+ - Update for most recent rails / rspec (rails 7+).
4
+ - This gem hasn't been updated for over 10+ years. So this is a welcome change!
5
+
1
6
  == 3.0.1
2
7
 
3
8
  - Made it into a rubygem. Get it from gemcutter:
data/README.rdoc CHANGED
@@ -28,9 +28,9 @@ Install the plugin:
28
28
 
29
29
  === Using it with RSpec
30
30
 
31
- Add the following to your <tt>spec/spec_helper.rb</tt> file, in the configuration section:
31
+ Add the following to your <tt>spec/rails_helper.rb</tt> file, in the configuration section:
32
32
 
33
- Spec::Runner.configure do |config|
33
+ RSpec.configure do |config|
34
34
  config.include FixtureReplacement
35
35
  end
36
36
 
@@ -98,18 +98,6 @@ Overrides can also be used with associations:
98
98
  post = create_post(:user => scott)
99
99
 
100
100
 
101
- === attr_protected / attr_accessible
102
-
103
- In the case that the model has an attr_protected field, FixtureReplacement
104
- will assign the field as if it wasn't protected, which is convenient for testing:
105
-
106
- class User < ActiveRecord::Base
107
- attr_protected :admin_status
108
- end
109
-
110
- user = create_user(:username => "scott", :admin_status => true)
111
- user.admin_status # => true
112
-
113
101
  === Validate your fixtures (thanks Fixjour)
114
102
 
115
103
  Validate your fixture definitions after including it in the spec helper or test helper:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.1
1
+ 4.0.0
@@ -32,7 +32,7 @@ module FixtureReplacement
32
32
  check_valid_keys(options, [:from, :class])
33
33
 
34
34
  @fixture_name = fixture_name.to_sym
35
- @attributes_proc = block || lambda {}
35
+ @attributes_proc = block || proc {}
36
36
  @from = options[:from].to_sym if options.has_key?(:from)
37
37
  @class = options[:class]
38
38
 
@@ -47,7 +47,7 @@ module FixtureReplacement
47
47
  end
48
48
 
49
49
  def instantiate(hash_to_merge = {}, instance = active_record_class.new)
50
- returning instance do
50
+ instance.tap do
51
51
  instantiate_parent_fixture(instance)
52
52
  call_attribute_body(instance, hash_to_merge)
53
53
  add_given_keys(instance, hash_to_merge)
@@ -59,7 +59,9 @@ module FixtureReplacement
59
59
 
60
60
  unless new_instance.valid?
61
61
  errors = "new_#{fixture_name} is not valid! - Errors: "
62
- errors << new_instance.errors.map { |key, value| "[#{key}: #{value}]"}.join(", ")
62
+ errors << new_instance.errors.map do |error|
63
+ "[#{error.attribute}: #{error.message}]"
64
+ end.join(", ")
63
65
  raise InvalidInstance, errors
64
66
  end
65
67
  end
@@ -1,5 +1,9 @@
1
1
  module FixtureReplacement
2
2
  module ClassMethods
3
+ def included(_other_mod)
4
+ FixtureReplacement.load_example_data
5
+ end
6
+
3
7
  def attributes_for(fixture_name, options={}, &block)
4
8
  builder = AttributeBuilder.new(fixture_name, options, &block)
5
9
  MethodGenerator.new(builder, self).generate_methods
@@ -18,12 +22,16 @@ module FixtureReplacement
18
22
 
19
23
  def load_example_data
20
24
  load "#{rails_root}/db/example_data.rb"
21
- rescue LoadError
25
+ # rescue NameError
26
+ # load "./db/example_data.rb"
27
+ rescue LoadError, NameError
22
28
  # no-op. If the file is not found, don't panic
23
29
  end
24
30
 
25
31
  def rails_root
26
- defined?(RAILS_ROOT) ? RAILS_ROOT : "."
32
+ ::Rails.root
33
+ rescue NameError
34
+ "."
27
35
  end
28
36
 
29
37
  def reload!
@@ -1,9 +1,9 @@
1
1
  module FixtureReplacement
2
2
  module Version
3
3
  unless defined?(FixtureReplacement::VERSION)
4
- MAJOR = 3
4
+ MAJOR = 4
5
5
  MINOR = 0
6
- TINY = 1
6
+ TINY = 0
7
7
 
8
8
  version_string = "#{MAJOR}.#{MINOR}.#{TINY}"
9
9
  version_string << " RC#{RELEASE_CANDIDATE}" if defined?(RELEASE_CANDIDATE)
@@ -13,4 +13,3 @@ end
13
13
 
14
14
  load "fr.rb"
15
15
 
16
- FixtureReplacement.load_example_data
metadata CHANGED
@@ -1,57 +1,33 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: fixture_replacement
3
- version: !ruby/object:Gem::Version
4
- version: 3.0.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 4.0.0
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - Scott Taylor
8
- autorequire:
8
+ - Stephen Schor
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
-
12
- date: 2009-11-21 00:00:00 -05:00
13
- default_executable:
12
+ date: 2022-09-07 00:00:00.000000000 Z
14
13
  dependencies: []
15
-
16
14
  description: |
17
15
  FixtureReplacement is a Rails plugin that provides a simple way to
18
16
  quickly populate your test database with model objects without having to manage multiple,
19
17
  brittle fixture files. You can easily set up complex object graphs (with models which
20
18
  reference other models) and add new objects on the fly.
21
-
22
- email: scott@railsnewbie.com
19
+ email: scott@railsnewbie.com beholdthepanda@gmail.com
23
20
  executables: []
24
-
25
21
  extensions: []
26
-
27
- extra_rdoc_files:
28
- - README.rdoc
29
- files:
30
- - .gitignore
22
+ extra_rdoc_files: []
23
+ files:
31
24
  - CHANGELOG.rdoc
32
25
  - GPL_LICENSE
33
26
  - MIT_LICENSE
34
27
  - README.rdoc
35
- - Rakefile
36
28
  - TODO.rdoc
37
29
  - VERSION
38
30
  - contributions.rdoc
39
- - etc/bug_reports/2007_09_28_linoj.txt
40
- - etc/google_analytics
41
- - etc/patches/2007_09_14_default_model_name_with_arguments.diff
42
- - etc/patches/2007_10_14_active_record_specs.diff
43
- - etc/patches/2007_10_14_protected_attributes.diff
44
- - etc/patches/2007_10_14_send_patch.diff
45
- - etc/patches/2007_10_14_spelling_error_in_comments.diff
46
- - etc/patches/2007_10_17_protected_attributes_second_go.diff
47
- - etc/patches/2007_10_18_README.diff
48
- - etc/patches/2007_10_19_readme_tweak.diff
49
- - etc/patches/2007_10_19_silence_migration.diff
50
- - etc/patches/2007_10_25_changed_classify_to_camelize.diff
51
- - etc/patches/2007_11_20_fixture_replacement_generator_should_not_reload_environment_or_boot.patch
52
- - etc/patches/2007_11_20_string_random_refactor_and_extension.patch
53
- - etc/patches/2007_11_20_string_random_refactor_and_extension_v2.patch
54
- - fixture_replacement.gemspec
55
31
  - lib/fixture_replacement.rb
56
32
  - lib/fixture_replacement/attribute_builder.rb
57
33
  - lib/fixture_replacement/class_methods.rb
@@ -59,85 +35,26 @@ files:
59
35
  - lib/fixture_replacement/version.rb
60
36
  - lib/fr.rb
61
37
  - philosophy_and_bugs.rdoc
62
- - rake_tasks/code_quality.rb
63
- - rake_tasks/docs.rb
64
- - rake_tasks/gem.rb
65
- - rake_tasks/specs.rb
66
- - rake_tasks/tests.rb
67
- - rake_tasks/website.rb
68
- - spec/fixture_replacement/attribute_builder_spec.rb
69
- - spec/fixture_replacement/fixture_replacement_spec.rb
70
- - spec/fixture_replacement/fixtures/classes.rb
71
- - spec/fixture_replacement/fr_spec.rb
72
- - spec/fixture_replacement/integration/attr_protected_attributes_spec.rb
73
- - spec/fixture_replacement/integration/attributes_for_with_invalid_keys_spec.rb
74
- - spec/fixture_replacement/integration/attributes_from_spec_without_block.rb
75
- - spec/fixture_replacement/integration/create_method_spec.rb
76
- - spec/fixture_replacement/integration/cyclic_dependency_spec.rb
77
- - spec/fixture_replacement/integration/default_warnings_spec.rb
78
- - spec/fixture_replacement/integration/extend_spec.rb
79
- - spec/fixture_replacement/integration/has_and_belongs_to_many_spec.rb
80
- - spec/fixture_replacement/integration/new_method_spec.rb
81
- - spec/fixture_replacement/integration/private_methods_spec.rb
82
- - spec/fixture_replacement/integration/public_methods_spec.rb
83
- - spec/fixture_replacement/integration/valid_attributes_spec.rb
84
- - spec/fixture_replacement/integration/validation_spec.rb
85
- - spec/fixture_replacement/regressions/2008_01_21_random_string_with_sti_spec.rb
86
- - spec/fixture_replacement/version_spec.rb
87
- - spec/spec.opts
88
- - spec/spec_helper.rb
89
- - spec/spec_helpers.rb
90
- - test/test_helper.rb
91
- - test/unit/user_test.rb
92
- has_rdoc: true
93
- homepage: http://replacefixtures.rubyforge.org
38
+ homepage: https://github.com/smtlaissezfaire/fixturereplacement
94
39
  licenses: []
95
-
96
- post_install_message:
97
- rdoc_options:
98
- - --charset=UTF-8
99
- require_paths:
40
+ metadata: {}
41
+ post_install_message:
42
+ rdoc_options: []
43
+ require_paths:
100
44
  - lib
101
- required_ruby_version: !ruby/object:Gem::Requirement
102
- requirements:
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
103
47
  - - ">="
104
- - !ruby/object:Gem::Version
105
- version: "0"
106
- version:
107
- required_rubygems_version: !ruby/object:Gem::Requirement
108
- requirements:
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
109
52
  - - ">="
110
- - !ruby/object:Gem::Version
111
- version: "0"
112
- version:
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
113
55
  requirements: []
114
-
115
- rubyforge_project:
116
- rubygems_version: 1.3.5
117
- signing_key:
56
+ rubygems_version: 3.0.9
57
+ signing_key:
118
58
  specification_version: 3
119
59
  summary: The original fixture replacement solution for rails
120
- test_files:
121
- - spec/fixture_replacement/attribute_builder_spec.rb
122
- - spec/fixture_replacement/fixture_replacement_spec.rb
123
- - spec/fixture_replacement/fixtures/classes.rb
124
- - spec/fixture_replacement/fr_spec.rb
125
- - spec/fixture_replacement/integration/attr_protected_attributes_spec.rb
126
- - spec/fixture_replacement/integration/attributes_for_with_invalid_keys_spec.rb
127
- - spec/fixture_replacement/integration/attributes_from_spec_without_block.rb
128
- - spec/fixture_replacement/integration/create_method_spec.rb
129
- - spec/fixture_replacement/integration/cyclic_dependency_spec.rb
130
- - spec/fixture_replacement/integration/default_warnings_spec.rb
131
- - spec/fixture_replacement/integration/extend_spec.rb
132
- - spec/fixture_replacement/integration/has_and_belongs_to_many_spec.rb
133
- - spec/fixture_replacement/integration/new_method_spec.rb
134
- - spec/fixture_replacement/integration/private_methods_spec.rb
135
- - spec/fixture_replacement/integration/public_methods_spec.rb
136
- - spec/fixture_replacement/integration/valid_attributes_spec.rb
137
- - spec/fixture_replacement/integration/validation_spec.rb
138
- - spec/fixture_replacement/regressions/2008_01_21_random_string_with_sti_spec.rb
139
- - spec/fixture_replacement/version_spec.rb
140
- - spec/spec_helper.rb
141
- - spec/spec_helpers.rb
142
- - test/test_helper.rb
143
- - test/unit/user_test.rb
60
+ test_files: []
data/.gitignore DELETED
@@ -1,2 +0,0 @@
1
- doc
2
- pkg
data/Rakefile DELETED
@@ -1,8 +0,0 @@
1
- require 'rake'
2
-
3
- Dir.glob("rake_tasks/**/*.rb").each do |file|
4
- require file
5
- end
6
-
7
- desc 'Default: run unit tests (specs + tests).'
8
- task :default => [:spec, :test]
@@ -1,51 +0,0 @@
1
- Hi Scott,
2
-
3
- I'm wondering if you have insight into this or if I should go ask somewhere else.
4
-
5
- I installed 2 plug-in today,
6
- first fixture_replacement plugin
7
- and been using it successfully
8
-
9
- Then I installed validates_email_format_of plugin
10
- http://code.dunae.ca/validates_email_format_of
11
-
12
- and added this to my User model
13
- validates_email_format_of :email
14
-
15
- then script/server wont start
16
- When I comment out this line, it's fine
17
-
18
- Here's the error:
19
-
20
- $ script/server
21
- => Booting Mongrel (use 'script/server webrick' to force WEBrick)
22
- => Rails application starting on http://0.0.0.0:3000
23
- => Call with -d to detach
24
- => Ctrl-C to shutdown server
25
- ** Starting Mongrel listening at 0.0.0.0:3000
26
- ** Starting Rails with development environment...
27
- Exiting
28
- /Users/jonathan/rails/reviewramp/vendor/plugins/fixture_replacement/init.rb:9:in `evaluate': Error in FixtureReplacement Plugin: undefined method `validates_email_format_of' for #<Class:0x241cc68> (RuntimeError)
29
- from ./script/../config/../vendor/rails/railties/lib/rails/plugin/loader.rb:107:in `evaluate'
30
- from /Users/jonathan/rails/reviewramp/vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
31
- from ./script/../config/../vendor/rails/railties/lib/rails/plugin/loader.rb:107:in `evaluate'
32
- from ./script/../config/../vendor/rails/railties/lib/rails/plugin/loader.rb:24:in `load'
33
- from /Users/jonathan/rails/reviewramp/vendor/rails/railties/lib/initializer.rb:183:in `load_plugins'
34
- from ./script/../config/../vendor/rails/railties/lib/rails/plugin/locator.rb:16:in `each'
35
- from ./script/../config/../vendor/rails/railties/lib/rails/plugin/locator.rb:16:in `each'
36
- from /Users/jonathan/rails/reviewramp/vendor/rails/railties/lib/initializer.rb:182:in `load_plugins'
37
- ... 31 levels...
38
- from /Users/jonathan/rails/reviewramp/vendor/rails/activesupport/lib/active_support/dependencies.rb:495:in `require'
39
- from /Users/jonathan/rails/reviewramp/vendor/rails/railties/lib/commands/server.rb:39
40
- from script/server:3:in `require'
41
- from script/server:3
42
-
43
-
44
- I havent tried it in a different project (without fixture_replacement) but looks like yours is getting the blame... :)
45
-
46
- (I'm on Rails Edge)
47
-
48
- -- linoj
49
-
50
-
51
-
data/etc/google_analytics DELETED
@@ -1,6 +0,0 @@
1
- <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
2
- </script>
3
- <script type="text/javascript">
4
- _uacct = "UA-3080808-2";
5
- urchinTracker();
6
- </script>
@@ -1,26 +0,0 @@
1
- Index: lib/fixture_replacement/fixture_replacement.rb
2
- ===================================================================
3
- --- lib/fixture_replacement/fixture_replacement.rb (revision 1151)
4
- +++ lib/fixture_replacement/fixture_replacement.rb (working copy)
5
- @@ -40,7 +40,8 @@
6
- def merge_unevaluated_method(obj, method_for_instantiation, hash={})
7
- hash.each do |key, value|
8
- if value.kind_of?(::FixtureReplacement::DelayedEvaluationProc)
9
- - hash[key] = obj.send("#{method_for_instantiation}_#{value.call}")
10
- + model_name, args = value.call
11
- + hash[key] = obj.send("#{method_for_instantiation}_#{model_name}", args)
12
- end
13
- end
14
- end
15
- @@ -63,9 +64,9 @@
16
- default_method = "default_#{model_name}".to_sym
17
-
18
- fixture_module.module_eval do
19
- - define_method(default_method) do
20
- + define_method(default_method) do |*args|
21
- ::FixtureReplacement::DelayedEvaluationProc.new do
22
- - model_as_string
23
- + [model_as_string, args[0]]
24
- end
25
- end
26
- end