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
@@ -2,11 +2,13 @@ class Product < ActiveRecord::Base
2
2
  validates_presence_of :title
3
3
 
4
4
  validates_inclusion_of :price, :in => 0..99, :unless => :tangible
5
+ validates_exclusion_of :weight, :in => 10..100, :unless => :tangible
5
6
  validates_format_of :size, :with => /^\d+\D+$/, :unless => :tangible
6
7
 
7
- validates_presence_of :price, :if => :tangible
8
- validates_inclusion_of :price, :in => 1..9999, :if => :tangible
9
- validates_inclusion_of :weight, :in => 1..100, :if => :tangible
10
- validates_format_of :size, :with => /.+x.+x.+/, :if => :tangible
11
- validates_length_of :size, :in => 5..20, :if => :tangible
8
+ validates_presence_of :price, :if => :tangible
9
+ validates_inclusion_of :price, :in => 1..9999, :if => :tangible, :allow_nil => true
10
+ validates_inclusion_of :weight, :in => 1..100, :if => :tangible, :allow_blank => true
11
+ validates_inclusion_of :size, :in => %w(S M L XL), :if => :tangible, :allow_blank => true
12
+ validates_exclusion_of :size, :in => %w(XS XM), :if => :tangible
13
+ validates_length_of :size, :in => 5..20, :if => :tangible, :allow_blank => true
12
14
  end
@@ -1,4 +1,6 @@
1
1
  class Tagging < ActiveRecord::Base
2
2
  belongs_to :post
3
3
  belongs_to :tag
4
+
5
+ validates_associated :post, :tag
4
6
  end
@@ -1,12 +1,14 @@
1
1
  class User < ActiveRecord::Base
2
2
  has_many :posts
3
- has_many :dogs, :foreign_key => :owner_id
3
+ has_many :dogs, :foreign_key => :owner_id, :class_name => "Pets::Dog", :validate => false
4
4
 
5
5
  has_many :friendships
6
6
  has_many :friends, :through => :friendships
7
7
 
8
8
  has_one :address, :as => :addressable, :dependent => :destroy
9
9
 
10
+ validates_associated :address, :posts
11
+
10
12
  named_scope :old, :conditions => "age > 50"
11
13
  named_scope :eighteen, :conditions => { :age => 18 }
12
14
  named_scope :recent, lambda {|count| { :limit => count } }
@@ -15,14 +17,27 @@ class User < ActiveRecord::Base
15
17
  scoped(:limit => count)
16
18
  end
17
19
 
20
+ attr_accessor :username, :username_confirmation, :terms
18
21
  attr_protected :password
19
22
  attr_readonly :name
20
23
 
21
24
  validates_format_of :email, :with => /\w*@\w*.com/
22
- validates_length_of :email, :in => 1..100
23
- validates_inclusion_of :age, :in => 1..100
24
- validates_acceptance_of :eula
25
+ validates_length_of :email, :in => 2..100, :allow_nil => false, :allow_blank => false
25
26
  validates_uniqueness_of :email, :scope => :name
27
+
28
+ validates_inclusion_of :age, :in => 2..100
29
+
26
30
  validates_length_of :ssn, :is => 9, :message => "Social Security Number is not the right length"
27
- validates_numericality_of :ssn
31
+ validates_numericality_of :ssn, :equal_to => 123456789
32
+
33
+ validates_acceptance_of :eula
34
+ validates_acceptance_of :terms, :allow_nil => false, :accept => true
35
+
36
+ validates_confirmation_of :username, :email
37
+
38
+ after_create :send_welcome_email
39
+ before_validation_on_update :some_weird_callback
40
+
41
+ def send_welcome_email; end
42
+ def some_weird_callback; end
28
43
  end
@@ -1,17 +1,19 @@
1
1
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
-
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
4
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
5
  <head>
6
6
  <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7
+ <meta name="description" content="Posts, posts and more posts" />
8
+ <meta name='keywords' content='posts' />
7
9
  <title>Posts: <%= controller.action_name %></title>
8
10
  <%= stylesheet_link_tag 'scaffold' %>
9
11
  </head>
10
12
  <body>
11
-
13
+
12
14
  <p style="color: green"><%= flash[:notice] %></p>
13
-
14
- <%= yield %>
15
-
15
+
16
+ <%= yield %>
17
+
16
18
  </body>
17
19
  </html>
@@ -1,4 +1,3 @@
1
- sqlite3:
1
+ test:
2
2
  :adapter: sqlite3
3
- # :dbfile: db/sqlite3.db
4
3
  :dbfile: ":memory:"
@@ -1,6 +1,8 @@
1
1
  # Specifies gem version of Rails to use when vendor/rails is not present
2
+ ENV['RAILS_ENV'] = 'test'
3
+
2
4
  old_verbose, $VERBOSE = $VERBOSE, nil
3
- RAILS_GEM_VERSION = '>= 2.1.0' unless defined? RAILS_GEM_VERSION
5
+ RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION
4
6
  $VERBOSE = old_verbose
5
7
 
6
8
  require File.join(File.dirname(__FILE__), 'boot')
@@ -0,0 +1,8 @@
1
+ en:
2
+ activerecord:
3
+ errors:
4
+ models:
5
+ user:
6
+ attributes:
7
+ email:
8
+ invalid: 'Please, give me a valid e-mail address.'
@@ -6,10 +6,10 @@ class CreateUsers < ActiveRecord::Migration
6
6
  t.column :age, :integer
7
7
  t.column :ssn, :string
8
8
  end
9
- add_index :users, :email
9
+ add_index :users, :email, :unique => true
10
10
  add_index :users, :name
11
11
  add_index :users, :age
12
- add_index :users, [:email, :name]
12
+ add_index :users, [:email, :name], :unique => true
13
13
  end
14
14
 
15
15
  def self.down
@@ -3,6 +3,7 @@ class CreateDogs < ActiveRecord::Migration
3
3
  create_table :dogs do |t|
4
4
  t.column :owner_id, :integer
5
5
  t.column :address_id, :integer
6
+ t.column :age, :integer
6
7
  end
7
8
  end
8
9
 
@@ -0,0 +1,10 @@
1
+ class AddFleasColor < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :fleas, :color, :string
4
+
5
+ end
6
+
7
+ def self.down
8
+ remove_column :fleas, :color
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ class AddFleasAddress < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :fleas, :address, :string
4
+
5
+ end
6
+
7
+ def self.down
8
+ remove_column :fleas, :address
9
+ end
10
+ end
File without changes
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  # This file is copied to ~/spec when you run 'ruby script/generate rspec'
2
2
  # from the project root directory.
3
- ENV['RAILS_ENV'] = 'sqlite3'
4
-
5
3
  RAILS_ROOT = File.dirname(__FILE__) + '/rails_root'
6
4
 
7
5
  require "#{RAILS_ROOT}/config/environment.rb"
metadata CHANGED
@@ -1,15 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carlosbrando-remarkable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.99
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Brando
8
+ - Diego Carrion
9
+ - "Jos\xC3\xA9 Valim"
8
10
  autorequire:
9
11
  bindir: bin
10
12
  cert_chain: []
11
13
 
12
- date: 2008-11-12 00:00:00 -08:00
14
+ date: 2009-02-10 00:00:00 -08:00
13
15
  default_executable:
14
16
  dependencies:
15
17
  - !ruby/object:Gem::Dependency
@@ -19,7 +21,7 @@ dependencies:
19
21
  requirements:
20
22
  - - ">="
21
23
  - !ruby/object:Gem::Version
22
- version: 1.1.11
24
+ version: 1.1.12
23
25
  version:
24
26
  - !ruby/object:Gem::Dependency
25
27
  name: rspec-rails
@@ -28,7 +30,7 @@ dependencies:
28
30
  requirements:
29
31
  - - ">="
30
32
  - !ruby/object:Gem::Version
31
- version: 1.1.11
33
+ version: 1.1.12
32
34
  version:
33
35
  - !ruby/object:Gem::Dependency
34
36
  name: newgem
@@ -37,7 +39,7 @@ dependencies:
37
39
  requirements:
38
40
  - - ">="
39
41
  - !ruby/object:Gem::Version
40
- version: 1.1.0
42
+ version: 1.2.3
41
43
  version:
42
44
  - !ruby/object:Gem::Dependency
43
45
  name: hoe
@@ -48,7 +50,7 @@ dependencies:
48
50
  - !ruby/object:Gem::Version
49
51
  version: 1.8.0
50
52
  version:
51
- description: FIX (describe your package)
53
+ description: Remarkable is a framework for Rspec matchers.
52
54
  email:
53
55
  - eduardobrando@gmail.com
54
56
  executables: []
@@ -68,51 +70,61 @@ files:
68
70
  - Rakefile
69
71
  - init.rb
70
72
  - lib/remarkable.rb
73
+ - lib/remarkable/active_record/README.markdown
71
74
  - lib/remarkable/active_record/active_record.rb
72
75
  - lib/remarkable/active_record/helpers.rb
73
- - lib/remarkable/active_record/macros/associations/belong_to.rb
74
- - lib/remarkable/active_record/macros/associations/have_and_belong_to_many.rb
75
- - lib/remarkable/active_record/macros/associations/have_many.rb
76
- - lib/remarkable/active_record/macros/associations/have_one.rb
77
- - lib/remarkable/active_record/macros/database/have_db_column.rb
78
- - lib/remarkable/active_record/macros/database/have_db_columns.rb
79
- - lib/remarkable/active_record/macros/database/have_indices.rb
80
- - lib/remarkable/active_record/macros/validations/allow_values_for.rb
81
- - lib/remarkable/active_record/macros/validations/ensure_length_at_least.rb
82
- - lib/remarkable/active_record/macros/validations/ensure_length_in_range.rb
83
- - lib/remarkable/active_record/macros/validations/ensure_length_is.rb
84
- - lib/remarkable/active_record/macros/validations/ensure_value_in_range.rb
85
- - lib/remarkable/active_record/macros/validations/have_class_methods.rb
86
- - lib/remarkable/active_record/macros/validations/have_instance_methods.rb
87
- - lib/remarkable/active_record/macros/validations/have_named_scope.rb
88
- - lib/remarkable/active_record/macros/validations/have_readonly_attributes.rb
89
- - lib/remarkable/active_record/macros/validations/only_allow_numeric_values_for.rb
90
- - lib/remarkable/active_record/macros/validations/protect_attributes.rb
91
- - lib/remarkable/active_record/macros/validations/require_acceptance_of.rb
92
- - lib/remarkable/active_record/macros/validations/require_attributes.rb
93
- - lib/remarkable/active_record/macros/validations/require_unique_attributes.rb
76
+ - lib/remarkable/active_record/macros.rb
77
+ - lib/remarkable/active_record/macros/associations/association_matcher.rb
78
+ - lib/remarkable/active_record/macros/callbacks/callback_matcher.rb
79
+ - lib/remarkable/active_record/macros/database/column_matcher.rb
80
+ - lib/remarkable/active_record/macros/database/index_matcher.rb
81
+ - lib/remarkable/active_record/macros/validations/allow_mass_assignment_of_matcher.rb
82
+ - lib/remarkable/active_record/macros/validations/ensure_value_in_list_matcher.rb
83
+ - lib/remarkable/active_record/macros/validations/ensure_value_in_range_matcher.rb
84
+ - lib/remarkable/active_record/macros/validations/have_class_methods_matcher.rb
85
+ - lib/remarkable/active_record/macros/validations/have_instance_methods_matcher.rb
86
+ - lib/remarkable/active_record/macros/validations/have_named_scope_matcher.rb
87
+ - lib/remarkable/active_record/macros/validations/have_readonly_attributes_matcher.rb
88
+ - lib/remarkable/active_record/macros/validations/protect_attributes_matcher.rb
89
+ - lib/remarkable/active_record/macros/validations/validate_acceptance_of_matcher.rb
90
+ - lib/remarkable/active_record/macros/validations/validate_associated_matcher.rb
91
+ - lib/remarkable/active_record/macros/validations/validate_confirmation_of_matcher.rb
92
+ - lib/remarkable/active_record/macros/validations/validate_exclusion_of_matcher.rb
93
+ - lib/remarkable/active_record/macros/validations/validate_format_of_matcher.rb
94
+ - lib/remarkable/active_record/macros/validations/validate_inclusion_of_matcher.rb
95
+ - lib/remarkable/active_record/macros/validations/validate_length_of_matcher.rb
96
+ - lib/remarkable/active_record/macros/validations/validate_numericality_of_matcher.rb
97
+ - lib/remarkable/active_record/macros/validations/validate_presence_of_matcher.rb
98
+ - lib/remarkable/active_record/macros/validations/validate_uniqueness_of_matcher.rb
99
+ - lib/remarkable/assertions.rb
100
+ - lib/remarkable/controller/README.markdown
94
101
  - lib/remarkable/controller/controller.rb
95
102
  - lib/remarkable/controller/helpers.rb
96
- - lib/remarkable/controller/macros/assign_to.rb
97
- - lib/remarkable/controller/macros/filter_params.rb
98
- - lib/remarkable/controller/macros/redirect_to.rb
99
- - lib/remarkable/controller/macros/render_a_form.rb
100
- - lib/remarkable/controller/macros/render_template.rb
101
- - lib/remarkable/controller/macros/render_with_layout.rb
102
- - lib/remarkable/controller/macros/respond_with.rb
103
- - lib/remarkable/controller/macros/respond_with_content_type.rb
104
- - lib/remarkable/controller/macros/return_from_session.rb
105
- - lib/remarkable/controller/macros/route.rb
106
- - lib/remarkable/controller/macros/set_the_flash_to.rb
103
+ - lib/remarkable/controller/macros.rb
104
+ - lib/remarkable/controller/macros/assign_matcher.rb
105
+ - lib/remarkable/controller/macros/filter_params_matcher.rb
106
+ - lib/remarkable/controller/macros/metadata_matcher.rb
107
+ - lib/remarkable/controller/macros/render_with_layout_matcher.rb
108
+ - lib/remarkable/controller/macros/respond_with_content_type_matcher.rb
109
+ - lib/remarkable/controller/macros/respond_with_matcher.rb
110
+ - lib/remarkable/controller/macros/return_from_session_matcher.rb
111
+ - lib/remarkable/controller/macros/route_matcher.rb
112
+ - lib/remarkable/controller/macros/set_the_flash_to_matcher.rb
113
+ - lib/remarkable/dsl.rb
107
114
  - lib/remarkable/example/example_methods.rb
115
+ - lib/remarkable/helpers.rb
116
+ - lib/remarkable/matcher_base.rb
108
117
  - lib/remarkable/private_helpers.rb
118
+ - lib/remarkable/rails.rb
109
119
  - rails/init.rb
120
+ - remarkable.gemspec
110
121
  - script/console
111
122
  - script/destroy
112
123
  - script/generate
113
124
  - spec/controllers/posts_controller_spec.rb
114
125
  - spec/controllers/users_controller_spec.rb
115
126
  - spec/fixtures/addresses.yml
127
+ - spec/fixtures/fleas.yml
116
128
  - spec/fixtures/friendships.yml
117
129
  - spec/fixtures/posts.yml
118
130
  - spec/fixtures/products.yml
@@ -128,6 +140,9 @@ files:
128
140
  - spec/models/tag_spec.rb
129
141
  - spec/models/tagging_spec.rb
130
142
  - spec/models/user_spec.rb
143
+ - spec/other/custom_macros_spec.rb
144
+ - spec/other/my_own_matcher_spec.rb
145
+ - spec/other/private_helpers_spec.rb
131
146
  - spec/rails_root/app/controllers/application.rb
132
147
  - spec/rails_root/app/controllers/posts_controller.rb
133
148
  - spec/rails_root/app/controllers/users_controller.rb
@@ -135,9 +150,9 @@ files:
135
150
  - spec/rails_root/app/helpers/posts_helper.rb
136
151
  - spec/rails_root/app/helpers/users_helper.rb
137
152
  - spec/rails_root/app/models/address.rb
138
- - spec/rails_root/app/models/dog.rb
139
153
  - spec/rails_root/app/models/flea.rb
140
154
  - spec/rails_root/app/models/friendship.rb
155
+ - spec/rails_root/app/models/pets/dog.rb
141
156
  - spec/rails_root/app/models/post.rb
142
157
  - spec/rails_root/app/models/product.rb
143
158
  - spec/rails_root/app/models/tag.rb
@@ -157,9 +172,10 @@ files:
157
172
  - spec/rails_root/config/boot.rb
158
173
  - spec/rails_root/config/database.yml
159
174
  - spec/rails_root/config/environment.rb
160
- - spec/rails_root/config/environments/sqlite3.rb
175
+ - spec/rails_root/config/environments/test.rb
161
176
  - spec/rails_root/config/initializers/new_rails_defaults.rb
162
177
  - spec/rails_root/config/initializers/shoulda.rb
178
+ - spec/rails_root/config/locales/en.yml
163
179
  - spec/rails_root/config/routes.rb
164
180
  - spec/rails_root/db/migrate/001_create_users.rb
165
181
  - spec/rails_root/db/migrate/002_create_posts.rb
@@ -171,22 +187,26 @@ files:
171
187
  - spec/rails_root/db/migrate/008_create_dogs_fleas.rb
172
188
  - spec/rails_root/db/migrate/009_create_products.rb
173
189
  - spec/rails_root/db/migrate/010_create_friendships.rb
190
+ - spec/rails_root/db/migrate/011_add_fleas_color.rb
191
+ - spec/rails_root/db/migrate/012_add_fleas_address.rb
174
192
  - spec/rails_root/db/schema.rb
175
193
  - spec/rails_root/log/.keep
176
- - spec/rails_root/log/sqlite3.log
194
+ - spec/rails_root/log/test.log
177
195
  - spec/rails_root/public/.htaccess
178
196
  - spec/rails_root/public/404.html
179
197
  - spec/rails_root/public/422.html
180
198
  - spec/rails_root/public/500.html
181
199
  - spec/rails_root/script/console
182
200
  - spec/rails_root/script/generate
201
+ - spec/rails_root/spec/remarkable_macros/.keep
183
202
  - spec/rails_root/vendor/plugins/.keep
203
+ - spec/rails_root/vendor/plugins/my_plugin/remarkable_macros/.keep
184
204
  - spec/rcov.opts
185
205
  - spec/spec.opts
186
206
  - spec/spec_helper.rb
187
207
  - tasks/rspec.rake
188
208
  has_rdoc: true
189
- homepage: http://www.nomedojogo.com
209
+ homepage:
190
210
  post_install_message: PostInstall.txt
191
211
  rdoc_options:
192
212
  - --main
@@ -211,6 +231,6 @@ rubyforge_project: remarkable
211
231
  rubygems_version: 1.2.0
212
232
  signing_key:
213
233
  specification_version: 2
214
- summary: FIX (describe your package)
234
+ summary: Remarkable is a framework for Rspec matchers.
215
235
  test_files: []
216
236
 
@@ -1,81 +0,0 @@
1
- module Remarkable
2
- module Syntax
3
-
4
- module RSpec
5
- class BelongTo
6
- include Remarkable::Private
7
-
8
- def initialize(*associations)
9
- get_options!(associations)
10
- @associations = associations
11
- end
12
-
13
- def matches?(klass)
14
- @klass = klass
15
-
16
- begin
17
- @associations.each do |association|
18
- reflection = klass.reflect_on_association(association)
19
- fail("#{klass.name} does not have any relationship to #{association}") unless reflection && reflection.macro == :belongs_to
20
-
21
- unless reflection.options[:polymorphic]
22
- associated_klass = (reflection.options[:class_name] || association.to_s.camelize).constantize
23
- fk = reflection.options[:foreign_key] || reflection.primary_key_name
24
- fail("#{klass.name} does not have a #{fk} foreign key.") unless klass.column_names.include?(fk.to_s)
25
- end
26
- end
27
-
28
- true
29
- rescue Exception => e
30
- false
31
- end
32
- end
33
-
34
- def description
35
- "belong to #{@associations.to_sentence}"
36
- end
37
-
38
- def failure_message
39
- @failure_message || "expected #{@klass.name} to belong to #{@associations.to_sentence}, but it didn't"
40
- end
41
-
42
- def negative_failure_message
43
- "expected #{@klass.name} not to belong to #{@associations.to_sentence}, but it did"
44
- end
45
- end
46
-
47
- # Ensure that the belongs_to relationship exists.
48
- #
49
- # it { Post.should belong_to(:user) }
50
- #
51
- def belong_to(*associations)
52
- Remarkable::Syntax::RSpec::BelongTo.new(*associations)
53
- end
54
- end
55
-
56
- module Shoulda
57
- # Ensure that the belongs_to relationship exists.
58
- #
59
- # should_belong_to :parent
60
- #
61
- def should_belong_to(*associations)
62
- get_options!(associations)
63
- klass = model_class
64
- associations.each do |association|
65
- it "should belong to #{association}" do
66
- reflection = klass.reflect_on_association(association)
67
- fail_with("#{klass.name} does not have any relationship to #{association}") unless reflection
68
- reflection.macro.should == :belongs_to
69
-
70
- unless reflection.options[:polymorphic]
71
- associated_klass = (reflection.options[:class_name] || association.to_s.camelize).constantize
72
- fk = reflection.options[:foreign_key] || reflection.primary_key_name
73
- fail_with("#{klass.name} does not have a #{fk} foreign key.") unless klass.column_names.include?(fk.to_s)
74
- end
75
- end
76
- end
77
- end
78
- end
79
-
80
- end
81
- end
@@ -1,77 +0,0 @@
1
- module Remarkable
2
- module Syntax
3
-
4
- module RSpec
5
- class HaveAndBelongToMany
6
- include Remarkable::Private
7
-
8
- def initialize(*associations)
9
- get_options!(associations)
10
- @associations = associations
11
- end
12
-
13
- def matches?(klass)
14
- @klass = klass
15
-
16
- begin
17
- @associations.each do |association|
18
- reflection = klass.reflect_on_association(association)
19
- fail("#{klass.name} does not have any relationship to #{association}") unless reflection && reflection.macro == :has_and_belongs_to_many
20
-
21
- table = reflection.options[:join_table]
22
- fail("table #{table} doesn't exist") unless ::ActiveRecord::Base.connection.tables.include?(table.to_s)
23
- end
24
-
25
- true
26
- rescue Exception => e
27
- false
28
- end
29
- end
30
-
31
- def description
32
- "should have and belong to many #{@associations.to_sentence}"
33
- end
34
-
35
- def failure_message
36
- @failure_message || "expected #{@klass.name} to have and belong to many #{@associations.to_sentence}, but it didn't"
37
- end
38
-
39
- def negative_failure_message
40
- "expected #{@klass.name} not to have and belong to many #{@associations.to_sentence}, but it did"
41
- end
42
- end
43
-
44
- # Ensures that the has_and_belongs_to_many relationship exists, and that the join
45
- # table is in place.
46
- #
47
- # it { User.should have_and_belong_to_many(:posts, :cars) }
48
- #
49
- def have_and_belong_to_many(*associations)
50
- Remarkable::Syntax::RSpec::HaveAndBelongToMany.new(*associations)
51
- end
52
- end
53
-
54
- module Shoulda
55
- # Ensures that the has_and_belongs_to_many relationship exists, and that the join
56
- # table is in place.
57
- #
58
- # should_have_and_belong_to_many :posts, :cars
59
- #
60
- def should_have_and_belong_to_many(*associations)
61
- get_options!(associations)
62
- klass = model_class
63
-
64
- associations.each do |association|
65
- it "should have and belong to many #{association}" do
66
- reflection = klass.reflect_on_association(association)
67
- fail_with("#{klass.name} does not have any relationship to #{association}") unless reflection
68
- reflection.macro.should == :has_and_belongs_to_many
69
- table = reflection.options[:join_table]
70
- fail_with("table #{table} doesn't exist") unless ::ActiveRecord::Base.connection.tables.include?(table.to_s)
71
- end
72
- end
73
- end
74
- end
75
-
76
- end
77
- end