This turned out to not have anything to do with the operation of any of the
testing framework. It was due to a code change in my project that
invalidated most if not all of the controller tests. I was redirecting
requests directed to bare domain names (no "www.") to the canonical
("www.") domain name. Don't ask why - you don't want to know.
On Monday, July 29, 2019 at 5:01:40 PM UTC-7, Jack R-G wrote:
>
> I have a series of controller tests that have worked in the past. I've
> just recently tried to resume using RSpec, and I started by trying to get
> the existing tests working. I'm seeing quite consistently that tests
> involving controllers are failing, and the problem seems to be with
> redirection. Below are some tests from one controller and their failure
> messages. It looks to me like the response is a dummy page with an <a>
> redirecting to the appropriate page - but I don't know the relevance of
> that. This controller is the controller that should handle users who are
> not logged in (that is, it is the entry point for the website).
>
> require 'spec_helper'
>
> describe HomeController do
>
> render_views
>
> describe "GET 'index'" do
> describe "when not logged in" do
> before(:each) do
> get 'index'
> test_sign_out
> end
>
> subject { response }
>
> it { should be_success }
>
> it "should be titled as the app name" do
> should have_selector "title", :content => @app_name
> end
>
> it "should have a header" do
> should have_selector "h1"
> end
>
> describe "login form" do
> it "should be present" do
> should have_selector "form", :action => app_path.sessions_path,
> :method => "post" do
> it { should have_selector "input", :name => "email", :type =>
> "email" }
> it { should have_selector "input", :name => "password", :type
> => "password" }
> it { should have_selector "input", :name => "remember_me",
> :type => "checkbox" }
> it { should have_selector "input", :name => "commit", :type =>
> "submit", value => "Login" }
> it { should have_selector "a", :content => "Forgot password",
> :href => app_path.new_password_reset_path }
> end
> end
> end
>
> it "should have a sign up link" do
> should have_selector "a", :content => "Sign up NOW!", :href =>
> app_path.new_user_path
> end
> end
> ...
> end
> end
>
>
> 1) HomeController GET 'index' when not logged in
>
> Failure/Error: it { should be_success }
>
> expected success? to return true, got false
>
> # ./spec/controllers/home_controller_spec.rb:16:in `block (4 levels)
> in <top (required)>'
>
>
> 2) HomeController GET 'index' when not logged in should be titled as the
> app name
>
> Failure/Error: should have_selector "title", :content => @app_name
>
> expected following output to contain a <title/> tag:
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "
> http://www.w3.org/TR/REC-html40/loose.dtd">
>
> <html><body>You are being <a href="https://www.test.host/
> ">redirected</a>.</body></html>
>
> # ./spec/controllers/home_controller_spec.rb:19:in `block (4 levels)
> in <top (required)>'
>
>
> 3) HomeController GET 'index' when not logged in should have a header
>
> Failure/Error: should have_selector "h1"
>
> expected following output to contain a <h1/> tag:
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "
> http://www.w3.org/TR/REC-html40/loose.dtd">
>
> <html><body>You are being <a href="https://www.test.host/
> ">redirected</a>.</body></html>
>
> # ./spec/controllers/home_controller_spec.rb:23:in `block (4 levels)
> in <top (required)>'
>
>
> 4) HomeController GET 'index' when not logged in should have a sign up
> link
>
> Failure/Error: should have_selector "a", :content => "Sign up NOW!",
> :href => app_path.new_user_path
>
> expected following output to contain a <a href='/users/new'>Sign
> up NOW!</a> tag:
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "
> http://www.w3.org/TR/REC-html40/loose.dtd">
>
> <html><body>You are being <a href="https://www.test.host/
> ">redirected</a>.</body></html>
>
> # ./spec/controllers/home_controller_spec.rb:39:in `block (4 levels)
> in <top (required)>'
>
>
> 5) HomeController GET 'index' when not logged in login form should be
> present
>
> Failure/Error: should have_selector "form", :action =>
> app_path.sessions_path, :method => "post" do
>
> expected following output to contain a <form action='/sessions'
> method='post'/> tag:
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "
> http://www.w3.org/TR/REC-html40/loose.dtd">
>
> <html><body>You are being <a href="https://www.test.host/
> ">redirected</a>.</body></html>
>
> # ./spec/controllers/home_controller_spec.rb:28:in `block (5 levels)
> in <top (required)>'
>
>
>
--
You received this message because you are subscribed to the Google Groups
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rspec/a45b6d66-b662-40f6-9277-33d3d647664a%40googlegroups.com.