base_presenter 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +12 -1
- data/base_presenter.gemspec +2 -2
- data/lib/application_helper.rb +11 -3
- data/lib/base_presenter.rb +22 -8
- data/lib/base_presenter/version.rb +1 -1
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/helpers/dummy_helper.rb +2 -2
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/models/{dummy.rb → dummy_model.rb} +1 -1
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +12 -0
- data/spec/dummy/config/boot.rb +4 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/routes.rb +56 -0
- data/spec/dummy/db/seeds.rb +7 -0
- data/spec/dummy/log/test.log +0 -0
- data/spec/helpers/base_presenter_spec.rb +51 -0
- data/spec/spec_helper.rb +2 -11
- metadata +47 -9
- data/spec/base_presenter_spec.rb +0 -27
- data/spec/dummy/app/presenters/dummy_presenter.rb +0 -7
data/README.md
CHANGED
@@ -27,10 +27,21 @@ In director root_rails/app/presenters create file example_presenter.rb with cont
|
|
27
27
|
def name
|
28
28
|
"Name"
|
29
29
|
end
|
30
|
+
|
31
|
+
def self.class_name
|
32
|
+
"Example"
|
33
|
+
end
|
30
34
|
end
|
31
35
|
|
32
|
-
and in file show.html.erb
|
36
|
+
and in file show.html.erb with:
|
37
|
+
* object @example
|
33
38
|
|
34
39
|
<% present @example do |presenter| %>
|
35
40
|
Name: <%= presenter.name %>
|
36
41
|
<% end %>
|
42
|
+
|
43
|
+
* class Example
|
44
|
+
|
45
|
+
<% present Example do |presenter| %>
|
46
|
+
Class name: <%= presenter.class_name %>
|
47
|
+
<% end %>
|
data/base_presenter.gemspec
CHANGED
@@ -6,7 +6,7 @@ require 'base_presenter/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "base_presenter"
|
8
8
|
spec.version = BasePresenter::VERSION
|
9
|
-
spec.date = '2013-10-
|
9
|
+
spec.date = '2013-10-10'
|
10
10
|
spec.authors = ["Michał Szyma"]
|
11
11
|
spec.email = ["raglub.ruby@gmail.com"]
|
12
12
|
spec.description = %q{The gem adds "Presenter" functionality into Rails application}
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.3"
|
23
23
|
spec.add_development_dependency "rake"
|
24
|
-
spec.add_development_dependency 'rspec'
|
24
|
+
spec.add_development_dependency 'rspec-rails'
|
25
25
|
spec.add_development_dependency 'rails', ">= 3.0.0"
|
26
26
|
|
27
27
|
end
|
data/lib/application_helper.rb
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
module ApplicationHelper
|
2
|
-
def present(
|
3
|
-
|
4
|
-
|
2
|
+
def present(object_or_class, klass = nil)
|
3
|
+
presenter = nil
|
4
|
+
|
5
|
+
if object_or_class.methods.include?(:new)
|
6
|
+
klass ||= "#{object_or_class}Presenter".constantize
|
7
|
+
presenter = klass
|
8
|
+
presenter.template = self
|
9
|
+
else
|
10
|
+
klass ||= "#{object_or_class.class}Presenter".constantize
|
11
|
+
presenter = klass.new(object_or_class, self)
|
12
|
+
end
|
5
13
|
|
6
14
|
yield presenter if block_given?
|
7
15
|
return presenter
|
data/lib/base_presenter.rb
CHANGED
@@ -7,21 +7,35 @@ class BasePresenter
|
|
7
7
|
@template = template
|
8
8
|
end
|
9
9
|
|
10
|
-
def self.presents(name)
|
11
|
-
define_method(name) do
|
12
|
-
@object
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
10
|
def method_missing(*args, &block)
|
17
|
-
|
11
|
+
h.send(*args, &block)
|
18
12
|
end
|
19
13
|
|
20
14
|
def handle_none(value)
|
21
15
|
if value.present?
|
22
16
|
yield
|
23
17
|
else
|
24
|
-
|
18
|
+
h.content_tag :span, "None given", class: "none"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class << self
|
23
|
+
attr_accessor :template
|
24
|
+
|
25
|
+
def presents(name)
|
26
|
+
define_method(name) do
|
27
|
+
@object
|
28
|
+
end
|
25
29
|
end
|
26
30
|
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def self.h
|
35
|
+
@@template
|
36
|
+
end
|
37
|
+
|
38
|
+
def h
|
39
|
+
@template
|
40
|
+
end
|
27
41
|
end
|
File without changes
|
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module DummyHelper
|
2
|
+
# extend ApplicationHelper
|
3
3
|
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
|
6
|
+
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#require 'rails/all'
|
2
|
+
require "action_controller/railtie"
|
3
|
+
require "action_mailer/railtie"
|
4
|
+
require "sprockets/railtie"
|
5
|
+
# Require the gems listed in Gemfile, including any gems
|
6
|
+
# you've limited to :test, :development, or :production.
|
7
|
+
Bundler.require(:default, Rails.env)
|
8
|
+
|
9
|
+
module Dummy
|
10
|
+
class Application < Rails::Application
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Do not eager load code on boot.
|
10
|
+
config.eager_load = false
|
11
|
+
|
12
|
+
# Show full error reports and disable caching.
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Don't care if the mailer can't send.
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
18
|
+
|
19
|
+
# Print deprecation notices to the Rails logger.
|
20
|
+
config.active_support.deprecation = :log
|
21
|
+
|
22
|
+
# Raise an error on page load if there are pending migrations
|
23
|
+
config.active_record.migration_error = :page_load
|
24
|
+
|
25
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
26
|
+
# This option may cause significant delays in view rendering with a large
|
27
|
+
# number of complex assets.
|
28
|
+
config.assets.debug = true
|
29
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# Code is not reloaded between requests.
|
5
|
+
config.cache_classes = true
|
6
|
+
|
7
|
+
# Eager load code on boot. This eager loads most of Rails and
|
8
|
+
# your application in memory, allowing both thread web servers
|
9
|
+
# and those relying on copy on write to perform better.
|
10
|
+
# Rake tasks automatically ignore this option for performance.
|
11
|
+
config.eager_load = true
|
12
|
+
|
13
|
+
# Full error reports are disabled and caching is turned on.
|
14
|
+
config.consider_all_requests_local = false
|
15
|
+
config.action_controller.perform_caching = true
|
16
|
+
|
17
|
+
# Enable Rack::Cache to put a simple HTTP cache in front of your application
|
18
|
+
# Add `rack-cache` to your Gemfile before enabling this.
|
19
|
+
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
|
20
|
+
# config.action_dispatch.rack_cache = true
|
21
|
+
|
22
|
+
# Disable Rails's static asset server (Apache or nginx will already do this).
|
23
|
+
config.serve_static_assets = false
|
24
|
+
|
25
|
+
# Compress JavaScripts and CSS.
|
26
|
+
config.assets.js_compressor = :uglifier
|
27
|
+
# config.assets.css_compressor = :sass
|
28
|
+
|
29
|
+
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
30
|
+
config.assets.compile = false
|
31
|
+
|
32
|
+
# Generate digests for assets URLs.
|
33
|
+
config.assets.digest = true
|
34
|
+
|
35
|
+
# Version of your assets, change this if you want to expire all your assets.
|
36
|
+
config.assets.version = '1.0'
|
37
|
+
|
38
|
+
# Specifies the header that your server uses for sending files.
|
39
|
+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
40
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
41
|
+
|
42
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
43
|
+
# config.force_ssl = true
|
44
|
+
|
45
|
+
# Set to :debug to see everything in the log.
|
46
|
+
config.log_level = :info
|
47
|
+
|
48
|
+
# Prepend all log lines with the following tags.
|
49
|
+
# config.log_tags = [ :subdomain, :uuid ]
|
50
|
+
|
51
|
+
# Use a different logger for distributed setups.
|
52
|
+
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
53
|
+
|
54
|
+
# Use a different cache store in production.
|
55
|
+
# config.cache_store = :mem_cache_store
|
56
|
+
|
57
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
58
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
59
|
+
|
60
|
+
# Precompile additional assets.
|
61
|
+
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
62
|
+
# config.assets.precompile += %w( search.js )
|
63
|
+
|
64
|
+
# Ignore bad email addresses and do not raise email delivery errors.
|
65
|
+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
66
|
+
# config.action_mailer.raise_delivery_errors = false
|
67
|
+
|
68
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
69
|
+
# the I18n.default_locale when a translation can not be found).
|
70
|
+
config.i18n.fallbacks = true
|
71
|
+
|
72
|
+
# Send deprecation notices to registered listeners.
|
73
|
+
config.active_support.deprecation = :notify
|
74
|
+
|
75
|
+
# Disable automatic flushing of the log to improve performance.
|
76
|
+
# config.autoflush_log = false
|
77
|
+
|
78
|
+
# Use default logging formatter so that PID and timestamp are not suppressed.
|
79
|
+
config.log_formatter = ::Logger::Formatter.new
|
80
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Do not eager load code on boot. This avoids loading your whole application
|
11
|
+
# just for the purpose of running a single test. If you are using a tool that
|
12
|
+
# preloads Rails for running tests, you may have to set it to true.
|
13
|
+
config.eager_load = false
|
14
|
+
|
15
|
+
# Configure static asset server for tests with Cache-Control for performance.
|
16
|
+
config.serve_static_assets = true
|
17
|
+
config.static_cache_control = "public, max-age=3600"
|
18
|
+
|
19
|
+
# Show full error reports and disable caching.
|
20
|
+
config.consider_all_requests_local = true
|
21
|
+
config.action_controller.perform_caching = false
|
22
|
+
|
23
|
+
# Raise exceptions instead of rendering exception templates.
|
24
|
+
config.action_dispatch.show_exceptions = false
|
25
|
+
|
26
|
+
# Disable request forgery protection in test environment.
|
27
|
+
config.action_controller.allow_forgery_protection = false
|
28
|
+
|
29
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
30
|
+
# The :test delivery method accumulates sent emails in the
|
31
|
+
# ActionMailer::Base.deliveries array.
|
32
|
+
config.action_mailer.delivery_method = :test
|
33
|
+
|
34
|
+
# Print deprecation notices to the stderr.
|
35
|
+
config.active_support.deprecation = :stderr
|
36
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key is used for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
|
6
|
+
# Make sure the secret is at least 30 characters and all random,
|
7
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
8
|
+
# You can use `rake secret` to generate a secure secret key.
|
9
|
+
|
10
|
+
# Make sure your secret_key_base is kept private
|
11
|
+
# if you're sharing your code publicly.
|
12
|
+
Dummy::Application.config.secret_key_base = '11655f0443b81ff7895b50d41240a00cee3ecdc65f268ccadffd341722e50c87d099467d0f8265edec7ac9993a0f826f1b2532bb68919d5c61646ff88ec26288'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
4
|
+
# is enabled by default.
|
5
|
+
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
8
|
+
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
|
9
|
+
end
|
10
|
+
|
11
|
+
# To enable root element in JSON for ActiveRecord objects.
|
12
|
+
# ActiveSupport.on_load(:active_record) do
|
13
|
+
# self.include_root_in_json = true
|
14
|
+
# end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
Dummy::Application.routes.draw do
|
2
|
+
# The priority is based upon order of creation: first created -> highest priority.
|
3
|
+
# See how all your routes lay out with "rake routes".
|
4
|
+
|
5
|
+
# You can have the root of your site routed with "root"
|
6
|
+
# root 'welcome#index'
|
7
|
+
|
8
|
+
# Example of regular route:
|
9
|
+
# get 'products/:id' => 'catalog#view'
|
10
|
+
|
11
|
+
# Example of named route that can be invoked with purchase_url(id: product.id)
|
12
|
+
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
|
13
|
+
|
14
|
+
# Example resource route (maps HTTP verbs to controller actions automatically):
|
15
|
+
# resources :products
|
16
|
+
|
17
|
+
# Example resource route with options:
|
18
|
+
# resources :products do
|
19
|
+
# member do
|
20
|
+
# get 'short'
|
21
|
+
# post 'toggle'
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# collection do
|
25
|
+
# get 'sold'
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
|
29
|
+
# Example resource route with sub-resources:
|
30
|
+
# resources :products do
|
31
|
+
# resources :comments, :sales
|
32
|
+
# resource :seller
|
33
|
+
# end
|
34
|
+
|
35
|
+
# Example resource route with more complex sub-resources:
|
36
|
+
# resources :products do
|
37
|
+
# resources :comments
|
38
|
+
# resources :sales do
|
39
|
+
# get 'recent', on: :collection
|
40
|
+
# end
|
41
|
+
# end
|
42
|
+
|
43
|
+
# Example resource route with concerns:
|
44
|
+
# concern :toggleable do
|
45
|
+
# post 'toggle'
|
46
|
+
# end
|
47
|
+
# resources :posts, concerns: :toggleable
|
48
|
+
# resources :photos, concerns: :toggleable
|
49
|
+
|
50
|
+
# Example resource route within a namespace:
|
51
|
+
# namespace :admin do
|
52
|
+
# # Directs /admin/products/* to Admin::ProductsController
|
53
|
+
# # (app/controllers/admin/products_controller.rb)
|
54
|
+
# resources :products
|
55
|
+
# end
|
56
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# This file should contain all the record creation needed to seed the database with its default values.
|
2
|
+
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
3
|
+
#
|
4
|
+
# Examples:
|
5
|
+
#
|
6
|
+
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
|
7
|
+
# Mayor.create(name: 'Emanuel', city: cities.first)
|
File without changes
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
class DummyModelPresenter < BasePresenter
|
3
|
+
presents :dummy
|
4
|
+
|
5
|
+
def name
|
6
|
+
dummy.name.upcase
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.name
|
10
|
+
"Class name"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe ApplicationHelper do
|
15
|
+
let(:dummy_model) { DummyModel.new }
|
16
|
+
|
17
|
+
let(:dummy_presenter) do
|
18
|
+
helper.present(dummy_model)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should initialize presenter" do
|
22
|
+
dummy_presenter
|
23
|
+
end
|
24
|
+
|
25
|
+
it "#presents" do
|
26
|
+
dummy_presenter.dummy.should eq dummy_model
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should show formated name" do
|
30
|
+
dummy_presenter.name.should eq("EXAMPLE NAME")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "#handle_none with not blank of value" do
|
34
|
+
value = "no empty"
|
35
|
+
dummy_presenter.handle_none(value) {value}.should eq(value)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "#handle_none with not blank of value" do
|
39
|
+
value = nil
|
40
|
+
dummy_presenter.handle_none(value) {value}.should match('<span class')
|
41
|
+
end
|
42
|
+
|
43
|
+
it ".template" do
|
44
|
+
helper.present(DummyModel).template.should_not be_nil
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should show class name" do
|
48
|
+
helper.present(DummyModel).name.should eq("Class name")
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,17 +1,8 @@
|
|
1
1
|
ENV["RAILS_ENV"] ||= 'test'
|
2
2
|
|
3
|
-
require
|
3
|
+
require ::File.expand_path('../dummy/config/environment', __FILE__)
|
4
|
+
require 'rspec/rails'
|
4
5
|
require 'base_presenter'
|
5
|
-
# Define the application and configuration
|
6
|
-
class Application < ::Rails::Application
|
7
|
-
# config.active_support.deprecation = :stderr
|
8
|
-
end
|
9
|
-
# Initialize the application
|
10
|
-
Application.initialize!
|
11
|
-
|
12
|
-
require_relative "dummy/app/helpers/dummy_helper.rb"
|
13
|
-
require_relative "dummy/app/models/dummy.rb"
|
14
|
-
require_relative "dummy/app/presenters/dummy_presenter.rb"
|
15
6
|
|
16
7
|
RSpec.configure do |config|
|
17
8
|
config.color_enabled = true
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: base_presenter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
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: 2013-10-
|
12
|
+
date: 2013-10-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
|
-
name: rspec
|
47
|
+
name: rspec-rails
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
@@ -91,10 +91,29 @@ files:
|
|
91
91
|
- lib/application_helper.rb
|
92
92
|
- lib/base_presenter.rb
|
93
93
|
- lib/base_presenter/version.rb
|
94
|
-
- spec/
|
94
|
+
- spec/dummy/app/controllers/application_controller.rb
|
95
|
+
- spec/dummy/app/controllers/concerns/.keep
|
96
|
+
- spec/dummy/app/helpers/application_helper.rb
|
95
97
|
- spec/dummy/app/helpers/dummy_helper.rb
|
96
|
-
- spec/dummy/app/models
|
97
|
-
- spec/dummy/app/
|
98
|
+
- spec/dummy/app/models/.keep
|
99
|
+
- spec/dummy/app/models/concerns/.keep
|
100
|
+
- spec/dummy/app/models/dummy_model.rb
|
101
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
102
|
+
- spec/dummy/config.ru
|
103
|
+
- spec/dummy/config/application.rb
|
104
|
+
- spec/dummy/config/boot.rb
|
105
|
+
- spec/dummy/config/environment.rb
|
106
|
+
- spec/dummy/config/environments/development.rb
|
107
|
+
- spec/dummy/config/environments/production.rb
|
108
|
+
- spec/dummy/config/environments/test.rb
|
109
|
+
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
110
|
+
- spec/dummy/config/initializers/secret_token.rb
|
111
|
+
- spec/dummy/config/initializers/session_store.rb
|
112
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
113
|
+
- spec/dummy/config/routes.rb
|
114
|
+
- spec/dummy/db/seeds.rb
|
115
|
+
- spec/dummy/log/test.log
|
116
|
+
- spec/helpers/base_presenter_spec.rb
|
98
117
|
- spec/spec_helper.rb
|
99
118
|
homepage: https://github.com/raglub/base_presenter
|
100
119
|
licenses:
|
@@ -122,8 +141,27 @@ signing_key:
|
|
122
141
|
specification_version: 3
|
123
142
|
summary: The gem adds "Presenter" functionality into Rails application
|
124
143
|
test_files:
|
125
|
-
- spec/
|
144
|
+
- spec/dummy/app/controllers/application_controller.rb
|
145
|
+
- spec/dummy/app/controllers/concerns/.keep
|
146
|
+
- spec/dummy/app/helpers/application_helper.rb
|
126
147
|
- spec/dummy/app/helpers/dummy_helper.rb
|
127
|
-
- spec/dummy/app/models
|
128
|
-
- spec/dummy/app/
|
148
|
+
- spec/dummy/app/models/.keep
|
149
|
+
- spec/dummy/app/models/concerns/.keep
|
150
|
+
- spec/dummy/app/models/dummy_model.rb
|
151
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
152
|
+
- spec/dummy/config.ru
|
153
|
+
- spec/dummy/config/application.rb
|
154
|
+
- spec/dummy/config/boot.rb
|
155
|
+
- spec/dummy/config/environment.rb
|
156
|
+
- spec/dummy/config/environments/development.rb
|
157
|
+
- spec/dummy/config/environments/production.rb
|
158
|
+
- spec/dummy/config/environments/test.rb
|
159
|
+
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
160
|
+
- spec/dummy/config/initializers/secret_token.rb
|
161
|
+
- spec/dummy/config/initializers/session_store.rb
|
162
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
163
|
+
- spec/dummy/config/routes.rb
|
164
|
+
- spec/dummy/db/seeds.rb
|
165
|
+
- spec/dummy/log/test.log
|
166
|
+
- spec/helpers/base_presenter_spec.rb
|
129
167
|
- spec/spec_helper.rb
|
data/spec/base_presenter_spec.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe BasePresenter do
|
4
|
-
let(:dummy) { Dummy.new }
|
5
|
-
|
6
|
-
let(:dummy_presenter) do
|
7
|
-
DummyHelper.present(dummy)
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should initialize presenter" do
|
11
|
-
dummy_presenter
|
12
|
-
end
|
13
|
-
|
14
|
-
it "#presents" do
|
15
|
-
dummy_presenter.dummy.should eq dummy
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should show formated name" do
|
19
|
-
dummy_presenter.name.should eq("EXAMPLE NAME")
|
20
|
-
end
|
21
|
-
|
22
|
-
it "#handle_none with not blank of value" do
|
23
|
-
value = "no empty"
|
24
|
-
dummy_presenter.handle_none(value) {value}.should eq(value)
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|