From 3b092b2248fb7d7417e2fab112ee65107874160e Mon Sep 17 00:00:00 2001 From: Andrew Haines Date: Sun, 14 Jul 2013 16:03:16 +0100 Subject: [PATCH] Add more route helper integration specs --- spec/dummy/app/views/posts/_post.html.erb | 6 ++++++ spec/dummy/spec/decorators/post_decorator_spec.rb | 8 ++++++++ spec/integration/integration_spec.rb | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/spec/dummy/app/views/posts/_post.html.erb b/spec/dummy/app/views/posts/_post.html.erb index 8170f7f..22350a4 100644 --- a/spec/dummy/app/views/posts/_post.html.erb +++ b/spec/dummy/app/views/posts/_post.html.erb @@ -20,12 +20,18 @@
Helpers from the controller:
<%= post.goodnight_moon %>
+
Path with decorator:
+
<%= post_path(post) %>
+
Path with model:
<%= post.path_with_model %>
Path with id:
<%= post.path_with_id %>
+
URL with decorator:
+
<%= post_url(post) %>
+
URL with model:
<%= post.url_with_model %>
diff --git a/spec/dummy/spec/decorators/post_decorator_spec.rb b/spec/dummy/spec/decorators/post_decorator_spec.rb index 703efae..75aaf41 100755 --- a/spec/dummy/spec/decorators/post_decorator_spec.rb +++ b/spec/dummy/spec/decorators/post_decorator_spec.rb @@ -16,6 +16,10 @@ describe PostDecorator do expect(decorator.hello_world).to eq "Hello, world!" end + it "can be passed to path helpers" do + expect(helpers.post_path(decorator)).to eq "/en/posts/#{object.id}" + end + it "can use path helpers with its model" do expect(decorator.path_with_model).to eq "/en/posts/#{object.id}" end @@ -24,6 +28,10 @@ describe PostDecorator do expect(decorator.path_with_id).to eq "/en/posts/#{object.id}" end + it "can be passed to url helpers" do + expect(helpers.post_url(decorator)).to eq "http://www.example.com:12345/en/posts/#{object.id}" + end + it "can use url helpers with its model" do expect(decorator.url_with_model).to eq "http://www.example.com:12345/en/posts/#{object.id}" end diff --git a/spec/integration/integration_spec.rb b/spec/integration/integration_spec.rb index 4da2f5f..3175b3c 100644 --- a/spec/integration/integration_spec.rb +++ b/spec/integration/integration_spec.rb @@ -38,6 +38,10 @@ app.start_server do expect(page).to have_text("Goodnight, moon!").in("#goodnight_moon") end + it "can be passed to path helpers" do + expect(page).to have_text("/en/posts/1").in("#path_with_decorator") + end + it "can use path helpers with a model" do expect(page).to have_text("/en/posts/1").in("#path_with_model") end @@ -46,6 +50,10 @@ app.start_server do expect(page).to have_text("/en/posts/1").in("#path_with_id") end + it "can be passed to url helpers" do + expect(page).to have_text("http://www.example.com:12345/en/posts/1").in("#url_with_decorator") + end + it "can use url helpers with a model" do expect(page).to have_text("http://www.example.com:12345/en/posts/1").in("#url_with_model") end