carlosbrando-remarkable 0.0.99 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. data/History.txt +5 -5
  2. data/Manifest.txt +53 -35
  3. data/PostInstall.txt +1 -6
  4. data/README.rdoc +109 -15
  5. data/Rakefile +29 -29
  6. data/lib/remarkable/active_record/README.markdown +378 -0
  7. data/lib/remarkable/active_record/active_record.rb +12 -11
  8. data/lib/remarkable/active_record/helpers.rb +215 -5
  9. data/lib/remarkable/active_record/macros/associations/association_matcher.rb +242 -0
  10. data/lib/remarkable/active_record/macros/callbacks/callback_matcher.rb +46 -0
  11. data/lib/remarkable/active_record/macros/database/column_matcher.rb +122 -0
  12. data/lib/remarkable/active_record/macros/database/index_matcher.rb +103 -0
  13. data/lib/remarkable/active_record/macros/validations/allow_mass_assignment_of_matcher.rb +52 -0
  14. data/lib/remarkable/active_record/macros/validations/ensure_value_in_list_matcher.rb +83 -0
  15. data/lib/remarkable/active_record/macros/validations/ensure_value_in_range_matcher.rb +172 -0
  16. data/lib/remarkable/active_record/macros/validations/have_class_methods_matcher.rb +54 -0
  17. data/lib/remarkable/active_record/macros/validations/have_instance_methods_matcher.rb +54 -0
  18. data/lib/remarkable/active_record/macros/validations/have_named_scope_matcher.rb +94 -0
  19. data/lib/remarkable/active_record/macros/validations/have_readonly_attributes_matcher.rb +48 -0
  20. data/lib/remarkable/active_record/macros/validations/protect_attributes_matcher.rb +51 -0
  21. data/lib/remarkable/active_record/macros/validations/validate_acceptance_of_matcher.rb +79 -0
  22. data/lib/remarkable/active_record/macros/validations/validate_associated_matcher.rb +177 -0
  23. data/lib/remarkable/active_record/macros/validations/validate_confirmation_of_matcher.rb +74 -0
  24. data/lib/remarkable/active_record/macros/validations/validate_exclusion_of_matcher.rb +38 -0
  25. data/lib/remarkable/active_record/macros/validations/validate_format_of_matcher.rb +33 -0
  26. data/lib/remarkable/active_record/macros/validations/validate_inclusion_of_matcher.rb +45 -0
  27. data/lib/remarkable/active_record/macros/validations/validate_length_of_matcher.rb +248 -0
  28. data/lib/remarkable/active_record/macros/validations/validate_numericality_of_matcher.rb +206 -0
  29. data/lib/remarkable/active_record/macros/validations/validate_presence_of_matcher.rb +72 -0
  30. data/lib/remarkable/active_record/macros/validations/validate_uniqueness_of_matcher.rb +222 -0
  31. data/lib/remarkable/active_record/macros.rb +52 -0
  32. data/lib/remarkable/assertions.rb +29 -0
  33. data/lib/remarkable/controller/README.markdown +147 -0
  34. data/lib/remarkable/controller/controller.rb +11 -6
  35. data/lib/remarkable/controller/helpers.rb +4 -38
  36. data/lib/remarkable/controller/macros/assign_matcher.rb +85 -0
  37. data/lib/remarkable/controller/macros/filter_params_matcher.rb +63 -0
  38. data/lib/remarkable/controller/macros/metadata_matcher.rb +63 -0
  39. data/lib/remarkable/controller/macros/render_with_layout_matcher.rb +75 -0
  40. data/lib/remarkable/controller/macros/respond_with_content_type_matcher.rb +60 -0
  41. data/lib/remarkable/controller/macros/respond_with_matcher.rb +62 -0
  42. data/lib/remarkable/controller/macros/return_from_session_matcher.rb +58 -0
  43. data/lib/remarkable/controller/macros/route_matcher.rb +75 -0
  44. data/lib/remarkable/controller/macros/set_the_flash_to_matcher.rb +60 -0
  45. data/lib/remarkable/controller/macros.rb +78 -0
  46. data/lib/remarkable/dsl.rb +239 -0
  47. data/lib/remarkable/example/example_methods.rb +27 -7
  48. data/lib/remarkable/helpers.rb +28 -0
  49. data/lib/remarkable/matcher_base.rb +64 -0
  50. data/lib/remarkable/private_helpers.rb +10 -115
  51. data/lib/remarkable/rails.rb +27 -0
  52. data/lib/remarkable.rb +13 -5
  53. data/remarkable.gemspec +43 -0
  54. data/spec/controllers/posts_controller_spec.rb +58 -4
  55. data/spec/controllers/users_controller_spec.rb +1 -0
  56. data/spec/fixtures/fleas.yml +10 -0
  57. data/spec/fixtures/users.yml +7 -0
  58. data/spec/models/address_spec.rb +44 -0
  59. data/spec/models/dog_spec.rb +64 -3
  60. data/spec/models/flea_spec.rb +30 -0
  61. data/spec/models/post_spec.rb +36 -2
  62. data/spec/models/product_spec.rb +73 -8
  63. data/spec/models/tag_spec.rb +2 -2
  64. data/spec/models/tagging_spec.rb +24 -0
  65. data/spec/models/user_spec.rb +206 -21
  66. data/spec/other/custom_macros_spec.rb +27 -0
  67. data/spec/other/my_own_matcher_spec.rb +11 -0
  68. data/spec/other/private_helpers_spec.rb +31 -0
  69. data/spec/rails_root/app/controllers/posts_controller.rb +2 -0
  70. data/spec/rails_root/app/models/address.rb +2 -2
  71. data/spec/rails_root/app/models/flea.rb +4 -0
  72. data/spec/rails_root/app/models/pets/dog.rb +12 -0
  73. data/spec/rails_root/app/models/product.rb +7 -5
  74. data/spec/rails_root/app/models/tagging.rb +2 -0
  75. data/spec/rails_root/app/models/user.rb +20 -5
  76. data/spec/rails_root/app/views/layouts/posts.rhtml +8 -6
  77. data/spec/rails_root/config/database.yml +1 -2
  78. data/spec/rails_root/config/environment.rb +3 -1
  79. data/spec/rails_root/config/environments/{sqlite3.rb → test.rb} +0 -0
  80. data/spec/rails_root/config/locales/en.yml +8 -0
  81. data/spec/rails_root/db/migrate/001_create_users.rb +2 -2
  82. data/spec/rails_root/db/migrate/005_create_dogs.rb +1 -0
  83. data/spec/rails_root/db/migrate/011_add_fleas_color.rb +10 -0
  84. data/spec/rails_root/db/migrate/012_add_fleas_address.rb +10 -0
  85. data/spec/rails_root/spec/remarkable_macros/.keep +0 -0
  86. data/spec/rails_root/vendor/plugins/my_plugin/remarkable_macros/.keep +0 -0
  87. data/spec/spec_helper.rb +0 -2
  88. metadata +63 -43
  89. data/lib/remarkable/active_record/macros/associations/belong_to.rb +0 -81
  90. data/lib/remarkable/active_record/macros/associations/have_and_belong_to_many.rb +0 -77
  91. data/lib/remarkable/active_record/macros/associations/have_many.rb +0 -160
  92. data/lib/remarkable/active_record/macros/associations/have_one.rb +0 -133
  93. data/lib/remarkable/active_record/macros/database/have_db_column.rb +0 -81
  94. data/lib/remarkable/active_record/macros/database/have_db_columns.rb +0 -73
  95. data/lib/remarkable/active_record/macros/database/have_indices.rb +0 -75
  96. data/lib/remarkable/active_record/macros/validations/allow_values_for.rb +0 -103
  97. data/lib/remarkable/active_record/macros/validations/ensure_length_at_least.rb +0 -97
  98. data/lib/remarkable/active_record/macros/validations/ensure_length_in_range.rb +0 -134
  99. data/lib/remarkable/active_record/macros/validations/ensure_length_is.rb +0 -106
  100. data/lib/remarkable/active_record/macros/validations/ensure_value_in_range.rb +0 -117
  101. data/lib/remarkable/active_record/macros/validations/have_class_methods.rb +0 -74
  102. data/lib/remarkable/active_record/macros/validations/have_instance_methods.rb +0 -74
  103. data/lib/remarkable/active_record/macros/validations/have_named_scope.rb +0 -148
  104. data/lib/remarkable/active_record/macros/validations/have_readonly_attributes.rb +0 -81
  105. data/lib/remarkable/active_record/macros/validations/only_allow_numeric_values_for.rb +0 -89
  106. data/lib/remarkable/active_record/macros/validations/protect_attributes.rb +0 -89
  107. data/lib/remarkable/active_record/macros/validations/require_acceptance_of.rb +0 -94
  108. data/lib/remarkable/active_record/macros/validations/require_attributes.rb +0 -94
  109. data/lib/remarkable/active_record/macros/validations/require_unique_attributes.rb +0 -146
  110. data/lib/remarkable/controller/macros/assign_to.rb +0 -110
  111. data/lib/remarkable/controller/macros/filter_params.rb +0 -52
  112. data/lib/remarkable/controller/macros/redirect_to.rb +0 -24
  113. data/lib/remarkable/controller/macros/render_a_form.rb +0 -23
  114. data/lib/remarkable/controller/macros/render_template.rb +0 -18
  115. data/lib/remarkable/controller/macros/render_with_layout.rb +0 -61
  116. data/lib/remarkable/controller/macros/respond_with.rb +0 -86
  117. data/lib/remarkable/controller/macros/respond_with_content_type.rb +0 -45
  118. data/lib/remarkable/controller/macros/return_from_session.rb +0 -45
  119. data/lib/remarkable/controller/macros/route.rb +0 -91
  120. data/lib/remarkable/controller/macros/set_the_flash_to.rb +0 -58
  121. data/spec/rails_root/app/models/dog.rb +0 -5
@@ -1,91 +0,0 @@
1
- module Remarkable
2
- module Syntax
3
-
4
- module RSpec
5
- # Macro that creates a routing test. It tries to use the given HTTP
6
- # +method+ on the given +path+, and asserts that it routes to the
7
- # given +options+.
8
- #
9
- # +to_param+ is called on the +options+ given.
10
- #
11
- # Examples:
12
- #
13
- # it { should route(:get, "/posts", :controller => :posts, :action => :index) }
14
- # it { should route(:get, "/posts/new", :controller => :posts, :action => :new) }
15
- # it { should route(:post, "/posts", :controller => :posts, :action => :create) }
16
- # it { should route(:get, "/posts/1", :controller => :posts, :action => :show, :id => 1) }
17
- # it { should route(:edit, "/posts/1", :controller => :posts, :action => :show, :id => 1) }
18
- # it { should route(:put, "/posts/1", :controller => :posts, :action => :update, :id => 1) }
19
- # it { should route(:delete, "/posts/1", :controller => :posts, :action => :destroy, :id => 1) }
20
- # it do
21
- # should route :get, "/users/1/posts/1", :controller => :posts, :action => :show, :id => 1, :user_id => 1
22
- # end
23
- #
24
- def route(method, path, options)
25
- simple_matcher "route #{method.to_s.upcase} #{path} to/from #{options.inspect}" do |controller|
26
- unless options[:controller]
27
- options[:controller] = controller.name.gsub(/Controller$/, '').tableize
28
- end
29
- options[:controller] = options[:controller].to_s
30
- options[:action] = options[:action].to_s
31
-
32
- populated_path = path.dup
33
- options.each do |key, value|
34
- options[key] = value.to_param if value.respond_to? :to_param
35
- populated_path.gsub!(key.inspect, value.to_s)
36
- end
37
-
38
- route_for(options).should == populated_path && params_from(method.to_sym, populated_path).should == options
39
- end
40
- end
41
- end
42
-
43
- module Shoulda
44
- # Macro that creates a routing test. It tries to use the given HTTP
45
- # +method+ on the given +path+, and asserts that it routes to the
46
- # given +options+.
47
- #
48
- # +to_param+ is called on the +options+ given.
49
- #
50
- # Examples:
51
- #
52
- # should_route :get, "/posts", :controller => :posts, :action => :index
53
- # should_route :get, "/posts/new", :controller => :posts, :action => :new
54
- # should_route :post, "/posts", :controller => :posts, :action => :create
55
- # should_route :get, "/posts/1", :controller => :posts, :action => :show, :id => 1
56
- # should_route :edit, "/posts/1", :controller => :posts, :action => :show, :id => 1
57
- # should_route :put, "/posts/1", :controller => :posts, :action => :update, :id => 1
58
- # should_route :delete, "/posts/1", :controller => :posts, :action => :destroy, :id => 1
59
- # should_route :get, "/users/1/posts/1",
60
- # :controller => :posts, :action => :show, :id => 1, :user_id => 1
61
- #
62
- def should_route(method, path, options)
63
- populated_path = path.dup
64
-
65
- unless options[:controller]
66
- it "should explicitly specify :controller" do
67
- options[:controller].should_not be_nil
68
- end
69
- return
70
- end
71
-
72
- options[:controller] = options[:controller].to_s
73
- options[:action] = options[:action].to_s
74
-
75
- options.each do |key, value|
76
- options[key] = value.to_param if value.respond_to? :to_param
77
- populated_path.gsub!(key.inspect, value.to_s)
78
- end
79
-
80
- it "should map #{options.inspect} to #{path.inspect}" do
81
- route_for(options).should == populated_path
82
- end
83
-
84
- it "should generate params #{options.inspect} from #{method.to_s.upcase} to #{path.inspect}" do
85
- params_from(method.to_sym, populated_path).should == options
86
- end
87
- end
88
- end
89
-
90
- end
91
- end
@@ -1,58 +0,0 @@
1
- module Remarkable
2
- module Syntax
3
-
4
- module RSpec
5
- # Macro that creates a test asserting that the flash contains the given value.
6
- # val can be a String, a Regex, or nil (indicating that the flash should not be set)
7
- #
8
- # Example:
9
- #
10
- # should_set_the_flash_to "Thank you for placing this order."
11
- # should_set_the_flash_to /created/i
12
- # should_set_the_flash_to nil
13
- #
14
- def set_the_flash_to(val = nil)
15
- if val
16
- simple_matcher "should have #{val.inspect} in the flash" do
17
- assert_contains(flash.values, val)
18
- end
19
- else
20
- simple_matcher "should not set the flash" do
21
- assert_equal({}, flash)
22
- end
23
- end
24
- end
25
- alias_method :set_the_flash, :set_the_flash_to
26
- end
27
-
28
- module Shoulda
29
- # Macro that creates a test asserting that the flash contains the given value.
30
- # val can be a String, a Regex, or nil (indicating that the flash should not be set)
31
- #
32
- # Example:
33
- #
34
- # should_set_the_flash_to "Thank you for placing this order."
35
- # should_set_the_flash_to /created/i
36
- # should_set_the_flash_to nil
37
- #
38
- def should_set_the_flash_to(val)
39
- if val
40
- it "should have #{val.inspect} in the flash" do
41
- assert_contains(flash.values, val)
42
- end
43
- else
44
- it "should not set the flash" do
45
- assert_equal({}, flash)
46
- end
47
- end
48
- end
49
-
50
- # Macro that creates a test asserting that the flash is empty. Same as
51
- # @should_set_the_flash_to nil@
52
- def should_not_set_the_flash
53
- should_set_the_flash_to nil
54
- end
55
- end
56
-
57
- end
58
- end
@@ -1,5 +0,0 @@
1
- class Dog < ActiveRecord::Base
2
- belongs_to :user, :foreign_key => :owner_id
3
- belongs_to :address
4
- has_and_belongs_to_many :fleas, :join_table => :fleas
5
- end