active_decorator-rspec 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -6
- data/active_decorator-rspec.gemspec +1 -1
- data/lib/active_decorator/rspec.rb +17 -16
- data/lib/active_decorator/rspec/version.rb +1 -1
- data/spec/{features/decorator_spec.rb → decorators/author_decorator_spec.rb} +0 -0
- data/spec/spec_helper.rb +0 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d55e74efa49b9c7685574667b56204b99e757bf7
|
4
|
+
data.tar.gz: 8f27b1e6d585653065e4bc0f94ae4a81d8dcf351
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 229aa66fa1e8e507c038e212824597643b82a17450314a097616adb01579796f226f52eb9233cdc11887d50349f75d371456c21903eb48767ac1d3cbdb810fc2
|
7
|
+
data.tar.gz: 1857f5b82924fa65bfcd06ff39c6e659f22f3a5ec103b1a72f7cfc12bab153680b7f4caebf1009db929bd66b7bbd06a68d7e0ea788d41930564f2ee9cfc0e02f
|
data/README.md
CHANGED
@@ -19,18 +19,21 @@ Or install it yourself as:
|
|
19
19
|
|
20
20
|
$ gem install active_decorator-rspec
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
First you need to require active_decorator/rspec in your spec_helper.rb:
|
22
|
+
And require it as:
|
25
23
|
|
26
24
|
```
|
27
25
|
require "active_decorator/rspec"
|
28
26
|
```
|
29
27
|
|
30
|
-
|
28
|
+
## Usage
|
31
29
|
|
32
|
-
```
|
33
|
-
|
30
|
+
```rb
|
31
|
+
describe AuthorDecorator, type: decorator do
|
32
|
+
let(:author) { Author.create name: 'boo' }
|
33
|
+
subject { decorate author }
|
34
|
+
|
35
|
+
its(:reverse_name) { should eq 'oob' }
|
36
|
+
end
|
34
37
|
```
|
35
38
|
|
36
39
|
## Contributing
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["mizokami"]
|
10
10
|
spec.email = ["suzunatsu@yahoo.com"]
|
11
11
|
spec.summary = %q{ActiveDecorator::RSpec}
|
12
|
-
spec.homepage = ""
|
12
|
+
spec.homepage = "https://github.com/mizoR/active_decorator-rspec"
|
13
13
|
spec.license = "MIT"
|
14
14
|
|
15
15
|
spec.files = `git ls-files -z`.split("\x0")
|
@@ -5,24 +5,25 @@ require "active_decorator/rspec/version"
|
|
5
5
|
|
6
6
|
module ActiveDecorator
|
7
7
|
module RSpec
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
def self.enable(example=nil)
|
9
|
+
controller = Class.new(ActionController::Base).new
|
10
|
+
controller.request = ActionController::TestRequest.new
|
11
|
+
ActiveDecorator::ViewContext.current = controller.view_context
|
12
|
+
|
13
|
+
example.extend self if example
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
ActiveDecorator::ViewContext.current = begin
|
18
|
-
controller = Class.new(ActionController::Base).new
|
19
|
-
controller.request = ActionController::TestRequest.new
|
20
|
-
view_context = controller.view_context
|
21
|
-
view_context
|
22
|
-
end
|
23
|
-
end
|
15
|
+
self
|
16
|
+
end
|
24
17
|
|
25
|
-
|
18
|
+
def decorate(obj)
|
19
|
+
ActiveDecorator::Decorator.instance.decorate(obj)
|
20
|
+
obj
|
26
21
|
end
|
27
22
|
end
|
28
23
|
end
|
24
|
+
|
25
|
+
RSpec.configure do |config|
|
26
|
+
config.before :each, type: :decorator do
|
27
|
+
ActiveDecorator::RSpec.enable(self)
|
28
|
+
end
|
29
|
+
end
|
File without changes
|
data/spec/spec_helper.rb
CHANGED
@@ -6,8 +6,6 @@ require "rspec/its"
|
|
6
6
|
require File.join(File.dirname(__FILE__), "dummy_app.rb")
|
7
7
|
|
8
8
|
RSpec.configure do |config|
|
9
|
-
config.include ActiveDecorator::RSpec, type: :decorator
|
10
|
-
|
11
9
|
config.before :all do
|
12
10
|
CreateAuthors.up if !ActiveRecord::Base.connection.table_exists?('authors')
|
13
11
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_decorator-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mizokami
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -152,10 +152,10 @@ files:
|
|
152
152
|
- active_decorator-rspec.gemspec
|
153
153
|
- lib/active_decorator/rspec.rb
|
154
154
|
- lib/active_decorator/rspec/version.rb
|
155
|
+
- spec/decorators/author_decorator_spec.rb
|
155
156
|
- spec/dummy_app.rb
|
156
|
-
- spec/features/decorator_spec.rb
|
157
157
|
- spec/spec_helper.rb
|
158
|
-
homepage:
|
158
|
+
homepage: https://github.com/mizoR/active_decorator-rspec
|
159
159
|
licenses:
|
160
160
|
- MIT
|
161
161
|
metadata: {}
|
@@ -180,6 +180,6 @@ signing_key:
|
|
180
180
|
specification_version: 4
|
181
181
|
summary: ActiveDecorator::RSpec
|
182
182
|
test_files:
|
183
|
+
- spec/decorators/author_decorator_spec.rb
|
183
184
|
- spec/dummy_app.rb
|
184
|
-
- spec/features/decorator_spec.rb
|
185
185
|
- spec/spec_helper.rb
|