From eceb2e0a4c06bc24279bd4ffe61a9008cb5e2af0 Mon Sep 17 00:00:00 2001 From: Ben Purinton Date: Thu, 6 Apr 2023 15:19:39 +0000 Subject: [PATCH 1/3] added first link_to spec --- spec/helper_methods/2_helper_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 spec/helper_methods/2_helper_spec.rb diff --git a/spec/helper_methods/2_helper_spec.rb b/spec/helper_methods/2_helper_spec.rb new file mode 100644 index 0000000..9f37fc9 --- /dev/null +++ b/spec/helper_methods/2_helper_spec.rb @@ -0,0 +1,10 @@ +require "rails_helper" + +describe "movies/index" do + it "uses an embedded Ruby link_to helper method", points: 2 do + template_name = "movies/index.html.erb" + template_path = Rails.root.join('app', 'views', template_name) + template_contents = open(template_path).read + expect(template_contents).to match /<%= link_to "Show details", movie %>/ + end +end From d4159312a9db1c79595f71fa71750944fc467a45 Mon Sep 17 00:00:00 2001 From: Ben Purinton Date: Thu, 6 Apr 2023 10:11:46 -0800 Subject: [PATCH 2/3] update regex and fail message --- spec/helper_methods/2_helper_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/helper_methods/2_helper_spec.rb b/spec/helper_methods/2_helper_spec.rb index 9f37fc9..e3a32cb 100644 --- a/spec/helper_methods/2_helper_spec.rb +++ b/spec/helper_methods/2_helper_spec.rb @@ -5,6 +5,7 @@ template_name = "movies/index.html.erb" template_path = Rails.root.join('app', 'views', template_name) template_contents = open(template_path).read - expect(template_contents).to match /<%= link_to "Show details", movie %>/ + expect(template_contents).to match(/<%=.*link_to.*Show details.*%>/), + "Expected to find `link_to` method with text 'Show details' in movies/index.html.erb" end end From 0ae894db171d9b65df426b5dfe03d0a25f3eb2a1 Mon Sep 17 00:00:00 2001 From: Ben Purinton Date: Thu, 6 Apr 2023 13:25:15 -0800 Subject: [PATCH 3/3] change link_to spec --- spec/helper_methods/2_helper_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/helper_methods/2_helper_spec.rb b/spec/helper_methods/2_helper_spec.rb index e3a32cb..337dd5d 100644 --- a/spec/helper_methods/2_helper_spec.rb +++ b/spec/helper_methods/2_helper_spec.rb @@ -3,9 +3,9 @@ describe "movies/index" do it "uses an embedded Ruby link_to helper method", points: 2 do template_name = "movies/index.html.erb" - template_path = Rails.root.join('app', 'views', template_name) + template_path = Rails.root.join("app", "views", template_name) template_contents = open(template_path).read - expect(template_contents).to match(/<%=.*link_to.*Show details.*%>/), - "Expected to find `link_to` method with text 'Show details' in movies/index.html.erb" + expect(template_contents).to match(/<%=.*link_to.*Add a new movie.*%>/), + "Expected to find `link_to` method with text 'Add a new movie' in movies/index.html.erb" end end