resource_controller 0.5.3 → 0.6.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. data/README.rdoc +18 -14
  2. data/VERSION.yml +5 -0
  3. data/generators/scaffold_resource/templates/rspec/routing_spec.rb +8 -8
  4. data/generators/scaffold_resource/templates/rspec/views/index_spec.rb +2 -2
  5. data/lib/resource_controller.rb +5 -14
  6. data/lib/resource_controller/base.rb +2 -2
  7. data/lib/resource_controller/class_methods.rb +2 -2
  8. data/lib/resource_controller/controller.rb +3 -2
  9. data/lib/resource_controller/helpers.rb +0 -6
  10. data/lib/resource_controller/helpers/nested.rb +1 -1
  11. data/lib/resource_controller/singleton.rb +2 -2
  12. data/test/app/controllers/{application.rb → application_controller.rb} +0 -2
  13. data/test/app/controllers/cms/personnel_controller.rb +2 -0
  14. data/test/app/controllers/cms/photos_controller.rb +6 -0
  15. data/test/app/controllers/photos_controller.rb +1 -0
  16. data/test/app/models/personnel.rb +3 -0
  17. data/test/app/models/photo.rb +1 -0
  18. data/test/app/views/cms/photos/edit.rhtml +17 -0
  19. data/test/app/views/cms/photos/index.rhtml +20 -0
  20. data/test/app/views/cms/photos/new.rhtml +16 -0
  21. data/test/app/views/cms/photos/show.rhtml +8 -0
  22. data/test/config/boot.rb +6 -5
  23. data/test/config/database.yml +6 -10
  24. data/test/config/environment.rb +4 -4
  25. data/test/config/environments/development.rb +0 -4
  26. data/test/config/initializers/inflections.rb +14 -0
  27. data/test/config/routes.rb +3 -0
  28. data/test/db/migrate/013_create_personnel.rb +11 -0
  29. data/test/db/migrate/014_add_personnel_id_to_photos.rb +9 -0
  30. data/test/db/schema.rb +9 -3
  31. data/test/test/fixtures/personnel.yml +5 -0
  32. data/test/test/functional/cms/options_controller_test.rb +1 -1
  33. data/test/test/functional/cms/photos_controller_test.rb +43 -0
  34. data/test/test/functional/cms/products_controller_test.rb +1 -1
  35. data/test/test/functional/comments_controller_test.rb +2 -9
  36. data/test/test/functional/images_controller_test.rb +1 -8
  37. data/test/test/functional/people_controller_test.rb +2 -9
  38. data/test/test/functional/photos_controller_test.rb +2 -9
  39. data/test/test/functional/posts_controller_test.rb +2 -9
  40. data/test/test/functional/projects_controller_test.rb +12 -9
  41. data/test/test/functional/somethings_controller_test.rb +2 -9
  42. data/test/test/functional/tags_controller_test.rb +2 -9
  43. data/test/test/functional/users_controller_test.rb +2 -9
  44. data/test/test/test_helper.rb +4 -3
  45. data/test/test/unit/accessors_test.rb +2 -2
  46. data/test/test/unit/account_test.rb +1 -1
  47. data/test/test/unit/action_options_test.rb +1 -1
  48. data/test/test/unit/base_test.rb +1 -1
  49. data/test/test/unit/comment_test.rb +1 -1
  50. data/test/test/unit/failable_action_options_test.rb +1 -1
  51. data/test/test/unit/helpers_test.rb +1 -1
  52. data/test/test/unit/image_test.rb +1 -1
  53. data/test/test/unit/option_test.rb +1 -1
  54. data/test/test/unit/photo_test.rb +1 -1
  55. data/test/test/unit/post_test.rb +1 -1
  56. data/test/test/unit/project_test.rb +1 -1
  57. data/test/test/unit/response_collector_test.rb +1 -1
  58. data/test/test/unit/something_test.rb +1 -1
  59. data/test/test/unit/tag_test.rb +1 -1
  60. data/test/test/unit/urligence_test.rb +1 -1
  61. metadata +162 -122
  62. data/Rakefile +0 -35
  63. data/init.rb +0 -1
  64. data/lib/resource_controller/version.rb +0 -9
  65. data/test/log/development.log +0 -3350
  66. data/test/log/test.log +0 -174947
  67. data/test/log/thin.log +0 -12
  68. data/test/vendor/plugins/shoulda/Rakefile +0 -32
  69. data/test/vendor/plugins/shoulda/bin/convert_to_should_syntax +0 -40
  70. data/test/vendor/plugins/shoulda/init.rb +0 -3
  71. data/test/vendor/plugins/shoulda/lib/shoulda.rb +0 -43
  72. data/test/vendor/plugins/shoulda/lib/shoulda/active_record_helpers.rb +0 -580
  73. data/test/vendor/plugins/shoulda/lib/shoulda/color.rb +0 -77
  74. data/test/vendor/plugins/shoulda/lib/shoulda/controller_tests/controller_tests.rb +0 -467
  75. data/test/vendor/plugins/shoulda/lib/shoulda/controller_tests/formats/html.rb +0 -201
  76. data/test/vendor/plugins/shoulda/lib/shoulda/controller_tests/formats/xml.rb +0 -170
  77. data/test/vendor/plugins/shoulda/lib/shoulda/gem/proc_extensions.rb +0 -14
  78. data/test/vendor/plugins/shoulda/lib/shoulda/gem/shoulda.rb +0 -239
  79. data/test/vendor/plugins/shoulda/lib/shoulda/general.rb +0 -118
  80. data/test/vendor/plugins/shoulda/lib/shoulda/private_helpers.rb +0 -22
@@ -1,118 +0,0 @@
1
- module ThoughtBot # :nodoc:
2
- module Shoulda # :nodoc:
3
- module General
4
- def self.included(other) # :nodoc:
5
- other.class_eval do
6
- extend ThoughtBot::Shoulda::General::ClassMethods
7
- end
8
- end
9
-
10
- module ClassMethods
11
- # Loads all fixture files (<tt>test/fixtures/*.yml</tt>)
12
- def load_all_fixtures
13
- all_fixtures = Dir.glob(File.join(Test::Unit::TestCase.fixture_path, "*.yml")).collect do |f|
14
- File.basename(f, '.yml').to_sym
15
- end
16
- fixtures *all_fixtures
17
- end
18
- end
19
-
20
- # Prints a message to stdout, tagged with the name of the calling method.
21
- def report!(msg = "")
22
- puts("#{caller.first}: #{msg}")
23
- end
24
-
25
- # Asserts that two arrays contain the same elements, the same number of times. Essentially ==, but unordered.
26
- #
27
- # assert_same_elements([:a, :b, :c], [:c, :a, :b]) => passes
28
- def assert_same_elements(a1, a2, msg = nil)
29
- [:select, :inject, :size].each do |m|
30
- [a1, a2].each {|a| assert_respond_to(a, m, "Are you sure that #{a.inspect} is an array? It doesn't respond to #{m}.") }
31
- end
32
-
33
- assert a1h = a1.inject({}) { |h,e| h[e] = a1.select { |i| i == e }.size; h }
34
- assert a2h = a2.inject({}) { |h,e| h[e] = a2.select { |i| i == e }.size; h }
35
-
36
- assert_equal(a1h, a2h, msg)
37
- end
38
-
39
- # Asserts that the given collection contains item x. If x is a regular expression, ensure that
40
- # at least one element from the collection matches x. +extra_msg+ is appended to the error message if the assertion fails.
41
- #
42
- # assert_contains(['a', '1'], /\d/) => passes
43
- # assert_contains(['a', '1'], 'a') => passes
44
- # assert_contains(['a', '1'], /not there/) => fails
45
- def assert_contains(collection, x, extra_msg = "")
46
- collection = [collection] unless collection.is_a?(Array)
47
- msg = "#{x.inspect} not found in #{collection.to_a.inspect} #{extra_msg}"
48
- case x
49
- when Regexp: assert(collection.detect { |e| e =~ x }, msg)
50
- else assert(collection.include?(x), msg)
51
- end
52
- end
53
-
54
- # Asserts that the given collection does not contain item x. If x is a regular expression, ensure that
55
- # none of the elements from the collection match x.
56
- def assert_does_not_contain(collection, x, extra_msg = "")
57
- collection = [collection] unless collection.is_a?(Array)
58
- msg = "#{x.inspect} found in #{collection.to_a.inspect} " + extra_msg
59
- case x
60
- when Regexp: assert(!collection.detect { |e| e =~ x }, msg)
61
- else assert(!collection.include?(x), msg)
62
- end
63
- end
64
-
65
- # Asserts that the given object can be saved
66
- #
67
- # assert_save User.new(params)
68
- def assert_save(obj)
69
- assert obj.save, "Errors: #{pretty_error_messages obj}"
70
- obj.reload
71
- end
72
-
73
- # Asserts that the given object is valid
74
- #
75
- # assert_valid User.new(params)
76
- def assert_valid(obj)
77
- assert obj.valid?, "Errors: #{pretty_error_messages obj}"
78
- end
79
-
80
- # Asserts that an email was delivered. Can take a block that can further
81
- # narrow down the types of emails you're expecting.
82
- #
83
- # assert_sent_email
84
- #
85
- # Passes if ActionMailer::Base.deliveries has an email
86
- #
87
- # assert_sent_email do |email|
88
- # email.subject =~ /hi there/ && email.to.include?('none@none.com')
89
- # end
90
- #
91
- # Passes if there is an email with subject containing 'hi there' and
92
- # 'none@none.com' as one of the recipients.
93
- #
94
- def assert_sent_email
95
- emails = ActionMailer::Base.deliveries
96
- assert !emails.empty?, "No emails were sent"
97
- if block_given?
98
- matching_emails = emails.select {|email| yield email }
99
- assert !matching_emails.empty?, "None of the emails matched."
100
- end
101
- end
102
-
103
- # Asserts that no ActionMailer mails were delivered
104
- #
105
- # assert_did_not_send_email
106
- def assert_did_not_send_email
107
- msg = "Sent #{ActionMailer::Base.deliveries.size} emails.\n"
108
- ActionMailer::Base.deliveries.each { |m| msg << " '#{m.subject}' sent to #{m.to.to_sentence}\n" }
109
- assert ActionMailer::Base.deliveries.empty?, msg
110
- end
111
-
112
- def pretty_error_messages(obj)
113
- obj.errors.map { |a, m| "#{a} #{m} (#{obj.send(a).inspect})" }
114
- end
115
-
116
- end
117
- end
118
- end
@@ -1,22 +0,0 @@
1
- module ThoughtBot # :nodoc:
2
- module Shoulda # :nodoc:
3
- module Private # :nodoc:
4
- # Returns the values for the entries in the args hash who's keys are listed in the wanted array.
5
- # Will raise if there are keys in the args hash that aren't listed.
6
- def get_options!(args, *wanted)
7
- ret = []
8
- opts = (args.last.is_a?(Hash) ? args.pop : {})
9
- wanted.each {|w| ret << opts.delete(w)}
10
- raise ArgumentError, "Unsupported options given: #{opts.keys.join(', ')}" unless opts.keys.empty?
11
- return *ret
12
- end
13
-
14
- # Returns the model class constant, as determined by the test class name.
15
- #
16
- # class TestUser; model_class; end => User
17
- def model_class
18
- self.name.gsub(/Test$/, '').constantize
19
- end
20
- end
21
- end
22
- end