Let's make draw poker with ruby ~ test-unit preparation ~

Overview

Let's make draw poker with ruby-Preparation-

Followed by.

Source: https://github.com/rytkmt/ruby_poker

I don't know the test-unit at all ... So this time I will prepare the test-unit.

Preparation

Please refer to this Official page to proceed.

However, since it is not a gem, the procedure seems to change a little ... So I will keep a record of the procedure including that

Initial file preparation

$ cd ruby_poker
$ bundle gem -t minitest ./
git status -sb

A  .gitignore
A  .travis.yml
A  CODE_OF_CONDUCT.md
A  Gemfile
A  LICENSE.txt
A  Rakefile
A  bin/console
A  bin/setup
A  lib/ruby_poker.rb
A  lib/ruby_poker/version.rb
A  ruby_poker.gemspec
A  test/ruby_poker_test.rb
A  test/test_helper.rb

Quite made

Remove gemspec because it is not gem

$ git rm ruby_poker.gemspec

File modification

Gemfile

Gemfile


-# Specify your gem's dependencies in ruby_poker.gemspec
-gemspec
+gem "rake"
+group :test do
+  gem "pry-byebug"
+  gem "test-unit"
+  gem "test-unit-rr"
+end

Delete gemspec line Instead, change from minitest to test-unit, so install gem first

$ bundle install

At this time, edit .gitignore as necessary so that the files installed by bundler do not go up to git.

Rakefile

Rakefile


-require "bundler/gem_tasks"
 require "rake/testtask"

test/test_helper.rb

test/test_helper.rb


 $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
 require "ruby_poker"
 
-require "minitest/autorun"
+require "pry"
+require "test/unit"
+require "test/unit/rr"

test/ruby_poker_test.rb

test/ruby_poker_test.rb


 require "test_helper"
 
-class RubyPokerTest < Minitest::Test
+class RubyPokerTest < Test::Unit::TestCase
   def test_that_it_has_a_version_number
     refute_nil ::RubyPoker::VERSION
   end

bin/console

When I run bundle exec console, I get an error because ruby_poker is not in LOAD_PATH. So add it to LOAD_PATH

bin/console


 require "bundler/setup"
+$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
+
 require "ruby_poker"

Operation check

console

Execute bundle exec console and OK if irb starts up

test

Since the test case is created as a sample so that bundle exec rake test is executed and 1 case fails, 1 case succeeds and 1 case fails.

$ rake test
/home/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/file_utils.rb:54: warning: Insecure world writable dir /home in PATH, mode 040707
Loaded suite /home/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rake-12.3.2/lib/rake/rake_test_loader
Started
F
==============================================================================================================================================================
      6:   end
      7: 
      8:   def test_it_does_something_useful
  =>  9:     assert false
     10:   end
     11: end
/home/vagrant/private_workspace/ruby_poker/test/ruby_poker_test.rb:9:in `test_it_does_something_useful'
Failure: test_it_does_something_useful(RubyPokerTest): <false> is not true.
==============================================================================================================================================================
.
Finished in 0.004560792 seconds.
--------------------------------------------------------------------------------------------------------------------------------------------------------------
2 tests, 2 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
50% passed
--------------------------------------------------------------------------------------------------------------------------------------------------------------
438.52 tests/s, 438.52 assertions/s
rake aborted!
Command failed with status (1)

Tasks: TOP => test
(See full trace by running task with --trace)

Continued

Let's make draw poker with ruby-Implementation 1 (card)-

Recommended Posts

Let's make draw poker with ruby ~ test-unit preparation ~
Let's make draw poker with ruby ~ Preparation ~
Let's make draw poker with ruby-Implementation 4 (Deck)-
Let's make draw poker with ruby-Implementation 3 (player)-
Let's make draw poker with ruby-Implementation 2 (role)-
Let's make a smart home with Ruby!
Let's make a LINE Bot with Ruby + Sinatra --Part 2
Let's make a LINE Bot with Ruby + Sinatra --Part 1
Make electronic music with randomness with Ruby
Let's use Amazon Textract with Ruby
Make a typing game with ruby
Make Ruby Kurosawa with Ruby (Ruby + LINE Messaging API)
Let's make a Christmas card with Processing!
Let's make an error screen with Rails
Let's make a search function with Rails (ransack)
How to make LINE messaging function made with Ruby
[Java basics] Let's make a triangle with a for statement
Make Nginx of CentOS8 SSL compatible with Let's Encrypt