draper_new 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +15 -0
  5. data/.yardopts +1 -0
  6. data/CHANGELOG.md +230 -0
  7. data/CONTRIBUTING.md +20 -0
  8. data/Gemfile +16 -0
  9. data/Guardfile +26 -0
  10. data/LICENSE +7 -0
  11. data/README.md +587 -0
  12. data/Rakefile +69 -0
  13. data/draper_new.gemspec +31 -0
  14. data/gemfiles/4.0.gemfile +3 -0
  15. data/gemfiles/4.1.gemfile +3 -0
  16. data/gemfiles/4.2.6.gemfile +3 -0
  17. data/gemfiles/4.2.gemfile +3 -0
  18. data/lib/draper.rb +63 -0
  19. data/lib/draper/automatic_delegation.rb +56 -0
  20. data/lib/draper/collection_decorator.rb +100 -0
  21. data/lib/draper/decoratable.rb +96 -0
  22. data/lib/draper/decoratable/equality.rb +26 -0
  23. data/lib/draper/decorated_association.rb +35 -0
  24. data/lib/draper/decorates_assigned.rb +44 -0
  25. data/lib/draper/decorator.rb +293 -0
  26. data/lib/draper/delegation.rb +13 -0
  27. data/lib/draper/factory.rb +91 -0
  28. data/lib/draper/finders.rb +37 -0
  29. data/lib/draper/helper_proxy.rb +44 -0
  30. data/lib/draper/helper_support.rb +5 -0
  31. data/lib/draper/lazy_helpers.rb +15 -0
  32. data/lib/draper/railtie.rb +70 -0
  33. data/lib/draper/tasks/test.rake +22 -0
  34. data/lib/draper/test/devise_helper.rb +30 -0
  35. data/lib/draper/test/minitest_integration.rb +6 -0
  36. data/lib/draper/test/rspec_integration.rb +20 -0
  37. data/lib/draper/test_case.rb +42 -0
  38. data/lib/draper/undecorate.rb +9 -0
  39. data/lib/draper/version.rb +3 -0
  40. data/lib/draper/view_context.rb +104 -0
  41. data/lib/draper/view_context/build_strategy.rb +48 -0
  42. data/lib/draper/view_helpers.rb +37 -0
  43. data/lib/generators/controller_override.rb +17 -0
  44. data/lib/generators/mini_test/decorator_generator.rb +20 -0
  45. data/lib/generators/mini_test/templates/decorator_spec.rb +4 -0
  46. data/lib/generators/mini_test/templates/decorator_test.rb +4 -0
  47. data/lib/generators/rails/decorator_generator.rb +36 -0
  48. data/lib/generators/rails/templates/decorator.rb +19 -0
  49. data/lib/generators/rspec/decorator_generator.rb +9 -0
  50. data/lib/generators/rspec/templates/decorator_spec.rb +4 -0
  51. data/lib/generators/test_unit/decorator_generator.rb +9 -0
  52. data/lib/generators/test_unit/templates/decorator_test.rb +4 -0
  53. data/spec/draper/collection_decorator_spec.rb +307 -0
  54. data/spec/draper/decoratable/equality_spec.rb +10 -0
  55. data/spec/draper/decoratable_spec.rb +202 -0
  56. data/spec/draper/decorated_association_spec.rb +84 -0
  57. data/spec/draper/decorates_assigned_spec.rb +71 -0
  58. data/spec/draper/decorator_spec.rb +816 -0
  59. data/spec/draper/factory_spec.rb +251 -0
  60. data/spec/draper/finders_spec.rb +166 -0
  61. data/spec/draper/helper_proxy_spec.rb +61 -0
  62. data/spec/draper/lazy_helpers_spec.rb +21 -0
  63. data/spec/draper/undecorate_spec.rb +19 -0
  64. data/spec/draper/view_context/build_strategy_spec.rb +116 -0
  65. data/spec/draper/view_context_spec.rb +154 -0
  66. data/spec/draper/view_helpers_spec.rb +8 -0
  67. data/spec/dummy/.rspec +2 -0
  68. data/spec/dummy/Rakefile +7 -0
  69. data/spec/dummy/app/controllers/application_controller.rb +4 -0
  70. data/spec/dummy/app/controllers/localized_urls.rb +5 -0
  71. data/spec/dummy/app/controllers/posts_controller.rb +20 -0
  72. data/spec/dummy/app/decorators/mongoid_post_decorator.rb +4 -0
  73. data/spec/dummy/app/decorators/post_decorator.rb +60 -0
  74. data/spec/dummy/app/helpers/application_helper.rb +5 -0
  75. data/spec/dummy/app/mailers/application_mailer.rb +3 -0
  76. data/spec/dummy/app/mailers/post_mailer.rb +19 -0
  77. data/spec/dummy/app/models/admin.rb +5 -0
  78. data/spec/dummy/app/models/mongoid_post.rb +5 -0
  79. data/spec/dummy/app/models/post.rb +3 -0
  80. data/spec/dummy/app/models/user.rb +5 -0
  81. data/spec/dummy/app/views/layouts/application.html.erb +11 -0
  82. data/spec/dummy/app/views/post_mailer/decorated_email.html.erb +1 -0
  83. data/spec/dummy/app/views/posts/_post.html.erb +40 -0
  84. data/spec/dummy/app/views/posts/show.html.erb +1 -0
  85. data/spec/dummy/bin/rails +4 -0
  86. data/spec/dummy/config.ru +4 -0
  87. data/spec/dummy/config/application.rb +71 -0
  88. data/spec/dummy/config/boot.rb +5 -0
  89. data/spec/dummy/config/database.yml +25 -0
  90. data/spec/dummy/config/environment.rb +5 -0
  91. data/spec/dummy/config/environments/development.rb +33 -0
  92. data/spec/dummy/config/environments/production.rb +57 -0
  93. data/spec/dummy/config/environments/test.rb +31 -0
  94. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  95. data/spec/dummy/config/initializers/inflections.rb +15 -0
  96. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  97. data/spec/dummy/config/initializers/secret_token.rb +8 -0
  98. data/spec/dummy/config/initializers/session_store.rb +8 -0
  99. data/spec/dummy/config/locales/en.yml +5 -0
  100. data/spec/dummy/config/mongoid.yml +79 -0
  101. data/spec/dummy/config/routes.rb +9 -0
  102. data/spec/dummy/db/migrate/20121019115657_create_posts.rb +8 -0
  103. data/spec/dummy/db/schema.rb +21 -0
  104. data/spec/dummy/db/seeds.rb +2 -0
  105. data/spec/dummy/fast_spec/post_decorator_spec.rb +37 -0
  106. data/spec/dummy/lib/tasks/test.rake +16 -0
  107. data/spec/dummy/public/404.html +26 -0
  108. data/spec/dummy/public/422.html +26 -0
  109. data/spec/dummy/public/500.html +25 -0
  110. data/spec/dummy/public/favicon.ico +0 -0
  111. data/spec/dummy/script/rails +6 -0
  112. data/spec/dummy/spec/decorators/active_model_serializers_spec.rb +16 -0
  113. data/spec/dummy/spec/decorators/devise_spec.rb +64 -0
  114. data/spec/dummy/spec/decorators/helpers_spec.rb +21 -0
  115. data/spec/dummy/spec/decorators/post_decorator_spec.rb +66 -0
  116. data/spec/dummy/spec/decorators/spec_type_spec.rb +7 -0
  117. data/spec/dummy/spec/decorators/view_context_spec.rb +22 -0
  118. data/spec/dummy/spec/mailers/post_mailer_spec.rb +33 -0
  119. data/spec/dummy/spec/models/mongoid_post_spec.rb +8 -0
  120. data/spec/dummy/spec/models/post_spec.rb +6 -0
  121. data/spec/dummy/spec/shared_examples/decoratable.rb +24 -0
  122. data/spec/dummy/spec/spec_helper.rb +8 -0
  123. data/spec/dummy/test/decorators/minitest/devise_test.rb +64 -0
  124. data/spec/dummy/test/decorators/minitest/helpers_test.rb +21 -0
  125. data/spec/dummy/test/decorators/minitest/spec_type_test.rb +52 -0
  126. data/spec/dummy/test/decorators/minitest/view_context_test.rb +24 -0
  127. data/spec/dummy/test/decorators/test_unit/devise_test.rb +64 -0
  128. data/spec/dummy/test/decorators/test_unit/helpers_test.rb +21 -0
  129. data/spec/dummy/test/decorators/test_unit/view_context_test.rb +24 -0
  130. data/spec/dummy/test/minitest_helper.rb +2 -0
  131. data/spec/dummy/test/test_helper.rb +3 -0
  132. data/spec/generators/controller/controller_generator_spec.rb +22 -0
  133. data/spec/generators/decorator/decorator_generator_spec.rb +92 -0
  134. data/spec/integration/integration_spec.rb +66 -0
  135. data/spec/performance/active_record.rb +4 -0
  136. data/spec/performance/benchmark.rb +55 -0
  137. data/spec/performance/decorators.rb +45 -0
  138. data/spec/performance/models.rb +20 -0
  139. data/spec/spec_helper.rb +41 -0
  140. data/spec/support/dummy_app.rb +85 -0
  141. data/spec/support/matchers/have_text.rb +50 -0
  142. data/spec/support/shared_examples/decoratable_equality.rb +40 -0
  143. data/spec/support/shared_examples/view_helpers.rb +39 -0
  144. metadata +420 -0
@@ -0,0 +1,24 @@
1
+ shared_examples_for "a decoratable model" do
2
+ describe ".decorate" do
3
+ it "applies a collection decorator to a scope" do
4
+ described_class.create
5
+ decorated = described_class.limit(1).decorate
6
+
7
+ expect(decorated.size).to eq(1)
8
+ expect(decorated).to be_decorated
9
+ end
10
+ end
11
+
12
+ describe "#==" do
13
+ it "is true for other instances' decorators" do
14
+ pending "Mongoid < 3.1 overrides `#==`" if defined?(Mongoid) && Mongoid::VERSION.to_f < 3.1 && described_class < Mongoid::Document
15
+
16
+ described_class.create
17
+ one = described_class.first
18
+ other = described_class.first
19
+
20
+ expect(one).not_to be other
21
+ expect(one == other.decorate).to be_truthy
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,8 @@
1
+ ENV['RAILS_ENV'] ||= 'test'
2
+ require File.expand_path('../../config/environment', __FILE__)
3
+ require 'rspec/rails'
4
+
5
+ RSpec.configure do |config|
6
+ config.expect_with(:rspec) {|c| c.syntax = :expect}
7
+ config.order = :random
8
+ end
@@ -0,0 +1,64 @@
1
+ require 'minitest_helper'
2
+
3
+ if defined?(Devise)
4
+ describe "A decorator test" do
5
+ it "can sign in a real user" do
6
+ user = User.new
7
+ sign_in user
8
+
9
+ assert_same user, helper.current_user
10
+ end
11
+
12
+ it "can sign in a mock user" do
13
+ user = Object.new
14
+ sign_in :user, user
15
+
16
+ assert_same user, helper.current_user
17
+ end
18
+
19
+ it "can sign in a real admin" do
20
+ admin = Admin.new
21
+ sign_in admin
22
+
23
+ assert_same admin, helper.current_admin
24
+ end
25
+
26
+ it "can sign in a mock admin" do
27
+ admin = Object.new
28
+ sign_in :admin, admin
29
+
30
+ assert_same admin, helper.current_admin
31
+ end
32
+
33
+ it "can sign out a real user" do
34
+ user = User.new
35
+ sign_in user
36
+ sign_out user
37
+
38
+ assert helper.current_user.nil?
39
+ end
40
+
41
+ it "can sign out a mock user" do
42
+ user = Object.new
43
+ sign_in :user, user
44
+ sign_out :user
45
+
46
+ assert helper.current_user.nil?
47
+ end
48
+
49
+ it "can sign out without a user" do
50
+ sign_out :user
51
+
52
+ assert helper.current_user.nil?
53
+ end
54
+
55
+ it "is backwards-compatible" do
56
+ user = Object.new
57
+ ActiveSupport::Deprecation.silence do
58
+ sign_in user
59
+ end
60
+
61
+ assert_same user, helper.current_user
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,21 @@
1
+ require 'minitest_helper'
2
+
3
+ describe "A decorator test" do
4
+ it "can access helpers through `helper`" do
5
+ assert_equal "<p>Help!</p>", helper.content_tag(:p, "Help!")
6
+ end
7
+
8
+ it "can access helpers through `helpers`" do
9
+ assert_equal "<p>Help!</p>", helpers.content_tag(:p, "Help!")
10
+ end
11
+
12
+ it "can access helpers through `h`" do
13
+ assert_equal "<p>Help!</p>", h.content_tag(:p, "Help!")
14
+ end
15
+
16
+ it "gets the same helper object as a decorator" do
17
+ decorator = Draper::Decorator.new(Object.new)
18
+
19
+ assert_same decorator.helpers, helpers
20
+ end
21
+ end
@@ -0,0 +1,52 @@
1
+ require 'minitest_helper'
2
+
3
+ def it_is_a_decorator_test
4
+ it "is a decorator test" do
5
+ assert_kind_of Draper::TestCase, self
6
+ end
7
+ end
8
+
9
+ def it_is_not_a_decorator_test
10
+ it "is not a decorator test" do
11
+ refute_kind_of Draper::TestCase, self
12
+ end
13
+ end
14
+
15
+ ProductDecorator = Class.new(Draper::Decorator)
16
+ ProductsDecorator = Class.new(Draper::CollectionDecorator)
17
+
18
+ describe ProductDecorator do
19
+ it_is_a_decorator_test
20
+ end
21
+
22
+ describe ProductsDecorator do
23
+ it_is_a_decorator_test
24
+ end
25
+
26
+ describe "ProductDecorator" do
27
+ it_is_a_decorator_test
28
+ end
29
+
30
+ describe "AnyDecorator" do
31
+ it_is_a_decorator_test
32
+ end
33
+
34
+ describe "Any decorator" do
35
+ it_is_a_decorator_test
36
+ end
37
+
38
+ describe "AnyDecoratorTest" do
39
+ it_is_a_decorator_test
40
+ end
41
+
42
+ describe "Any decorator test" do
43
+ it_is_a_decorator_test
44
+ end
45
+
46
+ describe Object do
47
+ it_is_not_a_decorator_test
48
+ end
49
+
50
+ describe "Nope" do
51
+ it_is_not_a_decorator_test
52
+ end
@@ -0,0 +1,24 @@
1
+ require 'minitest_helper'
2
+
3
+ def it_does_not_leak_view_context
4
+ 2.times do
5
+ it "has an independent view context" do
6
+ refute_equal :leaked, Draper::ViewContext.current
7
+ Draper::ViewContext.current = :leaked
8
+ end
9
+ end
10
+ end
11
+
12
+ describe "A decorator test" do
13
+ it_does_not_leak_view_context
14
+ end
15
+
16
+ describe "A controller test" do
17
+ tests Class.new(ActionController::Base)
18
+
19
+ it_does_not_leak_view_context
20
+ end
21
+
22
+ describe "A mailer test" do
23
+ it_does_not_leak_view_context
24
+ end
@@ -0,0 +1,64 @@
1
+ require 'test_helper'
2
+
3
+ if defined?(Devise)
4
+ class DeviseTest < Draper::TestCase
5
+ def test_sign_in_a_real_user
6
+ user = User.new
7
+ sign_in user
8
+
9
+ assert_same user, helper.current_user
10
+ end
11
+
12
+ def test_sign_in_a_mock_user
13
+ user = Object.new
14
+ sign_in :user, user
15
+
16
+ assert_same user, helper.current_user
17
+ end
18
+
19
+ def test_sign_in_a_real_admin
20
+ admin = Admin.new
21
+ sign_in admin
22
+
23
+ assert_same admin, helper.current_admin
24
+ end
25
+
26
+ def test_sign_in_a_mock_admin
27
+ admin = Object.new
28
+ sign_in :admin, admin
29
+
30
+ assert_same admin, helper.current_admin
31
+ end
32
+
33
+ def test_sign_out_a_real_user
34
+ user = User.new
35
+ sign_in user
36
+ sign_out user
37
+
38
+ assert helper.current_user.nil?
39
+ end
40
+
41
+ def test_sign_out_a_mock_user
42
+ user = Object.new
43
+ sign_in :user, user
44
+ sign_out :user
45
+
46
+ assert helper.current_user.nil?
47
+ end
48
+
49
+ def test_sign_out_without_a_user
50
+ sign_out :user
51
+
52
+ assert helper.current_user.nil?
53
+ end
54
+
55
+ def test_backwards_compatibility
56
+ user = Object.new
57
+ ActiveSupport::Deprecation.silence do
58
+ sign_in user
59
+ end
60
+
61
+ assert_same user, helper.current_user
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,21 @@
1
+ require 'test_helper'
2
+
3
+ class HelpersTest < Draper::TestCase
4
+ def test_access_helpers_through_helper
5
+ assert_equal "<p>Help!</p>", helper.content_tag(:p, "Help!")
6
+ end
7
+
8
+ def test_access_helpers_through_helpers
9
+ assert_equal "<p>Help!</p>", helpers.content_tag(:p, "Help!")
10
+ end
11
+
12
+ def test_access_helpers_through_h
13
+ assert_equal "<p>Help!</p>", h.content_tag(:p, "Help!")
14
+ end
15
+
16
+ def test_same_helper_object_as_decorators
17
+ decorator = Draper::Decorator.new(Object.new)
18
+
19
+ assert_same decorator.helpers, helpers
20
+ end
21
+ end
@@ -0,0 +1,24 @@
1
+ require 'test_helper'
2
+
3
+ def it_does_not_leak_view_context
4
+ 2.times do |n|
5
+ define_method("test_has_independent_view_context_#{n}") do
6
+ refute_equal :leaked, Draper::ViewContext.current
7
+ Draper::ViewContext.current = :leaked
8
+ end
9
+ end
10
+ end
11
+
12
+ class DecoratorTest < Draper::TestCase
13
+ it_does_not_leak_view_context
14
+ end
15
+
16
+ class ControllerTest < ActionController::TestCase
17
+ tests Class.new(ActionController::Base)
18
+
19
+ it_does_not_leak_view_context
20
+ end
21
+
22
+ class MailerTest < ActionMailer::TestCase
23
+ it_does_not_leak_view_context
24
+ end
@@ -0,0 +1,2 @@
1
+ require 'test_helper'
2
+ require 'minitest/rails'
@@ -0,0 +1,3 @@
1
+ ENV['RAILS_ENV'] ||= 'test'
2
+ require File.expand_path('../../config/environment', __FILE__)
3
+ require 'rails/test_help'
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+ require 'rails'
3
+ require 'ammeter/init'
4
+ require 'generators/controller_override'
5
+ require 'generators/rails/decorator_generator'
6
+
7
+ describe Rails::Generators::ControllerGenerator do
8
+ destination File.expand_path("../tmp", __FILE__)
9
+
10
+ before { prepare_destination }
11
+ after(:all) { FileUtils.rm_rf destination_root }
12
+
13
+ describe "the generated decorator" do
14
+ subject { file("app/decorators/your_model_decorator.rb") }
15
+
16
+ describe "naming" do
17
+ before { run_generator %w(YourModels) }
18
+
19
+ it { should contain "class YourModelDecorator" }
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,92 @@
1
+ require 'spec_helper'
2
+ require 'rails'
3
+ require 'ammeter/init'
4
+ require 'generators/rails/decorator_generator'
5
+
6
+ describe Rails::Generators::DecoratorGenerator do
7
+ destination File.expand_path("../tmp", __FILE__)
8
+
9
+ before { prepare_destination }
10
+ after(:all) { FileUtils.rm_rf destination_root }
11
+
12
+ describe "the generated decorator" do
13
+ subject { file("app/decorators/your_model_decorator.rb") }
14
+
15
+ describe "naming" do
16
+ before { run_generator %w(YourModel) }
17
+
18
+ it { should contain "class YourModelDecorator" }
19
+ end
20
+
21
+ describe "namespacing" do
22
+ subject { file("app/decorators/namespace/your_model_decorator.rb") }
23
+ before { run_generator %w(Namespace::YourModel) }
24
+
25
+ it { should contain "class Namespace::YourModelDecorator" }
26
+ end
27
+
28
+ describe "inheritance" do
29
+ context "by default" do
30
+ before { run_generator %w(YourModel) }
31
+
32
+ it { should contain "class YourModelDecorator < Draper::Decorator" }
33
+ end
34
+
35
+ context "with the --parent option" do
36
+ before { run_generator %w(YourModel --parent=FooDecorator) }
37
+
38
+ it { should contain "class YourModelDecorator < FooDecorator" }
39
+ end
40
+
41
+ context "with an ApplicationDecorator" do
42
+ before do
43
+ allow_any_instance_of(Object).to receive(:require).with("application_decorator").and_return(
44
+ stub_const "ApplicationDecorator", Class.new
45
+ )
46
+ end
47
+
48
+ before { run_generator %w(YourModel) }
49
+
50
+ it { should contain "class YourModelDecorator < ApplicationDecorator" }
51
+ end
52
+ end
53
+ end
54
+
55
+ context "with -t=rspec" do
56
+ describe "the generated spec" do
57
+ subject { file("spec/decorators/your_model_decorator_spec.rb") }
58
+
59
+ describe "naming" do
60
+ before { run_generator %w(YourModel -t=rspec) }
61
+
62
+ it { should contain "describe YourModelDecorator" }
63
+ end
64
+
65
+ describe "namespacing" do
66
+ subject { file("spec/decorators/namespace/your_model_decorator_spec.rb") }
67
+ before { run_generator %w(Namespace::YourModel -t=rspec) }
68
+
69
+ it { should contain "describe Namespace::YourModelDecorator" }
70
+ end
71
+ end
72
+ end
73
+
74
+ context "with -t=test_unit" do
75
+ describe "the generated test" do
76
+ subject { file("test/decorators/your_model_decorator_test.rb") }
77
+
78
+ describe "naming" do
79
+ before { run_generator %w(YourModel -t=test_unit) }
80
+
81
+ it { should contain "class YourModelDecoratorTest < Draper::TestCase" }
82
+ end
83
+
84
+ describe "namespacing" do
85
+ subject { file("test/decorators/namespace/your_model_decorator_test.rb") }
86
+ before { run_generator %w(Namespace::YourModel -t=test_unit) }
87
+
88
+ it { should contain "class Namespace::YourModelDecoratorTest < Draper::TestCase" }
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+ require 'support/dummy_app'
3
+ require 'support/matchers/have_text'
4
+
5
+ app = DummyApp.new(ENV["RAILS_ENV"])
6
+ spec_types = {
7
+ view: ["/posts/1", "PostsController"],
8
+ mailer: ["/posts/1/mail", "PostMailer"]
9
+ }
10
+
11
+ app.start_server do
12
+ spec_types.each do |type, (path, controller)|
13
+ page = app.get(path)
14
+
15
+ describe "in a #{type}" do
16
+ it "runs in the correct environment" do
17
+ expect(page).to have_text(app.environment).in("#environment")
18
+ end
19
+
20
+ it "uses the correct view context controller" do
21
+ expect(page).to have_text(controller).in("#controller")
22
+ end
23
+
24
+ it "can use built-in helpers" do
25
+ expect(page).to have_text("Once upon a...").in("#truncated")
26
+ end
27
+
28
+ it "can use built-in private helpers" do
29
+ # Nokogiri unescapes text!
30
+ expect(page).to have_text("<script>danger</script>").in("#html_escaped")
31
+ end
32
+
33
+ it "can use user-defined helpers from app/helpers" do
34
+ expect(page).to have_text("Hello, world!").in("#hello_world")
35
+ end
36
+
37
+ it "can use user-defined helpers from the controller" do
38
+ expect(page).to have_text("Goodnight, moon!").in("#goodnight_moon")
39
+ end
40
+
41
+ it "can be passed to path helpers" do
42
+ expect(page).to have_text("/en/posts/1").in("#path_with_decorator")
43
+ end
44
+
45
+ it "can use path helpers with a model" do
46
+ expect(page).to have_text("/en/posts/1").in("#path_with_model")
47
+ end
48
+
49
+ it "can use path helpers with an id" do
50
+ expect(page).to have_text("/en/posts/1").in("#path_with_id")
51
+ end
52
+
53
+ it "can be passed to url helpers" do
54
+ expect(page).to have_text("http://www.example.com:12345/en/posts/1").in("#url_with_decorator")
55
+ end
56
+
57
+ it "can use url helpers with a model" do
58
+ expect(page).to have_text("http://www.example.com:12345/en/posts/1").in("#url_with_model")
59
+ end
60
+
61
+ it "can use url helpers with an id" do
62
+ expect(page).to have_text("http://www.example.com:12345/en/posts/1").in("#url_with_id")
63
+ end
64
+ end
65
+ end
66
+ end