Hi Jack

>From memory and without knowing the specifics, thats a standard “Redirect” 
>page, you might check you’re not trying to send a 400 response and redirect at 
>the same time. You might also like to check that you are following redirects 
>in Capybara.

Cheers
Jon Rowe
---------------------------
[email protected]
jonrowe.co.uk

On 30 July 2019 at 01:01, 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" 
> "w3.org/TR/REC-html40/loose.dtd (http://www.w3.org/TR/REC-html40/loose.dtd)">
>
>
> <html><body>You are being <a href="test.host 
> (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" 
> "w3.org/TR/REC-html40/loose.dtd (http://www.w3.org/TR/REC-html40/loose.dtd)">
>
>
> <html><body>You are being <a href="test.host 
> (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" 
> "w3.org/TR/REC-html40/loose.dtd (http://www.w3.org/TR/REC-html40/loose.dtd)">
>
>
> <html><body>You are being <a href="test.host 
> (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" 
> "w3.org/TR/REC-html40/loose.dtd (http://www.w3.org/TR/REC-html40/loose.dtd)">
>
>
> <html><body>You are being <a href="test.host 
> (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/dejalu-217-adc303c9-c39f-4223-bda9-e58c0a60d81a%40jonrowe.co.uk.

Reply via email to