lulalala_presenter 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +29 -3
  3. data/Gemfile +4 -3
  4. data/README.md +5 -4
  5. data/Rakefile +9 -5
  6. data/gemfiles/Gemfile-rails.3.2.x +3 -12
  7. data/gemfiles/Gemfile-rails.4.0.x +3 -3
  8. data/gemfiles/Gemfile-rails.4.1.x +3 -2
  9. data/gemfiles/Gemfile-rails.4.2.x +3 -2
  10. data/gemfiles/Gemfile-rails.5.0.x +9 -0
  11. data/gemfiles/Gemfile-rails.5.1.x +9 -0
  12. data/lib/active_decorator/config.rb +3 -17
  13. data/lib/active_decorator/monkey/action_controller/base/rescue_from.rb +12 -8
  14. data/lib/active_decorator/view_context.rb +17 -12
  15. data/lib/generators/rails/decorator_generator.rb +1 -0
  16. data/lib/generators/rspec/decorator_generator.rb +1 -0
  17. data/lib/generators/test_unit/decorator_generator.rb +1 -0
  18. data/lib/lulalala_presenter/railtie.rb +8 -3
  19. data/lib/lulalala_presenter/version.rb +1 -1
  20. data/lulalala_presenter.gemspec +1 -0
  21. data/test/configuration_test.rb +28 -0
  22. data/test/controllers/fake_detection_test.rb +13 -0
  23. data/{spec → test}/fake_app/app/views/authors/index.html.erb +2 -2
  24. data/test/fake_app/app/views/authors/show.html.erb +2 -0
  25. data/test/fake_app/app/views/authors/show.json.jbuilder +3 -0
  26. data/test/fake_app/app/views/book_mailer/thanks.text.erb +1 -0
  27. data/test/fake_app/app/views/books/_book.html.erb +2 -0
  28. data/test/fake_app/app/views/books/_book.json.jbuilder +3 -0
  29. data/test/fake_app/app/views/books/_book_locals.html.erb +2 -0
  30. data/test/fake_app/app/views/books/error.html.erb +1 -0
  31. data/{spec → test}/fake_app/app/views/books/index.html.erb +1 -1
  32. data/{spec → test}/fake_app/app/views/books/purchase.html.erb +0 -0
  33. data/test/fake_app/app/views/books/show.html.erb +4 -0
  34. data/{spec → test}/fake_app/app/views/movies/show.html.erb +0 -0
  35. data/{spec → test}/fake_app/fake_app.rb +24 -37
  36. data/test/features/action_view_helpers_test.rb +37 -0
  37. data/test/features/controller_ivar_test.rb +40 -0
  38. data/test/features/jbuilder_test.rb +15 -0
  39. data/test/features/partial_test.rb +28 -0
  40. data/test/test_helper.rb +30 -0
  41. metadata +44 -46
  42. data/.rspec +0 -2
  43. data/gemfiles/Gemfile-rails.3.0.x +0 -16
  44. data/gemfiles/Gemfile-rails.3.1.x +0 -19
  45. data/lib/active_decorator/helpers.rb +0 -14
  46. data/spec/configuration_spec.rb +0 -27
  47. data/spec/controllers/fake_detection_spec.rb +0 -7
  48. data/spec/fake_app/app/views/authors/show.html.erb +0 -2
  49. data/spec/fake_app/app/views/authors/show.json.jbuilder +0 -2
  50. data/spec/fake_app/app/views/book_mailer/thanks.text.erb +0 -1
  51. data/spec/fake_app/app/views/books/_book.html.erb +0 -2
  52. data/spec/fake_app/app/views/books/_book.json.jbuilder +0 -2
  53. data/spec/fake_app/app/views/books/_book_locals.html.erb +0 -2
  54. data/spec/fake_app/app/views/books/error.html.erb +0 -1
  55. data/spec/fake_app/app/views/books/show.html.erb +0 -4
  56. data/spec/features/action_view_helpers_spec.rb +0 -25
  57. data/spec/features/controller_ivar_spec.rb +0 -37
  58. data/spec/features/jbuilder_spec.rb +0 -12
  59. data/spec/features/partial_spec.rb +0 -25
  60. data/spec/spec_helper.rb +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 83daef5e00861530f17904e67b427afb6398f4e6
4
- data.tar.gz: 0da518f4274c4172cb51bdc47150062f77253404
3
+ metadata.gz: 0b5396454f4b88dc51e67b067966e38eaf3a521b
4
+ data.tar.gz: b0539b185e73b8482d825d40d5b691ed33af7b53
5
5
  SHA512:
6
- metadata.gz: c5267a2f9ecec315bbf7f53e2feb755b9bfe598fc411d974af01ca6b19f59b65852e33d9dd4b59f13cde2dc6d7df3b7d76775dafffb9ce9f6c0e3e73a9807ec5
7
- data.tar.gz: 06ef0a6c2b5270754543f25c080c6c332d2eed8b3f8694e48330f45fc601f991dd387edc454f504c8f75ef92243384de973e36414df631c0a8eb0daba75316e3
6
+ metadata.gz: 6ba589a63175ef5df3b856190026721afb3cea7b8f101ce37833d43878287ac7d74535aad9440febd760c1efc3f363059c24435d6c779c409692c514d571d76d
7
+ data.tar.gz: e2c4fbdb0d99cb4a634ee593c6f75dd9a88138dd35f800d2cc6d92b025b52790dadb07f929c4577d50d19f6c27f5ce9aa771cf222a7f3fa8ac52cc6f3163b2f6
@@ -1,17 +1,22 @@
1
1
  language: ruby
2
2
 
3
- script: bundle exec rake spec
3
+ before_install: gem update bundler --no-document
4
+ script: bundle exec rake test
4
5
 
5
6
  rvm:
6
7
  - 2.0.0
7
- - 2.1
8
- - 2.2.3
8
+ - 2.1.10
9
+ - 2.2.7
10
+ - 2.3.4
11
+ - 2.4.1
9
12
  - ruby-head
10
13
  gemfile:
11
14
  - gemfiles/Gemfile-rails.3.2.x
12
15
  - gemfiles/Gemfile-rails.4.0.x
13
16
  - gemfiles/Gemfile-rails.4.1.x
14
17
  - gemfiles/Gemfile-rails.4.2.x
18
+ - gemfiles/Gemfile-rails.5.0.x
19
+ - gemfiles/Gemfile-rails.5.1.x
15
20
 
16
21
  sudo: false
17
22
 
@@ -19,5 +24,26 @@ matrix:
19
24
  exclude:
20
25
  - rvm: ruby-head
21
26
  gemfile: gemfiles/Gemfile-rails.3.2.x
27
+ - rvm: ruby-head
28
+ gemfile: gemfiles/Gemfile-rails.4.0.x
29
+ - rvm: ruby-head
30
+ gemfile: gemfiles/Gemfile-rails.4.1.x
31
+ - rvm: 2.4.1
32
+ gemfile: gemfiles/Gemfile-rails.3.2.x
33
+ - rvm: 2.4.1
34
+ gemfile: gemfiles/Gemfile-rails.4.0.x
35
+ - rvm: 2.4.1
36
+ gemfile: gemfiles/Gemfile-rails.4.1.x
37
+ - rvm: 2.4.1
38
+ gemfile: gemfiles/Gemfile-rails.4.2.x
39
+ - rvm: 2.0.0
40
+ gemfile: gemfiles/Gemfile-rails.5.0.x
41
+ - rvm: 2.1.10
42
+ gemfile: gemfiles/Gemfile-rails.5.0.x
43
+ - rvm: 2.0.0
44
+ gemfile: gemfiles/Gemfile-rails.5.1.x
45
+ - rvm: 2.1.10
46
+ gemfile: gemfiles/Gemfile-rails.5.1.x
22
47
  allow_failures:
23
48
  - rvm: ruby-head
49
+ - gemfile: gemfiles/Gemfile-rails.5.1.x
data/Gemfile CHANGED
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
1
2
  source 'https://rubygems.org'
2
3
 
3
4
  gemspec
4
5
 
5
- gem 'rails', '~> 4.0.0'
6
- gem 'rspec-rails'
7
- gem 'capybara', '>= 2'
6
+ gem 'rails'
7
+ gem 'test-unit-rails'
8
+ gem 'capybara'
8
9
  gem 'sqlite3'
9
10
  gem 'jbuilder'
data/README.md CHANGED
@@ -13,10 +13,11 @@ and this gem will solve it.
13
13
 
14
14
  ## Usage ##
15
15
 
16
- 1. put `gem 'lulalala_presenter', github:'lulalala/lulalala_presenter'` in Gemfile and then `bundle install`.
17
- 2. create a presenter class for each AR model you wish to present. For example, a decorator for a model `User` should be named `UserPresenter`.
16
+ 1. put `gem 'lulalala_presenter'` in Gemfile and then `bundle install`.
17
+ 2. create a presenter class for each AR model you wish to present. For example, a decorator for a model `User` should be named `UserPresenter`. In your helper methods:
18
+ 1. call any ActionView's helper methods using `h`, e.g. `h.content_tag` or `h.link_to`.
19
+ 2. call any model methods using `model`, e.g. `model.title`
18
20
  3. access this presenter from the model like this: `record.presenter`, and from there call the helper methods.
19
- 2. call any ActionView's helper methods using `h`, e.g. `h.content_tag` or `h.link_to`.
20
21
 
21
22
 
22
23
  ## Examples ##
@@ -28,7 +29,7 @@ class User < ActiveRecord::Base
28
29
  end
29
30
 
30
31
  # app/presenters/user_presenter.rb
31
- module UserPresenter < LulalalaPresenter::Base
32
+ class UserPresenter < LulalalaPresenter::Base
32
33
  def full_name
33
34
  "#{model.first_name} #{model.last_name}"
34
35
  end
data/Rakefile CHANGED
@@ -1,12 +1,16 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler'
4
5
  Bundler::GemHelper.install_tasks
5
6
 
6
- require 'rspec/core'
7
- require 'rspec/core/rake_task'
8
- RSpec::Core::RakeTask.new(:spec) do |spec|
9
- spec.pattern = FileList['spec/**/*_spec.rb']
7
+ require 'rake/testtask'
8
+
9
+ Rake::TestTask.new do |t|
10
+ t.libs << "test"
11
+ t.pattern = 'test/**/*_test.rb'
12
+ t.warning = true
13
+ t.verbose = true
10
14
  end
11
15
 
12
- task :default => :spec
16
+ task default: :test
@@ -1,20 +1,11 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'active_decorator', :path => '..'
3
+ gem 'active_decorator', path: '..'
4
4
 
5
5
  gem 'rails', '~> 3.2.0'
6
- gem 'rspec-rails', '~> 2.14.0'
7
- if RUBY_VERSION <= '1.8.7'
8
- gem 'i18n', '~> 0.6.11'
9
- end
6
+ gem 'test-unit-rails', '1.0.2'
10
7
  gem 'capybara', '~> 2.0.0'
11
- # rubyzip >=1 doesn't support ruby 1.8
12
- gem 'rubyzip', '< 1.0.0'
13
8
  gem 'sqlite3'
14
9
  gem 'nokogiri', '~> 1.5.0'
15
- if RUBY_VERSION <= '1.8.7'
16
- gem 'jbuilder', '< 2'
17
- else
18
- gem 'jbuilder'
19
- end
10
+ gem 'jbuilder'
20
11
  gem 'test-unit'
@@ -1,10 +1,10 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'active_decorator', :path => '..'
3
+ gem 'active_decorator', path: '..'
4
4
 
5
5
  gem 'rails', '~> 4.0.0'
6
- gem 'rspec-rails'
6
+ gem 'test-unit-rails'
7
7
  gem 'capybara'
8
8
  gem 'sqlite3'
9
+ gem 'nokogiri', '~> 1.6.0'
9
10
  gem 'jbuilder'
10
- gem 'test-unit'
@@ -1,9 +1,10 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'active_decorator', :path => '..'
3
+ gem 'active_decorator', path: '..'
4
4
 
5
5
  gem 'rails', '~> 4.1.0'
6
- gem 'rspec-rails'
6
+ gem 'test-unit-rails'
7
7
  gem 'capybara'
8
8
  gem 'sqlite3'
9
+ gem 'nokogiri', '~> 1.6.0'
9
10
  gem 'jbuilder'
@@ -1,9 +1,10 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'active_decorator', :path => '..'
3
+ gem 'active_decorator', path: '..'
4
4
 
5
5
  gem 'rails', '~> 4.2.0'
6
- gem 'rspec-rails'
6
+ gem 'test-unit-rails'
7
7
  gem 'capybara'
8
8
  gem 'sqlite3'
9
+ gem 'nokogiri', '~> 1.6.0'
9
10
  gem 'jbuilder'
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'active_decorator', path: '..'
4
+
5
+ gem 'rails', '~> 5.0.0'
6
+ gem 'test-unit-rails'
7
+ gem 'capybara'
8
+ gem 'sqlite3'
9
+ gem 'jbuilder'
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'active_decorator', path: '..'
4
+
5
+ gem 'rails', '5.1.0'
6
+ gem 'test-unit-rails'
7
+ gem 'capybara'
8
+ gem 'sqlite3'
9
+ gem 'jbuilder'
@@ -1,20 +1,6 @@
1
+ # frozen_string_literal: true
1
2
  module ActiveDecorator
2
- def self.configure(&block)
3
- yield @config ||= ActiveDecorator::Configuration.new
4
- end
3
+ include ActiveSupport::Configurable
5
4
 
6
- def self.config
7
- @config
8
- end
9
-
10
- # need a Class for 3.0
11
- class Configuration #:nodoc:
12
- include ActiveSupport::Configurable
13
-
14
- config_accessor :decorator_suffix
15
- end
16
-
17
- configure do |config|
18
- config.decorator_suffix = 'Decorator'
19
- end
5
+ config.decorator_suffix = 'Decorator'
20
6
  end
@@ -1,11 +1,15 @@
1
- module ActionController
2
- class Base
3
- def rescue_with_handler_with_decorator_view_context(exception)
4
- ActiveDecorator::ViewContext.push(view_context)
5
- rescue_with_handler_without_decorator_view_context(exception)
6
- ensure
7
- ActiveDecorator::ViewContext.pop
1
+ # frozen_string_literal: true
2
+ module ActiveDecorator
3
+ module Monkey
4
+ module ActionController
5
+ module Base
6
+ def rescue_with_handler(*)
7
+ ActiveDecorator::ViewContext.push(view_context)
8
+ super
9
+ ensure
10
+ ActiveDecorator::ViewContext.pop
11
+ end
12
+ end
8
13
  end
9
- alias_method_chain :rescue_with_handler, :decorator_view_context
10
14
  end
11
15
  end
@@ -1,17 +1,28 @@
1
+ # frozen_string_literal: true
1
2
  module ActiveDecorator
2
3
  module ViewContext
3
4
  class << self
4
5
  def current
5
- Thread.current[:active_decorator_view_contexts].last
6
+ view_context_stack.last
6
7
  end
7
8
 
8
9
  def push(view_context)
9
- Thread.current[:active_decorator_view_contexts] ||= []
10
- Thread.current[:active_decorator_view_contexts] << view_context
10
+ view_context_stack.push view_context
11
11
  end
12
12
 
13
13
  def pop
14
- Thread.current[:active_decorator_view_contexts].pop if Thread.current[:active_decorator_view_contexts]
14
+ view_context_stack.pop
15
+ end
16
+
17
+ def view_context_stack
18
+ Thread.current[:active_decorator_view_contexts] ||= []
19
+ end
20
+
21
+ def run_with(view_context)
22
+ push view_context
23
+ yield
24
+ ensure
25
+ pop
15
26
  end
16
27
  end
17
28
 
@@ -21,20 +32,14 @@ module ActiveDecorator
21
32
  included do
22
33
  if Rails::VERSION::MAJOR >= 4
23
34
  around_action do |controller, blk|
24
- begin
25
- ActiveDecorator::ViewContext.push controller.view_context
35
+ ActiveDecorator::ViewContext.run_with(controller.view_context) do
26
36
  blk.call
27
- ensure
28
- ActiveDecorator::ViewContext.pop
29
37
  end
30
38
  end
31
39
  else
32
40
  around_filter do |controller, blk|
33
- begin
34
- ActiveDecorator::ViewContext.push controller.view_context
41
+ ActiveDecorator::ViewContext.run_with(controller.view_context) do
35
42
  blk.call
36
- ensure
37
- ActiveDecorator::ViewContext.pop
38
43
  end
39
44
  end
40
45
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Rails
2
3
  module Generators
3
4
  class DecoratorGenerator < Rails::Generators::NamedBase
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Rspec
2
3
  class DecoratorGenerator < ::Rails::Generators::NamedBase
3
4
  source_root File.expand_path('../templates', __FILE__)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module TestUnit
2
3
  class DecoratorGenerator < ::Rails::Generators::NamedBase
3
4
  source_root File.expand_path('../templates', __FILE__)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'active_decorator/view_context'
2
3
  require 'lulalala_presenter/active_model_bridge'
3
4
  require 'rails'
@@ -5,16 +6,20 @@ require 'rails'
5
6
  module LulalalaPresenter
6
7
  class Railtie < ::Rails::Railtie
7
8
  initializer 'active_decorator' do
8
- ActiveSupport.on_load(:action_controller) do
9
+ ActiveSupport.on_load :action_controller do
9
10
  require 'active_decorator/monkey/action_controller/base/rescue_from'
11
+ ActionController::Base.send :prepend, ActiveDecorator::Monkey::ActionController::Base
12
+
10
13
  ActionController::Base.send :include, ActiveDecorator::ViewContext::Filter
11
14
  end
12
- ActiveSupport.on_load(:action_mailer) do
15
+
16
+ ActiveSupport.on_load :action_mailer do
13
17
  if ActionMailer::Base.respond_to? :before_action
14
18
  ActionMailer::Base.send :include, ActiveDecorator::ViewContext::Filter
15
19
  end
16
20
  end
17
- ActiveSupport.on_load(:active_record) do
21
+
22
+ ActiveSupport.on_load :active_record do
18
23
  ActiveRecord::Base.send :include, LulalalaPresenter::ActiveModelBridge
19
24
  end
20
25
  end
@@ -1,3 +1,3 @@
1
1
  module LulalalaPresenter
2
- VERSION = '0.0.1'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -1,4 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ # frozen_string_literal: true
2
3
  $:.push File.expand_path("../lib", __FILE__)
3
4
  require "lulalala_presenter/version"
4
5
 
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+ require 'test_helper'
3
+
4
+ Comic = Struct.new(:title, :price)
5
+
6
+ class ComicPresenter < LulalalaPresenter::Base
7
+ def price
8
+ "$#{super}"
9
+ end
10
+ end
11
+
12
+ class ConfigurationTest < Test::Unit::TestCase
13
+ test 'with a custom decorator_suffix' do
14
+ pend
15
+ begin
16
+ ActiveDecorator.configure do |config|
17
+ config.decorator_suffix = 'Presenter'
18
+ end
19
+
20
+ comic = Comic.new("amatsuda's (Poignant) Guide to ActiveDecorator", 3)
21
+ assert_equal '$3', comic.presenter.price
22
+ ensure
23
+ LulalalPresenter.configure do |config|
24
+ config.decorator_suffix = 'Presenter'
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+ require 'test_helper'
3
+
4
+ class MoviesControllerTest < ActionController::TestCase
5
+ test 'reveals fakes' do
6
+ movie = Movie.create
7
+ if Rails::VERSION::MAJOR >= 5
8
+ assert_nothing_raised { get :show, params: {id: movie.id} }
9
+ else
10
+ assert_nothing_raised { get :show, id: movie.id }
11
+ end
12
+ end
13
+ end
@@ -1,12 +1,12 @@
1
1
  <% @authors.each do |author| %>
2
2
  <%= author.name %>
3
- <%= author.reverse_name %>
3
+ <%= author.presenter.reverse_name %>
4
4
 
5
5
  <% if params[:partial] == 'collection' %>
6
6
  <%= render author.books %>
7
7
  <% elsif params[:partial] == 'locals' %>
8
8
  <% author.books.each do |book| %>
9
- <%= render :partial => 'books/book_locals', :locals => {:b => book} %>
9
+ <%= render partial: 'books/book_locals', locals: {b: book} %>
10
10
  <% end %>
11
11
  <% else %>
12
12
  <% author.books.each do |book| %>
@@ -0,0 +1,2 @@
1
+ <%= @author.name %>
2
+ <%= @author.presenter.capitalized_name %>
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+ json.name @author.name
3
+ json.books @author.books, partial: 'books/book', as: :book
@@ -0,0 +1 @@
1
+ Thank you for purchasing <%= @book.presenter.upcased_title %>.
@@ -0,0 +1,2 @@
1
+ <%= book.title %>
2
+ <%= book.presenter.reverse_title %>
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+ json.title book.title
3
+ json.reverse_title book.presenter.reverse_title
@@ -0,0 +1,2 @@
1
+ <%= b.title %>
2
+ <%= b.presenter.upcased_title %>
@@ -0,0 +1 @@
1
+ <%= @book.presenter.error %>
@@ -1,4 +1,4 @@
1
1
  <% @books.each do |book| %>
2
2
  <%= book.title %>
3
- <%= book.reverse_title %>
3
+ <%= book.presenter.reverse_title %>
4
4
  <% end %>
@@ -0,0 +1,4 @@
1
+ <%= @book.presenter.link %>
2
+ <%= @book.presenter.cover_image %>
3
+
4
+ <%= link_to 'purchase', [:purchase, @book.author, @book], method: :post %>
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'active_record'
2
3
  require 'action_controller/railtie'
3
4
  require 'action_mailer/railtie'
@@ -6,12 +7,12 @@ require 'ostruct'
6
7
  require 'jbuilder'
7
8
 
8
9
  # config
9
- ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
10
+ ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
10
11
 
11
12
  module ActiveDecoratorTestApp
12
13
  class Application < Rails::Application
13
14
  config.secret_token = '"confusion" will be my epitaph.'
14
- config.session_store :cookie_store, :key => '_myapp_session'
15
+ config.session_store :cookie_store, key: '_myapp_session'
15
16
  config.active_support.deprecation = :log
16
17
  config.eager_load = false
17
18
  config.action_dispatch.show_exceptions = false
@@ -24,15 +25,15 @@ ActiveDecoratorTestApp::Application.initialize!
24
25
 
25
26
  # routes
26
27
  ActiveDecoratorTestApp::Application.routes.draw do
27
- resources :authors, :only => [:index, :show] do
28
- resources :books, :only => [:index, :show] do
28
+ resources :authors, only: [:index, :show] do
29
+ resources :books, only: [:index, :show] do
29
30
  member do
30
31
  get :error
31
32
  post :purchase
32
33
  end
33
34
  end
34
35
  end
35
- resources :movies, :only => :show
36
+ resources :movies, only: :show
36
37
  end
37
38
 
38
39
  # models
@@ -49,30 +50,30 @@ end
49
50
  module ApplicationHelper; end
50
51
 
51
52
  # decorators
52
- module AuthorDecorator
53
+ class AuthorPresenter < LulalalaPresenter::Base
53
54
  def reverse_name
54
- name.reverse
55
+ model.name.reverse
55
56
  end
56
57
 
57
58
  def capitalized_name
58
- name.capitalize
59
+ model.name.capitalize
59
60
  end
60
61
  end
61
- module BookDecorator
62
+ class BookPresenter < LulalalaPresenter::Base
62
63
  def reverse_title
63
- title.reverse
64
+ model.title.reverse
64
65
  end
65
66
 
66
67
  def upcased_title
67
- title.upcase
68
+ model.title.upcase
68
69
  end
69
70
 
70
71
  def link
71
- link_to title, "#{request.protocol}#{request.host_with_port}/assets/sample.png", :class => 'title'
72
+ h.link_to model.title, "#{h.request.protocol}#{h.request.host_with_port}/assets/sample.png", class: 'title'
72
73
  end
73
74
 
74
75
  def cover_image
75
- image_tag 'cover.png'
76
+ h.image_tag 'cover.png'
76
77
  end
77
78
 
78
79
  def error
@@ -81,7 +82,7 @@ module BookDecorator
81
82
  end
82
83
 
83
84
  # decorator fake
84
- class MovieDecorator; end
85
+ class MoviePresenter < LulalalaPresenter::Base; end
85
86
 
86
87
  # controllers
87
88
  class ApplicationController < ActionController::Base
@@ -118,7 +119,7 @@ class BooksController < ApplicationController
118
119
  class CustomError < StandardError; end
119
120
 
120
121
  rescue_from CustomError do
121
- render "error"
122
+ render :error
122
123
  end
123
124
 
124
125
  def index
@@ -153,12 +154,12 @@ end
153
154
  class BookMailer < ActionMailer::Base
154
155
  def thanks(book)
155
156
  @book = book
156
- mail :from => 'nobody@example.com', :to => 'test@example.com', :subject => 'Thanks'
157
+ mail from: 'nobody@example.com', to: 'test@example.com', subject: 'Thanks'
157
158
  end
158
159
  end
159
160
 
160
161
  # migrations
161
- class CreateAllTables < ActiveRecord::Migration
162
+ class CreateAllTables < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[5.0] : ActiveRecord::Migration
162
163
  def self.up
163
164
  create_table(:authors) {|t| t.string :name}
164
165
  create_table(:books) {|t| t.string :title; t.references :author}
@@ -167,28 +168,14 @@ class CreateAllTables < ActiveRecord::Migration
167
168
  end
168
169
 
169
170
  # Proxy for ActiveRecord::Relation
170
- if RUBY_VERSION >= '1.9.0'
171
- class RelationProxy < BasicObject
172
- attr_accessor :ar_relation
171
+ class RelationProxy < BasicObject
172
+ attr_accessor :ar_relation
173
173
 
174
- def initialize(ar_relation)
175
- @ar_relation = ar_relation
176
- end
177
-
178
- def method_missing(method, *args, &block)
179
- @ar_relation.public_send(method, *args, &block)
180
- end
174
+ def initialize(ar_relation)
175
+ @ar_relation = ar_relation
181
176
  end
182
- else
183
- class RelationProxy < Object
184
- attr_accessor :ar_relation
185
177
 
186
- def initialize(ar_relation)
187
- @ar_relation = ar_relation
188
- end
189
-
190
- def method_missing(method, *args, &block)
191
- @ar_relation.send(method, *args, &block)
192
- end
178
+ def method_missing(method, *args, &block)
179
+ @ar_relation.public_send(method, *args, &block)
193
180
  end
194
181
  end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+ require 'test_helper'
3
+
4
+ class ActionViewHelpersTest < ActionDispatch::IntegrationTest
5
+ setup do
6
+ aamine = Author.create! name: 'aamine'
7
+ @rhg = aamine.books.create! title: 'RHG'
8
+ @rhg_novel = aamine.books.create! title: 'RHG Novel'
9
+ end
10
+
11
+ test 'invoking action_view helper methods' do
12
+ visit "/authors/#{@rhg.author.id}/books/#{@rhg.id}"
13
+ within 'a.title' do
14
+ assert page.has_content? 'RHG'
15
+ end
16
+ assert page.has_css?('img')
17
+ end
18
+
19
+ test 'invoking action_view helper methods on model subclass' do
20
+ visit "/authors/#{@rhg_novel.author.id}/books/#{@rhg_novel.id}"
21
+ within 'a.title' do
22
+ assert page.has_content? 'RHG Novel'
23
+ end
24
+ assert page.has_css?('img')
25
+ end
26
+
27
+ test 'invoking action_view helper methods in rescue_from view' do
28
+ visit "/authors/#{@rhg.author.id}/books/#{@rhg.id}/error"
29
+ assert page.has_content?('ERROR')
30
+ end
31
+
32
+ test 'make sure that action_view + action_mailer works' do
33
+ visit "/authors/#{@rhg.author.id}/books/#{@rhg.id}"
34
+ click_link 'purchase'
35
+ assert page.has_content? 'done'
36
+ end
37
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+ require 'test_helper'
3
+
4
+ class ControllerIvarTest < ActionDispatch::IntegrationTest
5
+ setup do
6
+ @matz = Author.create! name: 'matz'
7
+ @matz.books.create! title: 'the world of code'
8
+ Author.create! name: 'takahashim'
9
+ end
10
+
11
+ test 'decorating a model object in ivar' do
12
+ visit "/authors/#{@matz.id}"
13
+ assert page.has_content? 'matz'
14
+ assert page.has_content? 'matz'.capitalize
15
+ end
16
+
17
+ test 'decorating model scope in ivar' do
18
+ visit '/authors'
19
+ assert page.has_content? 'takahashim'
20
+ assert page.has_content? 'takahashim'.reverse
21
+ end
22
+
23
+ test "decorating models' array in ivar" do
24
+ visit '/authors?variable_type=array'
25
+ assert page.has_content? 'takahashim'
26
+ assert page.has_content? 'takahashim'.reverse
27
+ end
28
+
29
+ test "decorating models' proxy object in ivar" do
30
+ visit '/authors?variable_type=proxy'
31
+ assert page.has_content? 'takahashim'
32
+ assert page.has_content? 'takahashim'.reverse
33
+ end
34
+
35
+ test 'decorating model association proxy in ivar' do
36
+ visit "/authors/#{@matz.id}/books"
37
+ assert page.has_content? 'the world of code'
38
+ assert page.has_content? 'the world of code'.reverse
39
+ end
40
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+ require 'test_helper'
3
+
4
+ class JbuilderTest < ActionDispatch::IntegrationTest
5
+ setup do
6
+ Author.create! name: 'aamine'
7
+ nari = Author.create! name: 'nari'
8
+ nari.books.create! title: 'the gc book'
9
+ end
10
+
11
+ test 'decorating objects in Jbuilder partials' do
12
+ visit "/authors/#{Author.last.id}.json"
13
+ assert_equal '{"name":"nari","books":[{"title":"the gc book","reverse_title":"koob cg eht"}]}', page.source
14
+ end
15
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+ require 'test_helper'
3
+
4
+ class PartialTest < ActionDispatch::IntegrationTest
5
+ setup do
6
+ Author.create! name: 'aamine'
7
+ nari = Author.create! name: 'nari'
8
+ nari.books.create! title: 'the gc book'
9
+ end
10
+
11
+ test 'decorating implicit @object' do
12
+ visit '/authors'
13
+ assert page.has_content? 'the gc book'
14
+ assert page.has_content? 'the gc book'.reverse
15
+ end
16
+
17
+ test 'decorating implicit @collection' do
18
+ visit '/authors?partial=collection'
19
+ assert page.has_content? 'the gc book'
20
+ assert page.has_content? 'the gc book'.reverse
21
+ end
22
+
23
+ test 'decorating objects in @locals' do
24
+ visit '/authors?partial=locals'
25
+ assert page.has_content? 'the gc book'
26
+ assert page.has_content? 'the gc book'.upcase
27
+ end
28
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
4
+ # load Rails first
5
+ require 'rails'
6
+
7
+ # load the plugin
8
+ require 'lulalala_presenter'
9
+
10
+ # needs to load the app next
11
+ require 'fake_app/fake_app'
12
+
13
+ require 'test/unit/rails/test_help'
14
+
15
+ class ActionDispatch::IntegrationTest
16
+ include Capybara::DSL
17
+ end
18
+
19
+ module DatabaseDeleter
20
+ def setup
21
+ Book.delete_all
22
+ Author.delete_all
23
+ Movie.delete_all
24
+ super
25
+ end
26
+ end
27
+
28
+ Test::Unit::TestCase.send :prepend, DatabaseDeleter
29
+
30
+ CreateAllTables.up unless ActiveRecord::Base.connection.table_exists? 'authors'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lulalala_presenter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - lulalala
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-11-14 00:00:00.000000000 Z
12
+ date: 2017-11-19 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A simple and Rubyish view helper for Rails
15
15
  email:
@@ -20,20 +20,18 @@ extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
22
22
  - ".gitignore"
23
- - ".rspec"
24
23
  - ".travis.yml"
25
24
  - Gemfile
26
25
  - MIT-LICENSE
27
26
  - README.md
28
27
  - Rakefile
29
- - gemfiles/Gemfile-rails.3.0.x
30
- - gemfiles/Gemfile-rails.3.1.x
31
28
  - gemfiles/Gemfile-rails.3.2.x
32
29
  - gemfiles/Gemfile-rails.4.0.x
33
30
  - gemfiles/Gemfile-rails.4.1.x
34
31
  - gemfiles/Gemfile-rails.4.2.x
32
+ - gemfiles/Gemfile-rails.5.0.x
33
+ - gemfiles/Gemfile-rails.5.1.x
35
34
  - lib/active_decorator/config.rb
36
- - lib/active_decorator/helpers.rb
37
35
  - lib/active_decorator/monkey/action_controller/base/rescue_from.rb
38
36
  - lib/active_decorator/view_context.rb
39
37
  - lib/generators/rails/decorator_generator.rb
@@ -48,26 +46,26 @@ files:
48
46
  - lib/lulalala_presenter/railtie.rb
49
47
  - lib/lulalala_presenter/version.rb
50
48
  - lulalala_presenter.gemspec
51
- - spec/configuration_spec.rb
52
- - spec/controllers/fake_detection_spec.rb
53
- - spec/fake_app/app/views/authors/index.html.erb
54
- - spec/fake_app/app/views/authors/show.html.erb
55
- - spec/fake_app/app/views/authors/show.json.jbuilder
56
- - spec/fake_app/app/views/book_mailer/thanks.text.erb
57
- - spec/fake_app/app/views/books/_book.html.erb
58
- - spec/fake_app/app/views/books/_book.json.jbuilder
59
- - spec/fake_app/app/views/books/_book_locals.html.erb
60
- - spec/fake_app/app/views/books/error.html.erb
61
- - spec/fake_app/app/views/books/index.html.erb
62
- - spec/fake_app/app/views/books/purchase.html.erb
63
- - spec/fake_app/app/views/books/show.html.erb
64
- - spec/fake_app/app/views/movies/show.html.erb
65
- - spec/fake_app/fake_app.rb
66
- - spec/features/action_view_helpers_spec.rb
67
- - spec/features/controller_ivar_spec.rb
68
- - spec/features/jbuilder_spec.rb
69
- - spec/features/partial_spec.rb
70
- - spec/spec_helper.rb
49
+ - test/configuration_test.rb
50
+ - test/controllers/fake_detection_test.rb
51
+ - test/fake_app/app/views/authors/index.html.erb
52
+ - test/fake_app/app/views/authors/show.html.erb
53
+ - test/fake_app/app/views/authors/show.json.jbuilder
54
+ - test/fake_app/app/views/book_mailer/thanks.text.erb
55
+ - test/fake_app/app/views/books/_book.html.erb
56
+ - test/fake_app/app/views/books/_book.json.jbuilder
57
+ - test/fake_app/app/views/books/_book_locals.html.erb
58
+ - test/fake_app/app/views/books/error.html.erb
59
+ - test/fake_app/app/views/books/index.html.erb
60
+ - test/fake_app/app/views/books/purchase.html.erb
61
+ - test/fake_app/app/views/books/show.html.erb
62
+ - test/fake_app/app/views/movies/show.html.erb
63
+ - test/fake_app/fake_app.rb
64
+ - test/features/action_view_helpers_test.rb
65
+ - test/features/controller_ivar_test.rb
66
+ - test/features/jbuilder_test.rb
67
+ - test/features/partial_test.rb
68
+ - test/test_helper.rb
71
69
  homepage: https://github.com/lulalala/lulalala_presenter
72
70
  licenses: []
73
71
  metadata: {}
@@ -92,23 +90,23 @@ signing_key:
92
90
  specification_version: 4
93
91
  summary: A simple and Rubyish view helper for Rails
94
92
  test_files:
95
- - spec/configuration_spec.rb
96
- - spec/controllers/fake_detection_spec.rb
97
- - spec/fake_app/app/views/authors/index.html.erb
98
- - spec/fake_app/app/views/authors/show.html.erb
99
- - spec/fake_app/app/views/authors/show.json.jbuilder
100
- - spec/fake_app/app/views/book_mailer/thanks.text.erb
101
- - spec/fake_app/app/views/books/_book.html.erb
102
- - spec/fake_app/app/views/books/_book.json.jbuilder
103
- - spec/fake_app/app/views/books/_book_locals.html.erb
104
- - spec/fake_app/app/views/books/error.html.erb
105
- - spec/fake_app/app/views/books/index.html.erb
106
- - spec/fake_app/app/views/books/purchase.html.erb
107
- - spec/fake_app/app/views/books/show.html.erb
108
- - spec/fake_app/app/views/movies/show.html.erb
109
- - spec/fake_app/fake_app.rb
110
- - spec/features/action_view_helpers_spec.rb
111
- - spec/features/controller_ivar_spec.rb
112
- - spec/features/jbuilder_spec.rb
113
- - spec/features/partial_spec.rb
114
- - spec/spec_helper.rb
93
+ - test/configuration_test.rb
94
+ - test/controllers/fake_detection_test.rb
95
+ - test/fake_app/app/views/authors/index.html.erb
96
+ - test/fake_app/app/views/authors/show.html.erb
97
+ - test/fake_app/app/views/authors/show.json.jbuilder
98
+ - test/fake_app/app/views/book_mailer/thanks.text.erb
99
+ - test/fake_app/app/views/books/_book.html.erb
100
+ - test/fake_app/app/views/books/_book.json.jbuilder
101
+ - test/fake_app/app/views/books/_book_locals.html.erb
102
+ - test/fake_app/app/views/books/error.html.erb
103
+ - test/fake_app/app/views/books/index.html.erb
104
+ - test/fake_app/app/views/books/purchase.html.erb
105
+ - test/fake_app/app/views/books/show.html.erb
106
+ - test/fake_app/app/views/movies/show.html.erb
107
+ - test/fake_app/fake_app.rb
108
+ - test/features/action_view_helpers_test.rb
109
+ - test/features/controller_ivar_test.rb
110
+ - test/features/jbuilder_test.rb
111
+ - test/features/partial_test.rb
112
+ - test/test_helper.rb
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --require spec_helper
@@ -1,16 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'active_decorator', :path => '..'
4
-
5
- gem 'rails', '~> 3.0.0'
6
- gem 'rspec-rails', '~> 2.14.0'
7
- gem 'capybara', '~> 2.0.0'
8
- # rubyzip >=1 doesn't support ruby 1.8
9
- gem 'rubyzip', '< 1.0.0'
10
- gem 'sqlite3'
11
- gem 'nokogiri', '~> 1.5.0'
12
- if RUBY_VERSION <= '1.8.7'
13
- gem 'jbuilder', '< 2'
14
- else
15
- gem 'jbuilder'
16
- end
@@ -1,19 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'active_decorator', :path => '..'
4
-
5
- gem 'rails', '~> 3.1.0'
6
- gem 'rspec-rails', '~> 2.14.0'
7
- if RUBY_VERSION <= '1.8.7'
8
- gem 'i18n', '~> 0.6.11'
9
- end
10
- gem 'capybara', '~> 2.0.0'
11
- # rubyzip >=1 doesn't support ruby 1.8
12
- gem 'rubyzip', '< 1.0.0'
13
- gem 'sqlite3'
14
- gem 'nokogiri', '~> 1.5.0'
15
- if RUBY_VERSION <= '1.8.7'
16
- gem 'jbuilder', '< 2'
17
- else
18
- gem 'jbuilder'
19
- end
@@ -1,14 +0,0 @@
1
- module ActiveDecorator
2
- module Helpers
3
- def method_missing(method, *args, &block)
4
- super
5
- #TODO need to make sure who raised the error?
6
- rescue NoMethodError, NameError => original_error
7
- begin
8
- ActiveDecorator::ViewContext.current.send method, *args, &block
9
- rescue NoMethodError, NameError
10
- raise original_error
11
- end
12
- end
13
- end
14
- end
@@ -1,27 +0,0 @@
1
- Comic = Struct.new(:title, :price)
2
-
3
- module ComicPresenter
4
- def price
5
- "$#{super}"
6
- end
7
- end
8
-
9
- describe ActiveDecorator::Configuration do
10
- let(:comic) { ActiveDecorator::Decorator.instance.decorate(Comic.new("amatsuda's (Poignant) Guide to ActiveDecorator", 3)) }
11
-
12
- context 'with a custom decorator_suffix' do
13
- before do
14
- ActiveDecorator.configure do |config|
15
- config.decorator_suffix = 'Presenter'
16
- end
17
- end
18
-
19
- after do
20
- ActiveDecorator.configure do |config|
21
- config.decorator_suffix = 'Decorator'
22
- end
23
- end
24
-
25
- specify { comic.price.should == '$3' }
26
- end
27
- end
@@ -1,7 +0,0 @@
1
- describe MoviesController, :type => :controller do
2
- let(:movie){ Movie.create }
3
-
4
- it 'reveals fakes' do
5
- expect{ get :show, :id => movie.id }.not_to raise_error
6
- end
7
- end
@@ -1,2 +0,0 @@
1
- <%= @author.name %>
2
- <%= @author.capitalized_name %>
@@ -1,2 +0,0 @@
1
- json.name @author.name
2
- json.books @author.books, :partial => 'books/book', :as => :book
@@ -1 +0,0 @@
1
- Thank you for purchasing <%= @book.upcased_title %>.
@@ -1,2 +0,0 @@
1
- <%= book.title %>
2
- <%= book.reverse_title %>
@@ -1,2 +0,0 @@
1
- json.title book.title
2
- json.reverse_title book.reverse_title
@@ -1,2 +0,0 @@
1
- <%= b.title %>
2
- <%= b.upcased_title %>
@@ -1 +0,0 @@
1
- <%= @book.error %>
@@ -1,4 +0,0 @@
1
- <%= @book.link %>
2
- <%= @book.cover_image %>
3
-
4
- <%= link_to 'purchase', [:purchase, @book.author, @book], :method => :post %>
@@ -1,25 +0,0 @@
1
- feature 'fallback to helpers' do
2
- background do
3
- aamine = Author.create! :name => 'aamine'
4
- @rhg = aamine.books.create! :title => 'RHG'
5
- end
6
-
7
- scenario 'invoking action_view helper methods' do
8
- visit "/authors/#{@rhg.author.id}/books/#{@rhg.id}"
9
- within 'a.title' do
10
- page.should have_content 'RHG'
11
- end
12
- page.should have_css('img')
13
- end
14
-
15
- scenario 'invoking action_view helper methods in rescue_from view' do
16
- visit "/authors/#{@rhg.author.id}/books/#{@rhg.id}/error"
17
- page.should have_content('ERROR')
18
- end
19
-
20
- scenario 'make sure that action_view + action_mailer works' do
21
- visit "/authors/#{@rhg.author.id}/books/#{@rhg.id}"
22
- click_link 'purchase'
23
- page.should have_content 'done'
24
- end
25
- end
@@ -1,37 +0,0 @@
1
- feature 'decorating controller ivar' do
2
- background do
3
- @matz = Author.create! :name => 'matz'
4
- @matz.books.create! :title => 'the world of code'
5
- Author.create! :name => 'takahashim'
6
- end
7
-
8
- scenario 'decorating a model object in ivar' do
9
- visit "/authors/#{@matz.id}"
10
- page.should have_content 'matz'
11
- page.should have_content 'matz'.capitalize
12
- end
13
-
14
- scenario 'decorating model scope in ivar' do
15
- visit '/authors'
16
- page.should have_content 'takahashim'
17
- page.should have_content 'takahashim'.reverse
18
- end
19
-
20
- scenario "decorating models' array in ivar" do
21
- visit '/authors?variable_type=array'
22
- page.should have_content 'takahashim'
23
- page.should have_content 'takahashim'.reverse
24
- end
25
-
26
- scenario "decorating models' proxy object in ivar" do
27
- visit '/authors?variable_type=proxy'
28
- page.should have_content 'takahashim'
29
- page.should have_content 'takahashim'.reverse
30
- end
31
-
32
- scenario 'decorating model association proxy in ivar' do
33
- visit "/authors/#{@matz.id}/books"
34
- page.should have_content 'the world of code'
35
- page.should have_content 'the world of code'.reverse
36
- end
37
- end
@@ -1,12 +0,0 @@
1
- feature 'decorating partial object in Jbuilder' do
2
- background do
3
- Author.create! :name => 'aamine'
4
- nari = Author.create! :name => 'nari'
5
- nari.books.create! :title => 'the gc book'
6
- end
7
-
8
- scenario 'decorating objects in Jbuilder partials' do
9
- visit "/authors/#{Author.last.id}.json"
10
- page.source.should eq '{"name":"nari","books":[{"title":"the gc book","reverse_title":"koob cg eht"}]}'
11
- end
12
- end
@@ -1,25 +0,0 @@
1
- feature 'decorating partial object' do
2
- background do
3
- Author.create! :name => 'aamine'
4
- nari = Author.create! :name => 'nari'
5
- nari.books.create! :title => 'the gc book'
6
- end
7
-
8
- scenario 'decorating implicit @object' do
9
- visit '/authors'
10
- page.should have_content 'the gc book'
11
- page.should have_content 'the gc book'.reverse
12
- end
13
-
14
- scenario 'decorating implicit @collection' do
15
- visit '/authors?partial=collection'
16
- page.should have_content 'the gc book'
17
- page.should have_content 'the gc book'.reverse
18
- end
19
-
20
- scenario 'decorating objects in @locals' do
21
- visit '/authors?partial=locals'
22
- page.should have_content 'the gc book'
23
- page.should have_content 'the gc book'.upcase
24
- end
25
- end
@@ -1,27 +0,0 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- $LOAD_PATH.unshift(File.dirname(__FILE__))
3
- # load Rails first
4
- require 'rails'
5
- require 'active_decorator'
6
- # needs to load the app before loading rspec/rails => capybara
7
- require 'fake_app/fake_app'
8
- require 'rspec/rails'
9
- # Requires supporting files with custom matchers and macros, etc,
10
- # in ./support/ and its subdirectories.
11
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
12
-
13
- RSpec.configure do |config|
14
- config.expect_with :rspec do |c|
15
- c.syntax = [:should, :expect]
16
- end
17
-
18
- config.before :all do
19
- CreateAllTables.up unless ActiveRecord::Base.connection.table_exists? 'authors'
20
- end
21
-
22
- config.before :each do
23
- Book.delete_all
24
- Author.delete_all
25
- Movie.delete_all
26
- end
27
- end