Testing recursive IO prompt in rspec2019 Community Moderator ElectionHow do I test a private function or a class that has private methods, fields or inner classes?Unit Testing C CodeIs Unit Testing worth the effort?How do you unit test private methods?JavaScript unit test tools for TDDWhat is Unit test, Integration Test, Smoke test, Regression Test?Unit tests vs Functional testsWriting unit tests in Python: How do I start?RSpec - generic failure message instead of useful outputError after rake test, ruby on rails

Are small insurances worth it?

Trocar background-image com delay via jQuery

Translation of 答えを知っている人はいませんでした

What passages of Adi Shankaracharya’s Brahmasutra Bhashya does Sudarshana Suri cite?

What is the "determinant" of two vectors?

Has a sovereign Communist government ever run, and conceded loss, on a fair election?

Did Amazon pay $0 in taxes last year?

Should we avoid writing fiction about historical events without extensive research?

How should I solve this integral with changing parameters?

What will happen if my luggage gets delayed?

Writing text next to a table

Are all players supposed to be able to see each others' character sheets?

Playing a 7-string guitar song on a 6-string guitar

Rationale to prefer local variables over instance variables?

How do I increase the number of TTY consoles?

How do we create new idioms and use them in a novel?

Cycles on the torus

Was it really inappropriate to write a pull request for the company I interviewed with?

Do Paladin Auras of Differing Oaths Stack?

Giving a career talk in my old university, how prominently should I tell students my salary?

Is it appropriate to ask a former professor to order a book for me through an inter-library loan?

Does the US political system, in principle, allow for a no-party system?

"If + would" conditional in present perfect tense

Having the player face themselves after the mid-game



Testing recursive IO prompt in rspec



2019 Community Moderator ElectionHow do I test a private function or a class that has private methods, fields or inner classes?Unit Testing C CodeIs Unit Testing worth the effort?How do you unit test private methods?JavaScript unit test tools for TDDWhat is Unit test, Integration Test, Smoke test, Regression Test?Unit tests vs Functional testsWriting unit tests in Python: How do I start?RSpec - generic failure message instead of useful outputError after rake test, ruby on rails










1















I am writing a connect-four game for more OO and rspec practice. As part of my program, I would like to prompt the user to choose a column that they would like to put their game piece in. Here's that method:



def get_col_choice(input, output)
output.print "Player #@player, choose a column from 0-6: "
input_string = input.gets.chomp
begin
col_choice = Integer(input_string)
raise("The column you chose is out of bounds.") if out_of_bounds?(col_choice)
raise("The column you chose is fully occupied.") if unavailable?(col_choice)
return col_choice
rescue TypeError, ArgumentError
output.puts "Your choice of column is invalid. Try again."
rescue RuntimeError => err
puts err.message
end
get_col_choice(input, output)
end


In IRB, everything works as I planned. My hangup is in rspec where I am faced with a NoMethodError, which I think is coming from my recursive call to get_col_choice.



Can anyone help me understand what I can do to either improve get_col_choice or write the correct tests in Rspec? This is what my console output from my rspec file looks like:



Failures:

1) ConnectFourGame#get_col_choice notifies users which player gets to choose a column
Failure/Error: $connect_four.get_col_choice(input, output)

NoMethodError:
undefined method `chomp' for nil:NilClass
# /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:31:in `get_col_choice'
# /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:42:in `get_col_choice'
# ./connect_four_game_spec.rb:52:in `block (3 levels) in <top (required)>'

2) ConnectFourGame#get_col_choice returns the player's column choice
Failure/Error: expect($connect_four.get_col_choice(input, output)).to eq(0)

NoMethodError:
undefined method `chomp' for nil:NilClass
# /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:31:in `get_col_choice'
# /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:42:in `get_col_choice'
# ./connect_four_game_spec.rb:57:in `block (3 levels) in <top (required)>'

3) ConnectFourGame#get_col_choice notifies the user if the column they chose is already full of pieces
Failure/Error: expect(output.string).to include("The column you chose is fully occupied.")
expected "" to include "The column you chose is fully occupied."
# ./connect_four_game_spec.rb:62:in `block (3 levels) in <top (required)>'

4) ConnectFourGame#get_col_choice notifies the user their input is invalid when a non-numeric string is entered
Failure/Error: $connect_four.get_col_choice(input, output)

NoMethodError:
undefined method `chomp' for nil:NilClass
# /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:31:in `get_col_choice'
# /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:42:in `get_col_choice'
# ./connect_four_game_spec.rb:67:in `block (3 levels) in <top (required)>'

5) ConnectFourGame#get_col_choice column choice is out of bounds notifies the user their column choice is out of bounds when col is greater than 6
Failure/Error: $connect_four.get_col_choice(input, output)

NoMethodError:
undefined method `chomp' for nil:NilClass
# /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:31:in `get_col_choice'
# /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:42:in `get_col_choice'
# ./connect_four_game_spec.rb:74:in `block (4 levels) in <top (required)>'

6) ConnectFourGame#get_col_choice column choice is out of bounds notifies the user their column choice is out of bounds when col is less than 0
Failure/Error: $connect_four.get_col_choice(input, output)

NoMethodError:
undefined method `chomp' for nil:NilClass
# /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:31:in `get_col_choice'
# /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:42:in `get_col_choice'
# ./connect_four_game_spec.rb:80:in `block (4 levels) in <top (required)>'

Finished in 0.02399 seconds (files took 0.1108 seconds to load)
12 examples, 6 failures

Failed examples:

rspec ./connect_four_game_spec.rb:51 # ConnectFourGame#get_col_choice notifies users which player gets to choose a column
rspec ./connect_four_game_spec.rb:56 # ConnectFourGame#get_col_choice returns the player's column choice
rspec ./connect_four_game_spec.rb:60 # ConnectFourGame#get_col_choice notifies the user if the column they chose is already full of pieces
rspec ./connect_four_game_spec.rb:66 # ConnectFourGame#get_col_choice notifies the user their input is invalid when a non-numeric string is entered
rspec ./connect_four_game_spec.rb:73 # ConnectFourGame#get_col_choice column choice is out of bounds notifies the user their column choice is out of bounds when col is greater than 6
rspec ./connect_four_game_spec.rb:79 # ConnectFourGame#get_col_choice column choice is out of bounds notifies the user their column choice is out of bounds when col is less than 0


Here are the tests I wrote for get_col_choice:



describe '#get_col_choice' do
let(:output) StringIO.new
let(:input) StringIO.new("0n")
it 'notifies users which player gets to choose a column' do
$connect_four.get_col_choice(input, output)
expect(output.string).to include("Player 2, choose a column from 0-6: ")
end

it "returns the player's column choice" do
expect($connect_four.get_col_choice(input, output)).to eq(0)
end

it 'notifies the user if the column they chose is already full of pieces' do
6.times $connect_four.board.add_game_piece_to(0, "u2468")
expect(output.string).to include("The column you chose is fully occupied.")
end

let(:input) StringIO.new("!n")
it 'notifies the user their input is invalid when a non-numeric string is entered' do
$connect_four.get_col_choice(input, output)
expect(output.string).to include("Your choice of column is invalid. Try again.")
end

context 'column choice is out of bounds' do
let(:input) StringIO.new("7n")
it 'notifies the user their column choice is out of bounds when col is greater than 6' do
$connect_four.get_col_choice(input, output)
expect(output.string).to include("The column you chose is out of bounds.")
end

let(:input) StringIO.new("-1n")
it 'notifies the user their column choice is out of bounds when col is less than 0' do
$connect_four.get_col_choice(input, output)
expect(output.string).to include("The column number you chose is out of bounds.")
end
end
end









share|improve this question









New contributor




Brian Monaccio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
























    1















    I am writing a connect-four game for more OO and rspec practice. As part of my program, I would like to prompt the user to choose a column that they would like to put their game piece in. Here's that method:



    def get_col_choice(input, output)
    output.print "Player #@player, choose a column from 0-6: "
    input_string = input.gets.chomp
    begin
    col_choice = Integer(input_string)
    raise("The column you chose is out of bounds.") if out_of_bounds?(col_choice)
    raise("The column you chose is fully occupied.") if unavailable?(col_choice)
    return col_choice
    rescue TypeError, ArgumentError
    output.puts "Your choice of column is invalid. Try again."
    rescue RuntimeError => err
    puts err.message
    end
    get_col_choice(input, output)
    end


    In IRB, everything works as I planned. My hangup is in rspec where I am faced with a NoMethodError, which I think is coming from my recursive call to get_col_choice.



    Can anyone help me understand what I can do to either improve get_col_choice or write the correct tests in Rspec? This is what my console output from my rspec file looks like:



    Failures:

    1) ConnectFourGame#get_col_choice notifies users which player gets to choose a column
    Failure/Error: $connect_four.get_col_choice(input, output)

    NoMethodError:
    undefined method `chomp' for nil:NilClass
    # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:31:in `get_col_choice'
    # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:42:in `get_col_choice'
    # ./connect_four_game_spec.rb:52:in `block (3 levels) in <top (required)>'

    2) ConnectFourGame#get_col_choice returns the player's column choice
    Failure/Error: expect($connect_four.get_col_choice(input, output)).to eq(0)

    NoMethodError:
    undefined method `chomp' for nil:NilClass
    # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:31:in `get_col_choice'
    # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:42:in `get_col_choice'
    # ./connect_four_game_spec.rb:57:in `block (3 levels) in <top (required)>'

    3) ConnectFourGame#get_col_choice notifies the user if the column they chose is already full of pieces
    Failure/Error: expect(output.string).to include("The column you chose is fully occupied.")
    expected "" to include "The column you chose is fully occupied."
    # ./connect_four_game_spec.rb:62:in `block (3 levels) in <top (required)>'

    4) ConnectFourGame#get_col_choice notifies the user their input is invalid when a non-numeric string is entered
    Failure/Error: $connect_four.get_col_choice(input, output)

    NoMethodError:
    undefined method `chomp' for nil:NilClass
    # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:31:in `get_col_choice'
    # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:42:in `get_col_choice'
    # ./connect_four_game_spec.rb:67:in `block (3 levels) in <top (required)>'

    5) ConnectFourGame#get_col_choice column choice is out of bounds notifies the user their column choice is out of bounds when col is greater than 6
    Failure/Error: $connect_four.get_col_choice(input, output)

    NoMethodError:
    undefined method `chomp' for nil:NilClass
    # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:31:in `get_col_choice'
    # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:42:in `get_col_choice'
    # ./connect_four_game_spec.rb:74:in `block (4 levels) in <top (required)>'

    6) ConnectFourGame#get_col_choice column choice is out of bounds notifies the user their column choice is out of bounds when col is less than 0
    Failure/Error: $connect_four.get_col_choice(input, output)

    NoMethodError:
    undefined method `chomp' for nil:NilClass
    # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:31:in `get_col_choice'
    # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:42:in `get_col_choice'
    # ./connect_four_game_spec.rb:80:in `block (4 levels) in <top (required)>'

    Finished in 0.02399 seconds (files took 0.1108 seconds to load)
    12 examples, 6 failures

    Failed examples:

    rspec ./connect_four_game_spec.rb:51 # ConnectFourGame#get_col_choice notifies users which player gets to choose a column
    rspec ./connect_four_game_spec.rb:56 # ConnectFourGame#get_col_choice returns the player's column choice
    rspec ./connect_four_game_spec.rb:60 # ConnectFourGame#get_col_choice notifies the user if the column they chose is already full of pieces
    rspec ./connect_four_game_spec.rb:66 # ConnectFourGame#get_col_choice notifies the user their input is invalid when a non-numeric string is entered
    rspec ./connect_four_game_spec.rb:73 # ConnectFourGame#get_col_choice column choice is out of bounds notifies the user their column choice is out of bounds when col is greater than 6
    rspec ./connect_four_game_spec.rb:79 # ConnectFourGame#get_col_choice column choice is out of bounds notifies the user their column choice is out of bounds when col is less than 0


    Here are the tests I wrote for get_col_choice:



    describe '#get_col_choice' do
    let(:output) StringIO.new
    let(:input) StringIO.new("0n")
    it 'notifies users which player gets to choose a column' do
    $connect_four.get_col_choice(input, output)
    expect(output.string).to include("Player 2, choose a column from 0-6: ")
    end

    it "returns the player's column choice" do
    expect($connect_four.get_col_choice(input, output)).to eq(0)
    end

    it 'notifies the user if the column they chose is already full of pieces' do
    6.times $connect_four.board.add_game_piece_to(0, "u2468")
    expect(output.string).to include("The column you chose is fully occupied.")
    end

    let(:input) StringIO.new("!n")
    it 'notifies the user their input is invalid when a non-numeric string is entered' do
    $connect_four.get_col_choice(input, output)
    expect(output.string).to include("Your choice of column is invalid. Try again.")
    end

    context 'column choice is out of bounds' do
    let(:input) StringIO.new("7n")
    it 'notifies the user their column choice is out of bounds when col is greater than 6' do
    $connect_four.get_col_choice(input, output)
    expect(output.string).to include("The column you chose is out of bounds.")
    end

    let(:input) StringIO.new("-1n")
    it 'notifies the user their column choice is out of bounds when col is less than 0' do
    $connect_four.get_col_choice(input, output)
    expect(output.string).to include("The column number you chose is out of bounds.")
    end
    end
    end









    share|improve this question









    New contributor




    Brian Monaccio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      1












      1








      1








      I am writing a connect-four game for more OO and rspec practice. As part of my program, I would like to prompt the user to choose a column that they would like to put their game piece in. Here's that method:



      def get_col_choice(input, output)
      output.print "Player #@player, choose a column from 0-6: "
      input_string = input.gets.chomp
      begin
      col_choice = Integer(input_string)
      raise("The column you chose is out of bounds.") if out_of_bounds?(col_choice)
      raise("The column you chose is fully occupied.") if unavailable?(col_choice)
      return col_choice
      rescue TypeError, ArgumentError
      output.puts "Your choice of column is invalid. Try again."
      rescue RuntimeError => err
      puts err.message
      end
      get_col_choice(input, output)
      end


      In IRB, everything works as I planned. My hangup is in rspec where I am faced with a NoMethodError, which I think is coming from my recursive call to get_col_choice.



      Can anyone help me understand what I can do to either improve get_col_choice or write the correct tests in Rspec? This is what my console output from my rspec file looks like:



      Failures:

      1) ConnectFourGame#get_col_choice notifies users which player gets to choose a column
      Failure/Error: $connect_four.get_col_choice(input, output)

      NoMethodError:
      undefined method `chomp' for nil:NilClass
      # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:31:in `get_col_choice'
      # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:42:in `get_col_choice'
      # ./connect_four_game_spec.rb:52:in `block (3 levels) in <top (required)>'

      2) ConnectFourGame#get_col_choice returns the player's column choice
      Failure/Error: expect($connect_four.get_col_choice(input, output)).to eq(0)

      NoMethodError:
      undefined method `chomp' for nil:NilClass
      # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:31:in `get_col_choice'
      # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:42:in `get_col_choice'
      # ./connect_four_game_spec.rb:57:in `block (3 levels) in <top (required)>'

      3) ConnectFourGame#get_col_choice notifies the user if the column they chose is already full of pieces
      Failure/Error: expect(output.string).to include("The column you chose is fully occupied.")
      expected "" to include "The column you chose is fully occupied."
      # ./connect_four_game_spec.rb:62:in `block (3 levels) in <top (required)>'

      4) ConnectFourGame#get_col_choice notifies the user their input is invalid when a non-numeric string is entered
      Failure/Error: $connect_four.get_col_choice(input, output)

      NoMethodError:
      undefined method `chomp' for nil:NilClass
      # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:31:in `get_col_choice'
      # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:42:in `get_col_choice'
      # ./connect_four_game_spec.rb:67:in `block (3 levels) in <top (required)>'

      5) ConnectFourGame#get_col_choice column choice is out of bounds notifies the user their column choice is out of bounds when col is greater than 6
      Failure/Error: $connect_four.get_col_choice(input, output)

      NoMethodError:
      undefined method `chomp' for nil:NilClass
      # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:31:in `get_col_choice'
      # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:42:in `get_col_choice'
      # ./connect_four_game_spec.rb:74:in `block (4 levels) in <top (required)>'

      6) ConnectFourGame#get_col_choice column choice is out of bounds notifies the user their column choice is out of bounds when col is less than 0
      Failure/Error: $connect_four.get_col_choice(input, output)

      NoMethodError:
      undefined method `chomp' for nil:NilClass
      # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:31:in `get_col_choice'
      # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:42:in `get_col_choice'
      # ./connect_four_game_spec.rb:80:in `block (4 levels) in <top (required)>'

      Finished in 0.02399 seconds (files took 0.1108 seconds to load)
      12 examples, 6 failures

      Failed examples:

      rspec ./connect_four_game_spec.rb:51 # ConnectFourGame#get_col_choice notifies users which player gets to choose a column
      rspec ./connect_four_game_spec.rb:56 # ConnectFourGame#get_col_choice returns the player's column choice
      rspec ./connect_four_game_spec.rb:60 # ConnectFourGame#get_col_choice notifies the user if the column they chose is already full of pieces
      rspec ./connect_four_game_spec.rb:66 # ConnectFourGame#get_col_choice notifies the user their input is invalid when a non-numeric string is entered
      rspec ./connect_four_game_spec.rb:73 # ConnectFourGame#get_col_choice column choice is out of bounds notifies the user their column choice is out of bounds when col is greater than 6
      rspec ./connect_four_game_spec.rb:79 # ConnectFourGame#get_col_choice column choice is out of bounds notifies the user their column choice is out of bounds when col is less than 0


      Here are the tests I wrote for get_col_choice:



      describe '#get_col_choice' do
      let(:output) StringIO.new
      let(:input) StringIO.new("0n")
      it 'notifies users which player gets to choose a column' do
      $connect_four.get_col_choice(input, output)
      expect(output.string).to include("Player 2, choose a column from 0-6: ")
      end

      it "returns the player's column choice" do
      expect($connect_four.get_col_choice(input, output)).to eq(0)
      end

      it 'notifies the user if the column they chose is already full of pieces' do
      6.times $connect_four.board.add_game_piece_to(0, "u2468")
      expect(output.string).to include("The column you chose is fully occupied.")
      end

      let(:input) StringIO.new("!n")
      it 'notifies the user their input is invalid when a non-numeric string is entered' do
      $connect_four.get_col_choice(input, output)
      expect(output.string).to include("Your choice of column is invalid. Try again.")
      end

      context 'column choice is out of bounds' do
      let(:input) StringIO.new("7n")
      it 'notifies the user their column choice is out of bounds when col is greater than 6' do
      $connect_four.get_col_choice(input, output)
      expect(output.string).to include("The column you chose is out of bounds.")
      end

      let(:input) StringIO.new("-1n")
      it 'notifies the user their column choice is out of bounds when col is less than 0' do
      $connect_four.get_col_choice(input, output)
      expect(output.string).to include("The column number you chose is out of bounds.")
      end
      end
      end









      share|improve this question









      New contributor




      Brian Monaccio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I am writing a connect-four game for more OO and rspec practice. As part of my program, I would like to prompt the user to choose a column that they would like to put their game piece in. Here's that method:



      def get_col_choice(input, output)
      output.print "Player #@player, choose a column from 0-6: "
      input_string = input.gets.chomp
      begin
      col_choice = Integer(input_string)
      raise("The column you chose is out of bounds.") if out_of_bounds?(col_choice)
      raise("The column you chose is fully occupied.") if unavailable?(col_choice)
      return col_choice
      rescue TypeError, ArgumentError
      output.puts "Your choice of column is invalid. Try again."
      rescue RuntimeError => err
      puts err.message
      end
      get_col_choice(input, output)
      end


      In IRB, everything works as I planned. My hangup is in rspec where I am faced with a NoMethodError, which I think is coming from my recursive call to get_col_choice.



      Can anyone help me understand what I can do to either improve get_col_choice or write the correct tests in Rspec? This is what my console output from my rspec file looks like:



      Failures:

      1) ConnectFourGame#get_col_choice notifies users which player gets to choose a column
      Failure/Error: $connect_four.get_col_choice(input, output)

      NoMethodError:
      undefined method `chomp' for nil:NilClass
      # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:31:in `get_col_choice'
      # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:42:in `get_col_choice'
      # ./connect_four_game_spec.rb:52:in `block (3 levels) in <top (required)>'

      2) ConnectFourGame#get_col_choice returns the player's column choice
      Failure/Error: expect($connect_four.get_col_choice(input, output)).to eq(0)

      NoMethodError:
      undefined method `chomp' for nil:NilClass
      # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:31:in `get_col_choice'
      # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:42:in `get_col_choice'
      # ./connect_four_game_spec.rb:57:in `block (3 levels) in <top (required)>'

      3) ConnectFourGame#get_col_choice notifies the user if the column they chose is already full of pieces
      Failure/Error: expect(output.string).to include("The column you chose is fully occupied.")
      expected "" to include "The column you chose is fully occupied."
      # ./connect_four_game_spec.rb:62:in `block (3 levels) in <top (required)>'

      4) ConnectFourGame#get_col_choice notifies the user their input is invalid when a non-numeric string is entered
      Failure/Error: $connect_four.get_col_choice(input, output)

      NoMethodError:
      undefined method `chomp' for nil:NilClass
      # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:31:in `get_col_choice'
      # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:42:in `get_col_choice'
      # ./connect_four_game_spec.rb:67:in `block (3 levels) in <top (required)>'

      5) ConnectFourGame#get_col_choice column choice is out of bounds notifies the user their column choice is out of bounds when col is greater than 6
      Failure/Error: $connect_four.get_col_choice(input, output)

      NoMethodError:
      undefined method `chomp' for nil:NilClass
      # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:31:in `get_col_choice'
      # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:42:in `get_col_choice'
      # ./connect_four_game_spec.rb:74:in `block (4 levels) in <top (required)>'

      6) ConnectFourGame#get_col_choice column choice is out of bounds notifies the user their column choice is out of bounds when col is less than 0
      Failure/Error: $connect_four.get_col_choice(input, output)

      NoMethodError:
      undefined method `chomp' for nil:NilClass
      # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:31:in `get_col_choice'
      # /home/learnsometing/Desktop/the_Odin_Project/ruby/connect-four/lib/connect_four_game.rb:42:in `get_col_choice'
      # ./connect_four_game_spec.rb:80:in `block (4 levels) in <top (required)>'

      Finished in 0.02399 seconds (files took 0.1108 seconds to load)
      12 examples, 6 failures

      Failed examples:

      rspec ./connect_four_game_spec.rb:51 # ConnectFourGame#get_col_choice notifies users which player gets to choose a column
      rspec ./connect_four_game_spec.rb:56 # ConnectFourGame#get_col_choice returns the player's column choice
      rspec ./connect_four_game_spec.rb:60 # ConnectFourGame#get_col_choice notifies the user if the column they chose is already full of pieces
      rspec ./connect_four_game_spec.rb:66 # ConnectFourGame#get_col_choice notifies the user their input is invalid when a non-numeric string is entered
      rspec ./connect_four_game_spec.rb:73 # ConnectFourGame#get_col_choice column choice is out of bounds notifies the user their column choice is out of bounds when col is greater than 6
      rspec ./connect_four_game_spec.rb:79 # ConnectFourGame#get_col_choice column choice is out of bounds notifies the user their column choice is out of bounds when col is less than 0


      Here are the tests I wrote for get_col_choice:



      describe '#get_col_choice' do
      let(:output) StringIO.new
      let(:input) StringIO.new("0n")
      it 'notifies users which player gets to choose a column' do
      $connect_four.get_col_choice(input, output)
      expect(output.string).to include("Player 2, choose a column from 0-6: ")
      end

      it "returns the player's column choice" do
      expect($connect_four.get_col_choice(input, output)).to eq(0)
      end

      it 'notifies the user if the column they chose is already full of pieces' do
      6.times $connect_four.board.add_game_piece_to(0, "u2468")
      expect(output.string).to include("The column you chose is fully occupied.")
      end

      let(:input) StringIO.new("!n")
      it 'notifies the user their input is invalid when a non-numeric string is entered' do
      $connect_four.get_col_choice(input, output)
      expect(output.string).to include("Your choice of column is invalid. Try again.")
      end

      context 'column choice is out of bounds' do
      let(:input) StringIO.new("7n")
      it 'notifies the user their column choice is out of bounds when col is greater than 6' do
      $connect_four.get_col_choice(input, output)
      expect(output.string).to include("The column you chose is out of bounds.")
      end

      let(:input) StringIO.new("-1n")
      it 'notifies the user their column choice is out of bounds when col is less than 0' do
      $connect_four.get_col_choice(input, output)
      expect(output.string).to include("The column number you chose is out of bounds.")
      end
      end
      end






      ruby unit-testing testing tdd rspec3






      share|improve this question









      New contributor




      Brian Monaccio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      Brian Monaccio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited Mar 7 at 0:03









      Supa Mega Ducky Momo da Waffle

      2,00451129




      2,00451129






      New contributor




      Brian Monaccio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked Mar 6 at 22:13









      Brian MonaccioBrian Monaccio

      63




      63




      New contributor




      Brian Monaccio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Brian Monaccio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Brian Monaccio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          1 Answer
          1






          active

          oldest

          votes


















          0














          I was able to solve my problem by removing the input and output from get_col_choice:



          def get_col_choice
          print "Player #@player, choose a column from 0-6: "
          input_string = gets.chomp
          begin
          col_choice = Integer(input_string)
          raise("The column you chose is out of bounds.") if out_of_bounds?(col_choice)
          raise("The column you chose is fully occupied.") if @board.unavailable?(col_choice)
          return col_choice
          rescue TypeError, ArgumentError
          puts "Your choice of column is invalid. Try again."
          rescue RuntimeError => err
          puts err.message
          end
          get_col_choice
          end


          In my rspec file, instead of using StringIO to inject the behavior I expected into get_col_choice, I stubbed gets to return the values I needed to trigger expected behaviors:



          #code left out for brevity
          before(:each) do
          @game = ConnectFourGame.new
          end

          describe '#get_col_choice' do
          before(:each) do
          allow($stdout).to receive(:write)
          @game.player = 1
          end

          context 'valid input' do
          before(:each) do
          allow(@game).to receive(:gets) "0n"
          end

          it 'notifies users which player gets to choose a column' do
          expect @game.get_col_choice .to output('Player 1, choose a column from 0-6: ').to_stdout
          end

          it "returns the user's column choice as an integer" do
          expect(@game.get_col_choice).to eq(0)
          end
          end

          context 'invalid input' do
          output_expectation = Proc.new expect @game.get_col_choice .to output(output).to_stdout

          it 'notifies the user if the column they chose is already full of pieces' do
          allow(@game).to receive(:gets).and_return("0n", "1n")
          6.times @game.board.add_game_piece_to(0, "u2648")
          output = "Player 1, choose a column from 0-6: The column you chose is fully occupied.nPlayer 1, choose a column from 0-6: "
          output_expectation
          end

          it 'notifies the user their input is invalid when a non-numeric string is entered' do
          allow(@game).to receive(:gets).and_return("foon", "0n")
          output = "Player 1, choose a column from 0-6: Your choice of column is invalid. Try again.nPlayer 1, choose a column from 0-6: "
          output_expectation
          end

          it 'notifies the user their column choice is out of bounds when col is greater than 6' do
          allow(@game).to receive(:gets).and_return("7n", "0n")
          output = "Player 1, choose a column from 0-6: The column you chose is out of bounds.nPlayer 1, choose a column from 0-6: "
          output_expectation
          end

          it 'notifies the user their column choice is out of bounds when col is less than 0' do
          allow(@game).to receive(:gets).and_return("-1n", "0n")
          output = "Player 1, choose a column from 0-6: The column you chose is out of bounds.nPlayer 1, choose a column from 0-6: "
          output_expectation
          end
          end
          end


          The reason I received errors in my previous implementation of get_col_choice was because after StringIO received my first input string, it closed, resulting in a value of nil that I tried to call gets on.






          share|improve this answer








          New contributor




          Brian Monaccio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.



















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );






            Brian Monaccio is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55033020%2ftesting-recursive-io-prompt-in-rspec%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I was able to solve my problem by removing the input and output from get_col_choice:



            def get_col_choice
            print "Player #@player, choose a column from 0-6: "
            input_string = gets.chomp
            begin
            col_choice = Integer(input_string)
            raise("The column you chose is out of bounds.") if out_of_bounds?(col_choice)
            raise("The column you chose is fully occupied.") if @board.unavailable?(col_choice)
            return col_choice
            rescue TypeError, ArgumentError
            puts "Your choice of column is invalid. Try again."
            rescue RuntimeError => err
            puts err.message
            end
            get_col_choice
            end


            In my rspec file, instead of using StringIO to inject the behavior I expected into get_col_choice, I stubbed gets to return the values I needed to trigger expected behaviors:



            #code left out for brevity
            before(:each) do
            @game = ConnectFourGame.new
            end

            describe '#get_col_choice' do
            before(:each) do
            allow($stdout).to receive(:write)
            @game.player = 1
            end

            context 'valid input' do
            before(:each) do
            allow(@game).to receive(:gets) "0n"
            end

            it 'notifies users which player gets to choose a column' do
            expect @game.get_col_choice .to output('Player 1, choose a column from 0-6: ').to_stdout
            end

            it "returns the user's column choice as an integer" do
            expect(@game.get_col_choice).to eq(0)
            end
            end

            context 'invalid input' do
            output_expectation = Proc.new expect @game.get_col_choice .to output(output).to_stdout

            it 'notifies the user if the column they chose is already full of pieces' do
            allow(@game).to receive(:gets).and_return("0n", "1n")
            6.times @game.board.add_game_piece_to(0, "u2648")
            output = "Player 1, choose a column from 0-6: The column you chose is fully occupied.nPlayer 1, choose a column from 0-6: "
            output_expectation
            end

            it 'notifies the user their input is invalid when a non-numeric string is entered' do
            allow(@game).to receive(:gets).and_return("foon", "0n")
            output = "Player 1, choose a column from 0-6: Your choice of column is invalid. Try again.nPlayer 1, choose a column from 0-6: "
            output_expectation
            end

            it 'notifies the user their column choice is out of bounds when col is greater than 6' do
            allow(@game).to receive(:gets).and_return("7n", "0n")
            output = "Player 1, choose a column from 0-6: The column you chose is out of bounds.nPlayer 1, choose a column from 0-6: "
            output_expectation
            end

            it 'notifies the user their column choice is out of bounds when col is less than 0' do
            allow(@game).to receive(:gets).and_return("-1n", "0n")
            output = "Player 1, choose a column from 0-6: The column you chose is out of bounds.nPlayer 1, choose a column from 0-6: "
            output_expectation
            end
            end
            end


            The reason I received errors in my previous implementation of get_col_choice was because after StringIO received my first input string, it closed, resulting in a value of nil that I tried to call gets on.






            share|improve this answer








            New contributor




            Brian Monaccio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.
























              0














              I was able to solve my problem by removing the input and output from get_col_choice:



              def get_col_choice
              print "Player #@player, choose a column from 0-6: "
              input_string = gets.chomp
              begin
              col_choice = Integer(input_string)
              raise("The column you chose is out of bounds.") if out_of_bounds?(col_choice)
              raise("The column you chose is fully occupied.") if @board.unavailable?(col_choice)
              return col_choice
              rescue TypeError, ArgumentError
              puts "Your choice of column is invalid. Try again."
              rescue RuntimeError => err
              puts err.message
              end
              get_col_choice
              end


              In my rspec file, instead of using StringIO to inject the behavior I expected into get_col_choice, I stubbed gets to return the values I needed to trigger expected behaviors:



              #code left out for brevity
              before(:each) do
              @game = ConnectFourGame.new
              end

              describe '#get_col_choice' do
              before(:each) do
              allow($stdout).to receive(:write)
              @game.player = 1
              end

              context 'valid input' do
              before(:each) do
              allow(@game).to receive(:gets) "0n"
              end

              it 'notifies users which player gets to choose a column' do
              expect @game.get_col_choice .to output('Player 1, choose a column from 0-6: ').to_stdout
              end

              it "returns the user's column choice as an integer" do
              expect(@game.get_col_choice).to eq(0)
              end
              end

              context 'invalid input' do
              output_expectation = Proc.new expect @game.get_col_choice .to output(output).to_stdout

              it 'notifies the user if the column they chose is already full of pieces' do
              allow(@game).to receive(:gets).and_return("0n", "1n")
              6.times @game.board.add_game_piece_to(0, "u2648")
              output = "Player 1, choose a column from 0-6: The column you chose is fully occupied.nPlayer 1, choose a column from 0-6: "
              output_expectation
              end

              it 'notifies the user their input is invalid when a non-numeric string is entered' do
              allow(@game).to receive(:gets).and_return("foon", "0n")
              output = "Player 1, choose a column from 0-6: Your choice of column is invalid. Try again.nPlayer 1, choose a column from 0-6: "
              output_expectation
              end

              it 'notifies the user their column choice is out of bounds when col is greater than 6' do
              allow(@game).to receive(:gets).and_return("7n", "0n")
              output = "Player 1, choose a column from 0-6: The column you chose is out of bounds.nPlayer 1, choose a column from 0-6: "
              output_expectation
              end

              it 'notifies the user their column choice is out of bounds when col is less than 0' do
              allow(@game).to receive(:gets).and_return("-1n", "0n")
              output = "Player 1, choose a column from 0-6: The column you chose is out of bounds.nPlayer 1, choose a column from 0-6: "
              output_expectation
              end
              end
              end


              The reason I received errors in my previous implementation of get_col_choice was because after StringIO received my first input string, it closed, resulting in a value of nil that I tried to call gets on.






              share|improve this answer








              New contributor




              Brian Monaccio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.






















                0












                0








                0







                I was able to solve my problem by removing the input and output from get_col_choice:



                def get_col_choice
                print "Player #@player, choose a column from 0-6: "
                input_string = gets.chomp
                begin
                col_choice = Integer(input_string)
                raise("The column you chose is out of bounds.") if out_of_bounds?(col_choice)
                raise("The column you chose is fully occupied.") if @board.unavailable?(col_choice)
                return col_choice
                rescue TypeError, ArgumentError
                puts "Your choice of column is invalid. Try again."
                rescue RuntimeError => err
                puts err.message
                end
                get_col_choice
                end


                In my rspec file, instead of using StringIO to inject the behavior I expected into get_col_choice, I stubbed gets to return the values I needed to trigger expected behaviors:



                #code left out for brevity
                before(:each) do
                @game = ConnectFourGame.new
                end

                describe '#get_col_choice' do
                before(:each) do
                allow($stdout).to receive(:write)
                @game.player = 1
                end

                context 'valid input' do
                before(:each) do
                allow(@game).to receive(:gets) "0n"
                end

                it 'notifies users which player gets to choose a column' do
                expect @game.get_col_choice .to output('Player 1, choose a column from 0-6: ').to_stdout
                end

                it "returns the user's column choice as an integer" do
                expect(@game.get_col_choice).to eq(0)
                end
                end

                context 'invalid input' do
                output_expectation = Proc.new expect @game.get_col_choice .to output(output).to_stdout

                it 'notifies the user if the column they chose is already full of pieces' do
                allow(@game).to receive(:gets).and_return("0n", "1n")
                6.times @game.board.add_game_piece_to(0, "u2648")
                output = "Player 1, choose a column from 0-6: The column you chose is fully occupied.nPlayer 1, choose a column from 0-6: "
                output_expectation
                end

                it 'notifies the user their input is invalid when a non-numeric string is entered' do
                allow(@game).to receive(:gets).and_return("foon", "0n")
                output = "Player 1, choose a column from 0-6: Your choice of column is invalid. Try again.nPlayer 1, choose a column from 0-6: "
                output_expectation
                end

                it 'notifies the user their column choice is out of bounds when col is greater than 6' do
                allow(@game).to receive(:gets).and_return("7n", "0n")
                output = "Player 1, choose a column from 0-6: The column you chose is out of bounds.nPlayer 1, choose a column from 0-6: "
                output_expectation
                end

                it 'notifies the user their column choice is out of bounds when col is less than 0' do
                allow(@game).to receive(:gets).and_return("-1n", "0n")
                output = "Player 1, choose a column from 0-6: The column you chose is out of bounds.nPlayer 1, choose a column from 0-6: "
                output_expectation
                end
                end
                end


                The reason I received errors in my previous implementation of get_col_choice was because after StringIO received my first input string, it closed, resulting in a value of nil that I tried to call gets on.






                share|improve this answer








                New contributor




                Brian Monaccio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.










                I was able to solve my problem by removing the input and output from get_col_choice:



                def get_col_choice
                print "Player #@player, choose a column from 0-6: "
                input_string = gets.chomp
                begin
                col_choice = Integer(input_string)
                raise("The column you chose is out of bounds.") if out_of_bounds?(col_choice)
                raise("The column you chose is fully occupied.") if @board.unavailable?(col_choice)
                return col_choice
                rescue TypeError, ArgumentError
                puts "Your choice of column is invalid. Try again."
                rescue RuntimeError => err
                puts err.message
                end
                get_col_choice
                end


                In my rspec file, instead of using StringIO to inject the behavior I expected into get_col_choice, I stubbed gets to return the values I needed to trigger expected behaviors:



                #code left out for brevity
                before(:each) do
                @game = ConnectFourGame.new
                end

                describe '#get_col_choice' do
                before(:each) do
                allow($stdout).to receive(:write)
                @game.player = 1
                end

                context 'valid input' do
                before(:each) do
                allow(@game).to receive(:gets) "0n"
                end

                it 'notifies users which player gets to choose a column' do
                expect @game.get_col_choice .to output('Player 1, choose a column from 0-6: ').to_stdout
                end

                it "returns the user's column choice as an integer" do
                expect(@game.get_col_choice).to eq(0)
                end
                end

                context 'invalid input' do
                output_expectation = Proc.new expect @game.get_col_choice .to output(output).to_stdout

                it 'notifies the user if the column they chose is already full of pieces' do
                allow(@game).to receive(:gets).and_return("0n", "1n")
                6.times @game.board.add_game_piece_to(0, "u2648")
                output = "Player 1, choose a column from 0-6: The column you chose is fully occupied.nPlayer 1, choose a column from 0-6: "
                output_expectation
                end

                it 'notifies the user their input is invalid when a non-numeric string is entered' do
                allow(@game).to receive(:gets).and_return("foon", "0n")
                output = "Player 1, choose a column from 0-6: Your choice of column is invalid. Try again.nPlayer 1, choose a column from 0-6: "
                output_expectation
                end

                it 'notifies the user their column choice is out of bounds when col is greater than 6' do
                allow(@game).to receive(:gets).and_return("7n", "0n")
                output = "Player 1, choose a column from 0-6: The column you chose is out of bounds.nPlayer 1, choose a column from 0-6: "
                output_expectation
                end

                it 'notifies the user their column choice is out of bounds when col is less than 0' do
                allow(@game).to receive(:gets).and_return("-1n", "0n")
                output = "Player 1, choose a column from 0-6: The column you chose is out of bounds.nPlayer 1, choose a column from 0-6: "
                output_expectation
                end
                end
                end


                The reason I received errors in my previous implementation of get_col_choice was because after StringIO received my first input string, it closed, resulting in a value of nil that I tried to call gets on.







                share|improve this answer








                New contributor




                Brian Monaccio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                share|improve this answer



                share|improve this answer






                New contributor




                Brian Monaccio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                answered 2 days ago









                Brian MonaccioBrian Monaccio

                63




                63




                New contributor




                Brian Monaccio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.





                New contributor





                Brian Monaccio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






                Brian Monaccio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






















                    Brian Monaccio is a new contributor. Be nice, and check out our Code of Conduct.









                    draft saved

                    draft discarded


















                    Brian Monaccio is a new contributor. Be nice, and check out our Code of Conduct.












                    Brian Monaccio is a new contributor. Be nice, and check out our Code of Conduct.











                    Brian Monaccio is a new contributor. Be nice, and check out our Code of Conduct.














                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55033020%2ftesting-recursive-io-prompt-in-rspec%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

                    Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

                    2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived