active_model_lint-rspec 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +41 -0
- data/LICENSE +22 -0
- data/README.md +65 -0
- data/active_model_lint-rspec.gemspec +21 -0
- data/lib/active_model_lint-rspec.rb +3 -0
- data/lib/active_model_lint-rspec/an_active_model.rb +15 -0
- data/lib/active_model_lint-rspec/version.rb +4 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4e1df7ca0246fe04dfe1291501b8fd6a2c1c0897
|
4
|
+
data.tar.gz: e2d1fd5a7344d80d8a4a1187292d24f81617be88
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1f210d932471f00989a98119e0c11de9318574ce974f07b543132983cd769fe58ce4255721c8fa110f05d482a74cb2b26b77bb69844f7629a0b2f059699b4fad
|
7
|
+
data.tar.gz: bf1d089799ecfa0ad896a86aee11225cc6fc57a92df8ad9ae195e68573389915bbc78c67d9201d1dbe327ff93ea49392d29f6e6af42d0e7d992f7e3b7af0b173
|
data/Gemfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
gemspec
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
active_model_lint-rspec (0.0.1)
|
5
|
+
activemodel (>= 3.0)
|
6
|
+
rspec
|
7
|
+
|
8
|
+
GEM
|
9
|
+
specs:
|
10
|
+
activemodel (4.0.0)
|
11
|
+
activesupport (= 4.0.0)
|
12
|
+
builder (~> 3.1.0)
|
13
|
+
activesupport (4.0.0)
|
14
|
+
i18n (~> 0.6, >= 0.6.4)
|
15
|
+
minitest (~> 4.2)
|
16
|
+
multi_json (~> 1.3)
|
17
|
+
thread_safe (~> 0.1)
|
18
|
+
tzinfo (~> 0.3.37)
|
19
|
+
atomic (1.1.14)
|
20
|
+
builder (3.1.4)
|
21
|
+
diff-lcs (1.2.4)
|
22
|
+
i18n (0.6.5)
|
23
|
+
minitest (4.7.5)
|
24
|
+
multi_json (1.8.0)
|
25
|
+
rspec (2.14.1)
|
26
|
+
rspec-core (~> 2.14.0)
|
27
|
+
rspec-expectations (~> 2.14.0)
|
28
|
+
rspec-mocks (~> 2.14.0)
|
29
|
+
rspec-core (2.14.5)
|
30
|
+
rspec-expectations (2.14.2)
|
31
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
32
|
+
rspec-mocks (2.14.3)
|
33
|
+
thread_safe (0.1.3)
|
34
|
+
atomic
|
35
|
+
tzinfo (0.3.37)
|
36
|
+
|
37
|
+
PLATFORMS
|
38
|
+
ruby
|
39
|
+
|
40
|
+
DEPENDENCIES
|
41
|
+
active_model_lint-rspec!
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Geoff Harcourt
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# ActiveModel Lint for RSpec
|
2
|
+
|
3
|
+
Form objects are a great way to move logic out of your controllers and models while ensuring that classes focus on their core responsibility. When you implement ActiveModel behavior in a class, this gem provides a one-line test to ensure that your class implements required behavior such as the ````#persisted?```` method that is required for your form object to function within a Rails form.
|
4
|
+
|
5
|
+
The code here was shamelessly cribbed from an example published by [Mike Gerhard](http://github.com/msgehard) at Pivotal Labs. It appears in this [blog post](http://pivotallabs.com/making-sure-you-implement-the-activemodel-interface-fully/). This gem merely puts the shared example into a gem for easy distribution into your project.
|
6
|
+
|
7
|
+
## Example
|
8
|
+
|
9
|
+
Just one line to attach the shared example to your spec.
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
describe MyFormObjectClass do
|
13
|
+
|
14
|
+
it_behaves_like 'an ActiveModel'
|
15
|
+
|
16
|
+
end
|
17
|
+
```
|
18
|
+
|
19
|
+
Then run your specs:
|
20
|
+
|
21
|
+
```
|
22
|
+
MyFormObjectClass
|
23
|
+
behaves like an ActiveModel
|
24
|
+
test persisted?
|
25
|
+
test to param
|
26
|
+
test to partial path
|
27
|
+
test to key
|
28
|
+
test model naming
|
29
|
+
test errors aref
|
30
|
+
```
|
31
|
+
|
32
|
+
## Installation
|
33
|
+
|
34
|
+
###Rails and other Bundler projects
|
35
|
+
|
36
|
+
Add the gem to your test group.
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
group :test do
|
40
|
+
gem "active_model_lint-rspec"
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
44
|
+
### Other Ruby projects
|
45
|
+
|
46
|
+
Require the gem after RSpec has been required.
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
require 'rspec'
|
50
|
+
require 'active_model_lint-rspec'
|
51
|
+
```
|
52
|
+
|
53
|
+
## Further reading
|
54
|
+
* http://yehudakatz.com/2010/01/10/activemodel-make-any-ruby-object-feel-like-activerecord/
|
55
|
+
* http://pivotallabs.com/making-sure-you-implement-the-activemodel-interface-fully/
|
56
|
+
|
57
|
+
## Credits
|
58
|
+
|
59
|
+
ActiveModelLint-RSpec is packaged by [Geoff
|
60
|
+
Harcourt](http://github.com/geoffharcourt). It was built using code
|
61
|
+
from a blog post written by [Mike Gehard](http://github/msgehard).
|
62
|
+
|
63
|
+
## License
|
64
|
+
|
65
|
+
ActiveModelLint-Rspec is free software, and may be redistributed under the terms of the MIT license.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'active_model_lint-rspec/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'active_model_lint-rspec'
|
5
|
+
s.version = ActiveModelLintRspec::VERSION
|
6
|
+
s.date = '2013-09-21'
|
7
|
+
s.summary = "Implements ActiveModel::Lint::Tests in RSpec."
|
8
|
+
s.description = "Provides the ActiveModel::Lint::Tests for test-unit or minitest an RSpec shared example."
|
9
|
+
s.authors = ["Geoff Harcourt"]
|
10
|
+
s.email = 'geoff@fivetool.io'
|
11
|
+
s.files = `git ls-files`.split("\n")
|
12
|
+
s.test_files = `git ls-files -- {spec}/*`.split("\n")
|
13
|
+
s.require_paths = ["lib"]
|
14
|
+
s.homepage =
|
15
|
+
'http://github.com/geoffharcourt/active_model_lint-rspec'
|
16
|
+
s.license = 'MIT'
|
17
|
+
|
18
|
+
s.add_dependency("activemodel", ">= 3.0")
|
19
|
+
s.add_dependency("rspec")
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
shared_examples_for "an ActiveModel" do
|
2
|
+
require 'test/unit/assertions'
|
3
|
+
require 'active_model/lint'
|
4
|
+
include Test::Unit::Assertions
|
5
|
+
include ActiveModel::Lint::Tests
|
6
|
+
|
7
|
+
before do
|
8
|
+
@model = subject
|
9
|
+
end
|
10
|
+
|
11
|
+
ActiveModel::Lint::Tests.public_instance_methods.map { |method| method.to_s }.grep(/^test/).each do |method|
|
12
|
+
example(method.gsub('_', ' ')) { send method }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: active_model_lint-rspec
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Geoff Harcourt
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activemodel
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Provides the ActiveModel::Lint::Tests for test-unit or minitest an RSpec
|
42
|
+
shared example.
|
43
|
+
email: geoff@fivetool.io
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- Gemfile
|
49
|
+
- Gemfile.lock
|
50
|
+
- LICENSE
|
51
|
+
- README.md
|
52
|
+
- active_model_lint-rspec.gemspec
|
53
|
+
- lib/active_model_lint-rspec.rb
|
54
|
+
- lib/active_model_lint-rspec/an_active_model.rb
|
55
|
+
- lib/active_model_lint-rspec/version.rb
|
56
|
+
homepage: http://github.com/geoffharcourt/active_model_lint-rspec
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata: {}
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 2.1.4
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: Implements ActiveModel::Lint::Tests in RSpec.
|
80
|
+
test_files: []
|
81
|
+
has_rdoc:
|