draper 0.17.0 → 1.0.0.beta2
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.
- data/.gitignore +3 -0
- data/.travis.yml +5 -0
- data/CHANGELOG.markdown +49 -0
- data/Gemfile +4 -0
- data/Rakefile +50 -31
- data/Readme.markdown +63 -92
- data/draper.gemspec +6 -4
- data/lib/draper/collection_decorator.rb +88 -0
- data/lib/draper/decoratable.rb +44 -0
- data/lib/draper/decorated_association.rb +55 -0
- data/lib/draper/decorator.rb +260 -0
- data/lib/draper/finders.rb +34 -0
- data/lib/draper/helper_proxy.rb +16 -0
- data/lib/draper/railtie.rb +17 -21
- data/lib/draper/security.rb +48 -0
- data/lib/draper/tasks/tu.rake +5 -0
- data/lib/draper/test/minitest_integration.rb +5 -24
- data/lib/draper/test/rspec_integration.rb +0 -6
- data/lib/draper/test/test_unit_integration.rb +9 -0
- data/lib/draper/version.rb +1 -1
- data/lib/draper/view_context.rb +24 -6
- data/lib/draper/view_helpers.rb +36 -0
- data/lib/draper.rb +48 -7
- data/lib/generators/decorator/decorator_generator.rb +1 -1
- data/lib/generators/decorator/templates/decorator.rb +0 -1
- data/lib/generators/rspec/decorator_generator.rb +1 -1
- data/lib/generators/test_unit/decorator_generator.rb +1 -1
- data/lib/generators/test_unit/templates/decorator_test.rb +0 -3
- data/spec/draper/collection_decorator_spec.rb +240 -0
- data/spec/draper/decoratable_spec.rb +164 -0
- data/spec/draper/decorated_association_spec.rb +130 -0
- data/spec/draper/decorator_spec.rb +622 -0
- data/spec/draper/finders_spec.rb +145 -0
- data/spec/draper/helper_proxy_spec.rb +12 -0
- data/spec/draper/security_spec.rb +158 -0
- data/spec/draper/view_helpers_spec.rb +41 -0
- data/spec/dummy/.rspec +2 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +4 -0
- data/spec/dummy/app/controllers/localized_urls.rb +5 -0
- data/spec/dummy/app/controllers/posts_controller.rb +17 -0
- data/spec/dummy/app/decorators/post_decorator.rb +29 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/application_mailer.rb +3 -0
- data/spec/dummy/app/mailers/post_mailer.rb +9 -0
- data/spec/dummy/app/models/post.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +11 -0
- data/spec/dummy/app/views/post_mailer/decorated_email.html.erb +1 -0
- data/spec/dummy/app/views/posts/_post.html.erb +19 -0
- data/spec/dummy/app/views/posts/show.html.erb +1 -0
- data/spec/dummy/config/application.rb +64 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +34 -0
- data/spec/dummy/config/environments/production.rb +55 -0
- data/spec/dummy/config/environments/test.rb +32 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +7 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/20121019115657_create_posts.rb +8 -0
- data/spec/dummy/db/schema.rb +21 -0
- data/spec/dummy/db/seeds.rb +2 -0
- data/spec/dummy/lib/tasks/spec.rake +5 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/spec/decorators/post_decorator_spec.rb +26 -0
- data/spec/dummy/spec/mailers/post_mailer_spec.rb +29 -0
- data/spec/dummy/spec/spec_helper.rb +9 -0
- data/spec/generators/decorator/decorator_generator_spec.rb +25 -6
- data/spec/integration/integration_spec.rb +33 -0
- data/spec/minitest-rails/spec_type_spec.rb +63 -0
- data/{performance → spec/performance}/decorators.rb +2 -4
- data/spec/spec_helper.rb +23 -26
- data/spec/support/action_controller.rb +12 -0
- data/spec/support/active_model.rb +7 -0
- data/spec/support/{samples/active_record.rb → active_record.rb} +5 -0
- data/spec/support/{samples → decorators}/decorator_with_application_helper.rb +1 -1
- data/spec/support/decorators/namespaced_product_decorator.rb +5 -0
- data/spec/support/decorators/non_active_model_product_decorator.rb +2 -0
- data/spec/support/decorators/product_decorator.rb +23 -0
- data/spec/support/decorators/products_decorator.rb +10 -0
- data/spec/support/decorators/some_thing_decorator.rb +2 -0
- data/spec/support/{samples → decorators}/specific_product_decorator.rb +0 -2
- data/spec/support/dummy_app.rb +84 -0
- data/spec/support/matchers/have_text.rb +50 -0
- data/spec/support/{samples → models}/namespaced_product.rb +1 -3
- data/spec/support/{samples → models}/non_active_model_product.rb +1 -0
- data/spec/support/{samples → models}/product.rb +17 -2
- data/spec/support/models/some_thing.rb +5 -0
- data/spec/support/models/uninferrable_decorator_model.rb +3 -0
- metadata +211 -102
- data/doc/ApplicationDecorator.html +0 -147
- data/doc/Draper/AllHelpers.html +0 -256
- data/doc/Draper/Base.html +0 -1222
- data/doc/Draper/DecoratorGenerator.html +0 -216
- data/doc/Draper/LazyHelpers.html +0 -174
- data/doc/Draper/ModelSupport.html +0 -164
- data/doc/Draper/System.html +0 -179
- data/doc/Draper.html +0 -123
- data/doc/_index.html +0 -172
- data/doc/class_list.html +0 -47
- data/doc/css/common.css +0 -1
- data/doc/css/full_list.css +0 -53
- data/doc/css/style.css +0 -320
- data/doc/file_list.html +0 -46
- data/doc/frames.html +0 -13
- data/doc/index.html +0 -172
- data/doc/js/app.js +0 -205
- data/doc/js/full_list.js +0 -150
- data/doc/js/jquery.js +0 -16
- data/doc/method_list.html +0 -174
- data/doc/top-level-namespace.html +0 -103
- data/lib/draper/active_model_support.rb +0 -27
- data/lib/draper/base.rb +0 -312
- data/lib/draper/decorated_enumerable_proxy.rb +0 -57
- data/lib/draper/model_support.rb +0 -17
- data/lib/draper/rspec_integration.rb +0 -2
- data/lib/draper/system.rb +0 -10
- data/lib/draper/test/view_context.rb +0 -12
- data/spec/draper/base_spec.rb +0 -863
- data/spec/draper/helper_support_spec.rb +0 -18
- data/spec/draper/model_support_spec.rb +0 -48
- data/spec/draper/view_context_spec.rb +0 -30
- data/spec/support/samples/active_model.rb +0 -9
- data/spec/support/samples/application_controller.rb +0 -42
- data/spec/support/samples/application_helper.rb +0 -8
- data/spec/support/samples/decorator.rb +0 -5
- data/spec/support/samples/decorator_with_allows.rb +0 -3
- data/spec/support/samples/decorator_with_denies.rb +0 -3
- data/spec/support/samples/decorator_with_denies_all.rb +0 -3
- data/spec/support/samples/decorator_with_multiple_allows.rb +0 -4
- data/spec/support/samples/decorator_with_special_methods.rb +0 -13
- data/spec/support/samples/namespaced_product_decorator.rb +0 -7
- data/spec/support/samples/product_decorator.rb +0 -7
- data/spec/support/samples/sequel_product.rb +0 -13
- data/spec/support/samples/some_thing.rb +0 -2
- data/spec/support/samples/some_thing_decorator.rb +0 -3
- /data/{performance → spec/performance}/active_record.rb +0 -0
- /data/{performance/bechmark.rb → spec/performance/benchmark.rb} +0 -0
- /data/{performance → spec/performance}/models.rb +0 -0
- /data/spec/support/{samples → decorators}/widget_decorator.rb +0 -0
- /data/spec/support/{samples → models}/widget.rb +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'support/dummy_app'
|
|
3
|
+
require 'support/matchers/have_text'
|
|
4
|
+
|
|
5
|
+
app = DummyApp.new(ENV["RAILS_ENV"])
|
|
6
|
+
|
|
7
|
+
app.start_server do
|
|
8
|
+
{view: "/posts/1", mailer: "/posts/1/mail"}.each do |type, path|
|
|
9
|
+
page = app.get(path)
|
|
10
|
+
|
|
11
|
+
describe "in a #{type}" do
|
|
12
|
+
it "runs in the correct environment" do
|
|
13
|
+
page.should have_text(app.environment).in("#environment")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "can use path helpers with a model" do
|
|
17
|
+
page.should have_text("/en/posts/1").in("#path_with_model")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "can use path helpers with an id" do
|
|
21
|
+
page.should have_text("/en/posts/1").in("#path_with_id")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "can use url helpers with a model" do
|
|
25
|
+
page.should have_text("http://www.example.com/en/posts/1").in("#url_with_model")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "can use url helpers with an id" do
|
|
29
|
+
page.should have_text("http://www.example.com/en/posts/1").in("#url_with_id")
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'minitest/rails/active_support'
|
|
3
|
+
require 'draper/test/minitest_integration'
|
|
4
|
+
|
|
5
|
+
describe "minitest-rails spec_type Lookup Integration" do
|
|
6
|
+
context "ProductDecorator" do
|
|
7
|
+
it "resolves constants" do
|
|
8
|
+
klass = MiniTest::Spec.spec_type(ProductDecorator)
|
|
9
|
+
klass.should == MiniTest::Rails::ActiveSupport::TestCase
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "resolves strings" do
|
|
13
|
+
klass = MiniTest::Spec.spec_type("ProductDecorator")
|
|
14
|
+
klass.should == MiniTest::Rails::ActiveSupport::TestCase
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
context "WidgetDecorator" do
|
|
19
|
+
it "resolves constants" do
|
|
20
|
+
klass = MiniTest::Spec.spec_type(WidgetDecorator)
|
|
21
|
+
klass.should == MiniTest::Rails::ActiveSupport::TestCase
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "resolves strings" do
|
|
25
|
+
klass = MiniTest::Spec.spec_type("WidgetDecorator")
|
|
26
|
+
klass.should == MiniTest::Rails::ActiveSupport::TestCase
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
context "decorator strings" do
|
|
31
|
+
it "resolves DoesNotExistDecorator" do
|
|
32
|
+
klass = MiniTest::Spec.spec_type("DoesNotExistDecorator")
|
|
33
|
+
klass.should == MiniTest::Rails::ActiveSupport::TestCase
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "resolves DoesNotExistDecoratorTest" do
|
|
37
|
+
klass = MiniTest::Spec.spec_type("DoesNotExistDecoratorTest")
|
|
38
|
+
klass.should == MiniTest::Rails::ActiveSupport::TestCase
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "resolves Does Not Exist Decorator" do
|
|
42
|
+
klass = MiniTest::Spec.spec_type("Does Not Exist Decorator")
|
|
43
|
+
klass.should == MiniTest::Rails::ActiveSupport::TestCase
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "resolves Does Not Exist Decorator Test" do
|
|
47
|
+
klass = MiniTest::Spec.spec_type("Does Not Exist Decorator Test")
|
|
48
|
+
klass.should == MiniTest::Rails::ActiveSupport::TestCase
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
context "non-decorators" do
|
|
53
|
+
it "doesn't resolve constants" do
|
|
54
|
+
klass = MiniTest::Spec.spec_type(Draper::HelperSupport)
|
|
55
|
+
klass.should == MiniTest::Spec
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "doesn't resolve strings" do
|
|
59
|
+
klass = MiniTest::Spec.spec_type("Nothing to see here...")
|
|
60
|
+
klass.should == MiniTest::Spec
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
require "./performance/models"
|
|
2
|
-
class ProductDecorator < Draper::
|
|
3
|
-
decorates :product
|
|
2
|
+
class ProductDecorator < Draper::Decorator
|
|
4
3
|
|
|
5
4
|
def awesome_title
|
|
6
5
|
"Awesome Title"
|
|
@@ -21,8 +20,7 @@ class ProductDecorator < Draper::Base
|
|
|
21
20
|
|
|
22
21
|
end
|
|
23
22
|
|
|
24
|
-
class FastProductDecorator < Draper::
|
|
25
|
-
decorates :product
|
|
23
|
+
class FastProductDecorator < Draper::Decorator
|
|
26
24
|
|
|
27
25
|
def awesome_title
|
|
28
26
|
"Awesome Title"
|
data/spec/spec_helper.rb
CHANGED
|
@@ -3,34 +3,31 @@ require 'ammeter/init'
|
|
|
3
3
|
require 'rails'
|
|
4
4
|
|
|
5
5
|
require 'action_view'
|
|
6
|
-
require '
|
|
6
|
+
require 'action_controller'
|
|
7
|
+
require 'action_controller/test_case'
|
|
7
8
|
|
|
8
9
|
Bundler.require
|
|
9
10
|
|
|
10
|
-
require './spec/support/
|
|
11
|
-
require './spec/support/
|
|
12
|
-
require './spec/support/
|
|
13
|
-
require './spec/support/samples/decorator'
|
|
14
|
-
require './spec/support/samples/decorator_with_allows'
|
|
15
|
-
require './spec/support/samples/decorator_with_multiple_allows'
|
|
16
|
-
require './spec/support/samples/decorator_with_application_helper'
|
|
17
|
-
require './spec/support/samples/decorator_with_denies'
|
|
18
|
-
require './spec/support/samples/decorator_with_denies_all'
|
|
19
|
-
require './spec/support/samples/decorator_with_special_methods'
|
|
20
|
-
require './spec/support/samples/namespaced_product'
|
|
21
|
-
require './spec/support/samples/namespaced_product_decorator'
|
|
22
|
-
require './spec/support/samples/non_active_model_product'
|
|
23
|
-
require './spec/support/samples/product'
|
|
24
|
-
require './spec/support/samples/product_decorator'
|
|
25
|
-
require './spec/support/samples/sequel_product'
|
|
26
|
-
require './spec/support/samples/specific_product_decorator'
|
|
27
|
-
require './spec/support/samples/some_thing'
|
|
28
|
-
require './spec/support/samples/some_thing_decorator'
|
|
29
|
-
require './spec/support/samples/widget'
|
|
30
|
-
require './spec/support/samples/widget_decorator'
|
|
11
|
+
require './spec/support/active_model'
|
|
12
|
+
require './spec/support/active_record'
|
|
13
|
+
require './spec/support/action_controller'
|
|
31
14
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
15
|
+
require './spec/support/models/product'
|
|
16
|
+
require './spec/support/models/namespaced_product'
|
|
17
|
+
require './spec/support/models/non_active_model_product'
|
|
18
|
+
require './spec/support/models/widget'
|
|
19
|
+
require './spec/support/models/some_thing'
|
|
20
|
+
require './spec/support/models/uninferrable_decorator_model'
|
|
21
|
+
|
|
22
|
+
require './spec/support/decorators/product_decorator'
|
|
23
|
+
require './spec/support/decorators/namespaced_product_decorator'
|
|
24
|
+
require './spec/support/decorators/non_active_model_product_decorator'
|
|
25
|
+
require './spec/support/decorators/widget_decorator'
|
|
26
|
+
require './spec/support/decorators/specific_product_decorator'
|
|
27
|
+
require './spec/support/decorators/products_decorator'
|
|
28
|
+
require './spec/support/decorators/some_thing_decorator'
|
|
29
|
+
require './spec/support/decorators/decorator_with_application_helper'
|
|
30
|
+
|
|
31
|
+
class << Rails
|
|
32
|
+
undef application # Avoid silly Rails bug: https://github.com/rails/rails/pull/6429
|
|
36
33
|
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
class ProductDecorator < Draper::Decorator
|
|
2
|
+
decorates_finders
|
|
3
|
+
|
|
4
|
+
def awesome_title
|
|
5
|
+
"Awesome Title"
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def overridable
|
|
9
|
+
:overridden
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.overridable
|
|
13
|
+
:overridden
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.my_class_method
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def awesome_private_title
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
require 'socket'
|
|
2
|
+
require 'net/http'
|
|
3
|
+
|
|
4
|
+
# Adapted from code by Jon Leighton
|
|
5
|
+
# https://github.com/jonleighton/focused_controller/blob/ec7ccf1/test/acceptance/app_test.rb
|
|
6
|
+
|
|
7
|
+
class DummyApp
|
|
8
|
+
|
|
9
|
+
def initialize(environment)
|
|
10
|
+
raise ArgumentError, "Environment must be development or production" unless ["development", "production"].include?(environment.to_s)
|
|
11
|
+
@environment = environment
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
attr_reader :environment
|
|
15
|
+
|
|
16
|
+
def url
|
|
17
|
+
"http://#{localhost}:#{port}"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def get(path)
|
|
21
|
+
Net::HTTP.get(URI(url + path))
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def within_app(&block)
|
|
25
|
+
Dir.chdir(root, &block)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def start_server
|
|
29
|
+
within_app do
|
|
30
|
+
IO.popen("bundle exec rails s -e #{@environment} -p #{port} 2>&1") do |out|
|
|
31
|
+
start = Time.now
|
|
32
|
+
started = false
|
|
33
|
+
output = ""
|
|
34
|
+
timeout = 60.0
|
|
35
|
+
|
|
36
|
+
while !started && !out.eof? && Time.now - start <= timeout
|
|
37
|
+
output << read_output(out)
|
|
38
|
+
sleep 0.1
|
|
39
|
+
|
|
40
|
+
begin
|
|
41
|
+
TCPSocket.new(localhost, port)
|
|
42
|
+
rescue Errno::ECONNREFUSED
|
|
43
|
+
else
|
|
44
|
+
started = true
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
raise "Server failed to start:\n#{output}" unless started
|
|
49
|
+
|
|
50
|
+
yield
|
|
51
|
+
|
|
52
|
+
Process.kill('KILL', out.pid)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
private
|
|
58
|
+
|
|
59
|
+
def root
|
|
60
|
+
File.expand_path('../../dummy', __FILE__)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def localhost
|
|
64
|
+
'127.0.0.1'
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def port
|
|
68
|
+
@port ||= begin
|
|
69
|
+
server = TCPServer.new(localhost, 0)
|
|
70
|
+
server.addr[1]
|
|
71
|
+
ensure
|
|
72
|
+
server.close if server
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def read_output(stream)
|
|
77
|
+
read = IO.select([stream], [], [stream], 0.1)
|
|
78
|
+
output = ""
|
|
79
|
+
loop { output << stream.read_nonblock(1024) } if read
|
|
80
|
+
output
|
|
81
|
+
rescue Errno::EAGAIN, Errno::EWOULDBLOCK, EOFError
|
|
82
|
+
output
|
|
83
|
+
end
|
|
84
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require 'capybara'
|
|
2
|
+
|
|
3
|
+
module HaveTextMatcher
|
|
4
|
+
def have_text(text)
|
|
5
|
+
HaveText.new(text)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
class HaveText
|
|
9
|
+
def initialize(text)
|
|
10
|
+
@text = text
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def in(css)
|
|
14
|
+
@css = css
|
|
15
|
+
self
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def matches?(subject)
|
|
19
|
+
@subject = Capybara.string(subject)
|
|
20
|
+
|
|
21
|
+
@subject.has_css?(@css || "*", text: @text)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def failure_message_for_should
|
|
25
|
+
"expected to find #{@text.inspect} #{within}"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def failure_message_for_should_not
|
|
29
|
+
"expected not to find #{@text.inspect} #{within}"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
def within
|
|
35
|
+
if @css && @subject.has_css?(@css)
|
|
36
|
+
"within\n#{@subject.find(@css).native}"
|
|
37
|
+
else
|
|
38
|
+
"#{inside} within\n#{@subject.native}"
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def inside
|
|
43
|
+
@css ? "inside #{@css.inspect}" : "anywhere"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
RSpec.configure do |config|
|
|
49
|
+
config.include HaveTextMatcher
|
|
50
|
+
end
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
class Product < ActiveRecord::Base
|
|
2
|
-
include Draper::
|
|
2
|
+
include Draper::Decoratable
|
|
3
|
+
include ActiveModel::Serialization
|
|
4
|
+
|
|
5
|
+
delegate :delegated_method, to: :thing
|
|
3
6
|
|
|
4
7
|
def self.find_by_name(name)
|
|
5
8
|
@@dummy ||= Product.new
|
|
@@ -22,7 +25,7 @@ class Product < ActiveRecord::Base
|
|
|
22
25
|
end
|
|
23
26
|
|
|
24
27
|
def self.model_name
|
|
25
|
-
|
|
28
|
+
name
|
|
26
29
|
end
|
|
27
30
|
|
|
28
31
|
def self.find(id)
|
|
@@ -77,4 +80,16 @@ class Product < ActiveRecord::Base
|
|
|
77
80
|
Product.new
|
|
78
81
|
end
|
|
79
82
|
|
|
83
|
+
def overridable
|
|
84
|
+
:overridable
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def self.overridable
|
|
88
|
+
:overridable
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
private
|
|
92
|
+
|
|
93
|
+
def private_title
|
|
94
|
+
end
|
|
80
95
|
end
|