remockable 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.markdown ADDED
@@ -0,0 +1,46 @@
1
+ # Remockable
2
+
3
+ A collection of RSpec 2 matchers to simplify your web app specs.
4
+
5
+
6
+ ## Background
7
+
8
+ The goal of this project is to provide a modern replacement to the now
9
+ unmaintained Remarkable project. Remarkable was a great asset when Rails 2.3
10
+ was current, but now that Rails 3.0 has become mainstream, a gap has been left
11
+ by still unreleased Remarkable 4.0.
12
+
13
+ In looking at the code for Remarkable to determine the feasibility of continuing
14
+ work on Remarkable itself, it seems clear that the scope of that project has
15
+ outgrown its usefulness for most users. It was with this conclusion in mind that
16
+ Remockable was born. It's an attempt to start with a clean slate but maintain
17
+ the original goal of Remarkable in spirit.
18
+
19
+
20
+ ## Matchers
21
+
22
+ Remockable currently includes support for all of the Active Model validation
23
+ and allow_mass_assignment_of matchers, and also supports the have_column,
24
+ have_index, and have_scope Active Record matchers.
25
+
26
+ More are on the way soon.
27
+
28
+
29
+ ## Installation
30
+
31
+ Add the `remockable` gem to your `Gemfile`:
32
+
33
+ gem 'remockable'
34
+
35
+ Then run `bundle install` to install the gem.
36
+
37
+ You'll also want to make sure the library is required by RSpec, so add the
38
+ following to your `spec_helper.rb` or someone else where it will get loaded
39
+ when your specs do:
40
+
41
+ require 'remockable'
42
+
43
+
44
+ ## Copyright
45
+
46
+ Copyright © 2010-2011 Tyler Hunt. See LICENSE for details.
@@ -0,0 +1,27 @@
1
+ RSpec::Matchers.define(:allow_mass_assignment_of) do |*attributes|
2
+ @attributes = attributes
3
+
4
+ match_for_should do |actual|
5
+ @attributes.all? do |attribute|
6
+ !actual.class.active_authorizer.deny?(attribute)
7
+ end
8
+ end
9
+
10
+ match_for_should_not do |actual|
11
+ @attributes.all? do |attribute|
12
+ actual.class.active_authorizer.deny?(attribute)
13
+ end
14
+ end
15
+
16
+ failure_message_for_should do |actual|
17
+ "Expected #{actual.class.name} to #{description}"
18
+ end
19
+
20
+ failure_message_for_should_not do |actual|
21
+ "Did not expect #{actual.class.name} to #{description}"
22
+ end
23
+
24
+ description do
25
+ "allow mass-assignment of #{@attributes.to_sentence}"
26
+ end
27
+ end
@@ -13,7 +13,7 @@ module Remockable
13
13
 
14
14
  def validate_attributes
15
15
  @attributes.inject(true) do |result, attribute|
16
- yield validator_for(attribute)
16
+ result & yield(validator_for(attribute))
17
17
  end
18
18
  end
19
19
  end
@@ -1,4 +1,5 @@
1
1
  require 'remockable/active_model/helpers'
2
+ require 'remockable/active_model/allow_mass_assignment_of'
2
3
  require 'remockable/active_model/validate_acceptance_of'
3
4
  require 'remockable/active_model/validate_confirmation_of'
4
5
  require 'remockable/active_model/validate_exclusion_of'
@@ -0,0 +1,3 @@
1
+ module Remockable
2
+ VERSION = '0.0.4'
3
+ end
data/lib/remockable.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  require 'rspec/core'
2
+
3
+ require 'active_support/core_ext/array/conversions'
2
4
  require 'active_support/core_ext/array/extract_options'
3
5
  require 'active_support/core_ext/hash/slice'
4
6
  require 'active_support/core_ext/object/try'
@@ -6,3 +8,4 @@ require 'active_support/core_ext/object/try'
6
8
  require 'remockable/helpers'
7
9
  require 'remockable/active_model'
8
10
  require 'remockable/active_record'
11
+ require 'remockable/version'
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remockable
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 3
9
- version: 0.0.3
4
+ prerelease:
5
+ version: 0.0.4
10
6
  platform: ruby
11
7
  authors:
12
8
  - Tyler Hunt
@@ -14,7 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-03-11 00:00:00 -05:00
13
+ date: 2011-05-07 00:00:00 -04:00
18
14
  default_executable:
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
@@ -25,10 +21,6 @@ dependencies:
25
21
  requirements:
26
22
  - - ~>
27
23
  - !ruby/object:Gem::Version
28
- segments:
29
- - 3
30
- - 0
31
- - 0
32
24
  version: 3.0.0
33
25
  type: :runtime
34
26
  version_requirements: *id001
@@ -40,10 +32,6 @@ dependencies:
40
32
  requirements:
41
33
  - - ~>
42
34
  - !ruby/object:Gem::Version
43
- segments:
44
- - 3
45
- - 0
46
- - 0
47
35
  version: 3.0.0
48
36
  type: :runtime
49
37
  version_requirements: *id002
@@ -55,10 +43,6 @@ dependencies:
55
43
  requirements:
56
44
  - - ~>
57
45
  - !ruby/object:Gem::Version
58
- segments:
59
- - 3
60
- - 0
61
- - 0
62
46
  version: 3.0.0
63
47
  type: :runtime
64
48
  version_requirements: *id003
@@ -70,9 +54,6 @@ dependencies:
70
54
  requirements:
71
55
  - - ~>
72
56
  - !ruby/object:Gem::Version
73
- segments:
74
- - 2
75
- - 0
76
57
  version: "2.0"
77
58
  type: :runtime
78
59
  version_requirements: *id004
@@ -84,9 +65,6 @@ dependencies:
84
65
  requirements:
85
66
  - - ~>
86
67
  - !ruby/object:Gem::Version
87
- segments:
88
- - 2
89
- - 0
90
68
  version: "2.0"
91
69
  type: :runtime
92
70
  version_requirements: *id005
@@ -98,9 +76,6 @@ dependencies:
98
76
  requirements:
99
77
  - - ~>
100
78
  - !ruby/object:Gem::Version
101
- segments:
102
- - 2
103
- - 0
104
79
  version: "2.0"
105
80
  type: :development
106
81
  version_requirements: *id006
@@ -112,10 +87,6 @@ dependencies:
112
87
  requirements:
113
88
  - - ~>
114
89
  - !ruby/object:Gem::Version
115
- segments:
116
- - 1
117
- - 3
118
- - 3
119
90
  version: 1.3.3
120
91
  type: :development
121
92
  version_requirements: *id007
@@ -128,7 +99,9 @@ extensions: []
128
99
  extra_rdoc_files: []
129
100
 
130
101
  files:
102
+ - README.markdown
131
103
  - LICENSE
104
+ - lib/remockable/active_model/allow_mass_assignment_of.rb
132
105
  - lib/remockable/active_model/helpers.rb
133
106
  - lib/remockable/active_model/validate_acceptance_of.rb
134
107
  - lib/remockable/active_model/validate_confirmation_of.rb
@@ -145,6 +118,7 @@ files:
145
118
  - lib/remockable/active_record/helpers.rb
146
119
  - lib/remockable/active_record.rb
147
120
  - lib/remockable/helpers.rb
121
+ - lib/remockable/version.rb
148
122
  - lib/remockable.rb
149
123
  has_rdoc: true
150
124
  homepage: http://github.com/tylerhunt/remockable
@@ -160,21 +134,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
160
134
  requirements:
161
135
  - - ">="
162
136
  - !ruby/object:Gem::Version
163
- segments:
164
- - 0
165
137
  version: "0"
166
138
  required_rubygems_version: !ruby/object:Gem::Requirement
167
139
  none: false
168
140
  requirements:
169
141
  - - ">="
170
142
  - !ruby/object:Gem::Version
171
- segments:
172
- - 0
173
143
  version: "0"
174
144
  requirements: []
175
145
 
176
146
  rubyforge_project:
177
- rubygems_version: 1.3.7
147
+ rubygems_version: 1.6.2
178
148
  signing_key:
179
149
  specification_version: 3
180
150
  summary: A collection of RSpec matchers to simplify your web app specs.