From 39ae873c06d9fd35bbde94556a11ad048b363963 Mon Sep 17 00:00:00 2001 From: Ben Purinton Date: Thu, 14 Sep 2023 09:58:00 -0800 Subject: [PATCH] add coupla specs --- spec/views/movies/show.html.erb_spec.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 spec/views/movies/show.html.erb_spec.rb diff --git a/spec/views/movies/show.html.erb_spec.rb b/spec/views/movies/show.html.erb_spec.rb new file mode 100644 index 0000000..3ac847b --- /dev/null +++ b/spec/views/movies/show.html.erb_spec.rb @@ -0,0 +1,20 @@ +require "rails_helper" + +describe "movies/show.html.erb" do + + let!(:movie) { Movie.create(title: "E", description: "EE", created_at: 1.day.ago, updated_at: 0.day.ago) } + + it "uses time_ago_in_words for created_at" do + assign(:the_movie, movie) + allow(view).to receive(:time_ago_in_words) + render + expect(view).to have_received(:time_ago_in_words).with(movie.created_at) + end + + it "uses link_to for edit link" do + assign(:the_movie, movie) + allow(view).to receive(:link_to) + render + expect(view).to have_received(:link_to).with("Edit movie", "/movies/#{movie.id}/edit") + end +end