r_decorator 0.0.2 → 0.0.3

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.
@@ -1,6 +1,6 @@
1
1
  source :rubygems
2
2
 
3
- gem 'active_decorator', :path => '..'
3
+ gem 'r_decorator', :path => '..'
4
4
 
5
5
  gem 'rails', '~> 3.0.0'
6
6
  gem 'rspec-rails'
@@ -1,6 +1,6 @@
1
1
  source :rubygems
2
2
 
3
- gem 'active_decorator', :path => '..'
3
+ gem 'r_decorator', :path => '..'
4
4
 
5
5
  gem 'rails', '~> 3.1.0'
6
6
  gem 'rspec-rails'
@@ -0,0 +1,19 @@
1
+ module RSpec::Rails::RDecoratorExampleGroup
2
+ extend ActiveSupport::Concern
3
+ include RSpec::Rails::RailsExampleGroup
4
+ include ActionView::TestCase::Behavior
5
+
6
+ included do
7
+ metadata[:type] = :decorator
8
+
9
+ before do
10
+ RDecorator::ViewContext.current = controller.view_context
11
+ end
12
+ end
13
+ end
14
+
15
+ RSpec::configure do |c|
16
+ c.include RSpec::Rails::RDecoratorExampleGroup, :type => :decorator, :example_group => {
17
+ :file_path => c.escaped_path(%w[spec decorators])
18
+ }
19
+ end
@@ -1,3 +1,3 @@
1
1
  module RDecorator
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'view_context on rspec' do
4
+ let(:author) { Author.create(name: 'test') }
5
+ subject { author.decorated }
6
+ its(:name_link) { should be_html_safe }
7
+ end
@@ -1,6 +1,7 @@
1
1
  <% @authors.each do |author| %>
2
2
  <%= author.deco.name %>
3
3
  <%= author.deco.reverse_name %>
4
+ <%= author.deco.name_link %>
4
5
 
5
6
  <% if params[:partial] == 'collection' %>
6
7
  <%= render author.books %>
@@ -36,6 +36,10 @@ module ApplicationHelper; end
36
36
  class ApplicationDecorator < RDecorator::Base
37
37
  end
38
38
  class AuthorDecorator < ApplicationDecorator
39
+ def name_link
40
+ link_to origin.name, author_path(origin), title: origin.name
41
+ end
42
+
39
43
  def reverse_name
40
44
  name.reverse
41
45
  end
@@ -52,7 +56,7 @@ class BookDecorator < ApplicationDecorator
52
56
  def upcased_title
53
57
  title.upcase
54
58
  end
55
-
59
+
56
60
  def link
57
61
  link_to title, "#{request.protocol}#{request.host_with_port}/assets/sample.png"
58
62
  end
@@ -19,6 +19,7 @@ feature 'decorating controller ivar' do
19
19
  visit '/authors'
20
20
  page.should have_content 'takahashim'
21
21
  page.should have_content 'takahashim'.reverse
22
+ page.should have_selector 'a[title="takahashim"]'
22
23
  end
23
24
 
24
25
  scenario "decorating models' array in ivar" do
data/spec/spec_helper.rb CHANGED
@@ -7,7 +7,8 @@ require 'r_decorator'
7
7
  require 'fake_app/fake_app'
8
8
  require 'rspec/rails'
9
9
  require 'capybara/rspec'
10
-
10
+ require 'r_decorator/rspec'
11
+
11
12
  # Requires supporting files with custom matchers and macros, etc,
12
13
  # in ./support/ and its subdirectories.
13
14
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: r_decorator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-16 00:00:00.000000000 Z
12
+ date: 2012-12-18 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A readable and simple view helper for Rails 3
15
15
  email:
@@ -37,9 +37,12 @@ files:
37
37
  - lib/r_decorator.rb
38
38
  - lib/r_decorator/base.rb
39
39
  - lib/r_decorator/railtie.rb
40
+ - lib/r_decorator/rspec.rb
40
41
  - lib/r_decorator/version.rb
41
42
  - lib/r_decorator/view_context.rb
42
43
  - r_decortator.gemspec
44
+ - spec/decorators/definition_spec.rb
45
+ - spec/decorators/view_helpers_spec.rb
43
46
  - spec/fake_app/authors/index.html.erb
44
47
  - spec/fake_app/authors/show.html.erb
45
48
  - spec/fake_app/books/_book.html.erb
@@ -48,7 +51,6 @@ files:
48
51
  - spec/fake_app/fake_app.rb
49
52
  - spec/features/action_view_helpers_spec.rb
50
53
  - spec/features/controller_ivar_spec.rb
51
- - spec/features/decorator_spec.rb
52
54
  - spec/features/partial_spec.rb
53
55
  - spec/spec_helper.rb
54
56
  homepage: https://github.com/takuya327/r_decorator
@@ -76,6 +78,8 @@ signing_key:
76
78
  specification_version: 3
77
79
  summary: A readable and simple view helper for Rails 3
78
80
  test_files:
81
+ - spec/decorators/definition_spec.rb
82
+ - spec/decorators/view_helpers_spec.rb
79
83
  - spec/fake_app/authors/index.html.erb
80
84
  - spec/fake_app/authors/show.html.erb
81
85
  - spec/fake_app/books/_book.html.erb
@@ -84,6 +88,5 @@ test_files:
84
88
  - spec/fake_app/fake_app.rb
85
89
  - spec/features/action_view_helpers_spec.rb
86
90
  - spec/features/controller_ivar_spec.rb
87
- - spec/features/decorator_spec.rb
88
91
  - spec/features/partial_spec.rb
89
92
  - spec/spec_helper.rb