File tree Expand file tree Collapse file tree 6 files changed +33
-4
lines changed
Expand file tree Collapse file tree 6 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -68,10 +68,11 @@ group :test do
6868 # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
6969 gem "capybara"
7070 gem "selenium-webdriver"
71+ gem 'simplecov'
7172end
7273
7374group :production do
7475 gem 'pg'
7576end
7677
77- gem 'aws-sdk-s3' , '~> 1'
78+ gem 'aws-sdk-s3' , '~> 1'
Original file line number Diff line number Diff line change 121121 debug (1.9.2 )
122122 irb (~> 1.10 )
123123 reline (>= 0.3.8 )
124+ docile (1.4.1 )
124125 drb (2.2.1 )
125126 erubi (1.13.0 )
126127 globalid (1.2.1 )
256257 rexml (~> 3.2 , >= 3.2.5 )
257258 rubyzip (>= 1.2.2 , < 3.0 )
258259 websocket (~> 1.0 )
260+ simplecov (0.22.0 )
261+ docile (~> 1.1 )
262+ simplecov-html (~> 0.11 )
263+ simplecov_json_formatter (~> 0.1 )
264+ simplecov-html (0.13.1 )
265+ simplecov_json_formatter (0.1.4 )
259266 sprockets (4.2.1 )
260267 concurrent-ruby (~> 1.0 )
261268 rack (>= 2.2.4 , < 4 )
@@ -318,6 +325,7 @@ DEPENDENCIES
318325 rails (~> 7.1.3 , >= 7.1.3.4 )
319326 rubocop
320327 selenium-webdriver
328+ simplecov
321329 sprockets-rails
322330 sqlite3 (~> 1.4 )
323331 stimulus-rails
Original file line number Diff line number Diff line change @@ -10,9 +10,8 @@ class Message < ApplicationRecord
1010 # https://blade.ruby-lang.org/ruby-talk/410000 is not.
1111 self . skip_time_zone_conversion_for_attributes = [ :published_at ]
1212
13- def self . from_s3 ( list_name , list_seq )
14- client = Aws ::S3 ::Client . new ( region : BLADE_BUCKET_REGION )
15- obj = client . get_object ( bucket : BLADE_BUCKET_NAME , key : "#{ list_name } /#{ list_seq } " )
13+ def self . from_s3 ( list_name , list_seq , s3_client = Aws ::S3 ::Client . new ( region : BLADE_BUCKET_REGION ) )
14+ obj = s3_client . get_object ( bucket : BLADE_BUCKET_NAME , key : "#{ list_name } /#{ list_seq } " )
1615
1716 m = self . from_string ( obj . body . read )
1817 m . list_id = List . find_by_name ( list_name ) . id
Original file line number Diff line number Diff line change @@ -4,4 +4,8 @@ class ListTest < ActiveSupport::TestCase
44 test 'name' do
55 assert_equal 'ruby-list' , List ::find_by_name ( 'ruby-list' ) . name
66 end
7+
8+ test 'find_by_id' do
9+ assert_equal 'ruby-list' , List . find_by_id ( 1 ) . name
10+ end
711end
Original file line number Diff line number Diff line change @@ -14,4 +14,16 @@ class MessageTest < ActiveSupport::TestCase
1414
1515 assert_equal DateTime . parse ( '2005-12-15T19:32:40+09:00' ) , m . published_at
1616 end
17+
18+ test 'from_s3' do
19+ s3_client = Aws ::S3 ::Client . new ( stub_responses : true )
20+ s3_client . stub_responses ( :get_object , body : <<END_OF_BODY )
21+ Subject: [ruby-list:1] Hello
22+ From: alice@...
23+ Date: 2005-12-15T19:32:40+09:00
24+
25+ Hello, world!
26+ END_OF_BODY
27+ Message . from_s3 ( 'ruby-list' , 1234 , s3_client )
28+ end
1729end
Original file line number Diff line number Diff line change 1+ require 'simplecov'
2+ SimpleCov . start 'rails'
3+ SimpleCov . minimum_coverage 50
4+
15ENV [ "RAILS_ENV" ] ||= "test"
26require_relative "../config/environment"
37require "rails/test_help"
48
9+
510module ActiveSupport
611 class TestCase
712 # Run tests in parallel with specified workers
You can’t perform that action at this time.
0 commit comments