active_decorator-rspec 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c663ea68b5384b69af39e822ad6a3dd9cf1f383d
4
- data.tar.gz: 8f665f5c1ff6a9f429c97ee60415b1b3e6204484
3
+ metadata.gz: d55e74efa49b9c7685574667b56204b99e757bf7
4
+ data.tar.gz: 8f27b1e6d585653065e4bc0f94ae4a81d8dcf351
5
5
  SHA512:
6
- metadata.gz: 5a09fc1769d68121f772d355eee5968cf24ab0ccfeb3b68159e6bd846f0835d39cc8b8202b707d8b77ddb2b3ce4c1fe4deb5cb3c9b1f4bf66f402cbd6259c4ca
7
- data.tar.gz: 11f00aa6439d9bf8705ed566384907d42ca1f464e7a2c12cc6806a5d29d8d1690eeb82e749f95c08bd7b08486886a60a5950b840b0384cde1c84e6f5a892d16b
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
- ## Usage
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
- And You will need to include ActiveDecorator::RSpec in your example groups:
28
+ ## Usage
31
29
 
32
- ```
33
- config.include ActiveDecorator::RSpec, type: :decorator
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
- module HelperMethods
9
- def decorate(obj)
10
- ActiveDecorator::Decorator.instance.decorate(obj)
11
- obj
12
- end
13
- end
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
- def self.included(config)
16
- config.before :each do
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
- ::RSpec::Core::ExampleGroup.send(:include, HelperMethods)
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
@@ -1,5 +1,5 @@
1
1
  module ActiveDecorator
2
2
  module RSpec
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
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.1
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-08-31 00:00:00.000000000 Z
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