This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
class Bingo | |
def self.generate_card | |
# 以下の行は削除して、自分でロジックを実装してください。 | |
sample | |
end | |
def self.sample | |
<<-CARD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/autorun' | |
module SumMatrix | |
extend self | |
def generate_sum_matrix(col: 4, row: 4, number_range: 1..1000) | |
matrix = generate_matrix(col: col, row: row, number_range: number_range) | |
format_matrix(sum_matrix(matrix)) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
require 'csv' | |
class FillBlankTest < Test::Unit::TestCase | |
def fill_blank(csv_text) | |
CSV.parse(csv_text).inject([]) { |results, row| | |
results << row.zip(results.last || []).map { |curr, prev| curr || prev } | |
} | |
.map { |row| row.join(',') } | |
.join("\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe 'Test true/truthy' do | |
context 'test 1' do | |
example do | |
expect(1).to be_truthy | |
end | |
example do | |
expect(1).to be true | |
end | |
example do | |
expect(1).to eq true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# gem 'database_cleaner', '~> 1.4' | |
RSpec.configure do |config| | |
config.before(:suite) do | |
DatabaseCleaner.clean_with(:truncation) | |
end | |
config.before(:each) do | |
DatabaseCleaner.strategy = :transaction | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
class Foo | |
def self.bar(*args) | |
raise 'Should be stubbed.' | |
end | |
end | |
describe 'Large args' do | |
example do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
class Foo | |
def self.bar(*args) | |
puts "foo" | |
"bar" | |
end | |
end | |
describe Foo do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# see also | |
# https://relishapp.com/rspec/rspec-mocks/v/3-9/docs/configuring-responses/block-implementation#simulating-a-transient-network-failure | |
describe 'Mock' do | |
specify do | |
foo = double | |
counter = 0 | |
allow(foo).to receive(:bar) do | |
if counter.zero? | |
counter += 1 | |
'abc' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rspec' | |
class Person | |
def hello(name) | |
puts "Hello, #{name}" | |
end | |
end | |
describe do | |
example do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe 'test' do | |
example do | |
x = [{id: 1, name: 'hoge'}, {id: 2, name: 'fuga'}] | |
expect(x).to a_collection_including a_hash_including(id: 2), a_hash_including(id: 1) | |
end | |
end |