mvcStudentXD 1.2.1 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +13 -0
  3. data/{mvcStudentXD/CHANGELOG.md → CHANGELOG.md} +5 -5
  4. data/{mvcStudentXD/CODE_OF_CONDUCT.md → CODE_OF_CONDUCT.md} +84 -84
  5. data/Gemfile +4 -6
  6. data/Gemfile.lock +97 -101
  7. data/README.md +34 -2
  8. data/{mvcStudentXD/Rakefile → Rakefile} +16 -16
  9. data/{mvcStudentXD/lib → lib}/mvcStudentXD/version.rb +5 -5
  10. data/lib/mvcStudentXD.rb +10 -0
  11. data/mvcStudentXD-1.2.2.gem +0 -0
  12. data/mvcStudentXD.gemspec +38 -0
  13. data/{mvcStudentXD/sig → sig}/mvcStudentXD.rbs +4 -4
  14. metadata +42 -91
  15. data/Lab1/arr1_3.txt +0 -1
  16. data/Lab1/lb1_1.rb +0 -19
  17. data/Lab1/lb1_2.rb +0 -28
  18. data/Lab1/lb1_3.rb +0 -46
  19. data/Lab1/lb1_4.rb +0 -82
  20. data/Lab2/1Class.jpg +0 -0
  21. data/Lab2/Web/main.rb +0 -89
  22. data/Lab2/Web/views/add.html +0 -168
  23. data/Lab2/Web/views/main.html +0 -233
  24. data/Lab2/data_storage/students1.txt +0 -1
  25. data/Lab2/data_storage/studentsRead.json +0 -36
  26. data/Lab2/data_storage/studentsRead.txt +0 -3
  27. data/Lab2/data_storage/studentsRead.yaml +0 -26
  28. data/Lab2/data_storage/studentsWrite.json +0 -42
  29. data/Lab2/data_storage/studentsWrite.txt +0 -4
  30. data/Lab2/data_storage/studentsWrite.yaml +0 -31
  31. data/Lab2/examples/Strategy.rb +0 -38
  32. data/Lab2/examples/adapter.rb +0 -30
  33. data/Lab2/examples/database.rb +0 -15
  34. data/Lab2/examples/observer_example.rb +0 -51
  35. data/Lab2/examples/pattern_pattern.rb +0 -44
  36. data/Lab2/examples/site_example.rb +0 -21
  37. data/Lab2/examples/views/about.erb +0 -11
  38. data/Lab2/examples/views/contact.erb +0 -15
  39. data/Lab2/examples/views/index.erb +0 -11
  40. data/Lab2/main.rb +0 -6
  41. data/Lab2/main_window.rb +0 -31
  42. data/Lab2/student_input_form.rb +0 -71
  43. data/Lab2/tab_students.rb +0 -157
  44. data/Lab2/test/student_test.rb +0 -91
  45. data/mvcStudentXD/Gemfile +0 -22
  46. data/mvcStudentXD/Gemfile.lock +0 -97
  47. data/mvcStudentXD/README.md +0 -35
  48. data/mvcStudentXD/bin/console +0 -11
  49. data/mvcStudentXD/bin/setup +0 -8
  50. data/mvcStudentXD/lib/mvcStudentXD.rb +0 -10
  51. data/mvcStudentXD/mvcStudentXD.gemspec +0 -15
  52. data/mvcStudentXD/pkg/mvcStudentXD-0.1.0.gem +0 -0
  53. data/mvcStudentXD/pkg/mvcStudentXD-1.0.1.gem +0 -0
  54. data/mvcStudentXD/pkg/mvcStudentXD-1.1.1.gem +0 -0
  55. data/mvcStudentXD/test/student_test.rb +0 -91
  56. data/mvcStudentXD/test/test_helper.rb +0 -6
  57. data/mvcStudentXD/test/test_mvcStudentXD.rb +0 -13
  58. /data/{mvcStudentXD/lib → lib}/source/adapters/student_list_adapter.rb +0 -0
  59. /data/{mvcStudentXD/lib → lib}/source/containers/Data_list.rb +0 -0
  60. /data/{mvcStudentXD/lib → lib}/source/containers/Data_list_student_short.rb +0 -0
  61. /data/{mvcStudentXD/lib → lib}/source/containers/Data_table.rb +0 -0
  62. /data/{mvcStudentXD/lib → lib}/source/controllers/student_edit_form_controller.rb +0 -0
  63. /data/{mvcStudentXD/lib → lib}/source/controllers/student_input_form_controller.rb +0 -0
  64. /data/{mvcStudentXD/lib → lib}/source/controllers/student_list_controller.rb +0 -0
  65. /data/{mvcStudentXD/lib → lib}/source/converters/Converter.rb +0 -0
  66. /data/{mvcStudentXD/lib → lib}/source/converters/Converter_json.rb +0 -0
  67. /data/{mvcStudentXD/lib → lib}/source/converters/Converter_txt.rb +0 -0
  68. /data/{mvcStudentXD/lib → lib}/source/converters/Converter_yaml.rb +0 -0
  69. /data/{mvcStudentXD/lib → lib}/source/database/scripts/create_table.sql +0 -0
  70. /data/{mvcStudentXD/lib → lib}/source/database/scripts/insert_data.sql +0 -0
  71. /data/{mvcStudentXD/lib → lib}/source/database/student_list_db.rb +0 -0
  72. /data/{mvcStudentXD/lib → lib}/source/database/students_db.rb +0 -0
  73. /data/{mvcStudentXD/lib → lib}/source/model/Student.rb +0 -0
  74. /data/{mvcStudentXD/lib → lib}/source/model/StudentBase.rb +0 -0
  75. /data/{mvcStudentXD/lib → lib}/source/model/Student_short.rb +0 -0
  76. /data/{mvcStudentXD/lib → lib}/source/repositories/Student_list.rb +0 -0
  77. /data/{mvcStudentXD/lib → lib}/source/repositories/student_list_adv.rb +0 -0
  78. /data/{mvcStudentXD/lib → lib}/source/util/LoggerHolder.rb +0 -0
  79. /data/{mvcStudentXD/mvcStudentXD-1.2.0.gem → mvcStudentXD-1.2.0.gem} +0 -0
@@ -1,71 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'glimmer-dsl-libui'
4
- require_relative '../mvcStudentXD/lib/student_input_form_controller'
5
- require_relative 'model/StudentBase'
6
- require 'win32api'
7
-
8
- class StudentInputForm
9
- include Glimmer
10
-
11
- def initialize(controller,existing_student = nil)
12
- @existing_student = existing_student.to_hash unless existing_student.nil?
13
- @controller = controller
14
- @entries = {}
15
- end
16
-
17
- def on_create
18
- @controller.on_view_created
19
- end
20
-
21
- def create
22
- @root_container = window('Универ', 300, 150) {
23
- resizable false
24
-
25
- vertical_box {
26
- @student_form = form {
27
- stretchy false
28
-
29
- fields = [[:last_name, 'Фамилия', false], [:first_name, 'Имя', false], [:parental_name, 'Отчество', false], [:git, 'Гит', true], [:telegram, 'Телеграм', true], [:email, 'Почта', true], [:phone, 'Телефон', true]]
30
-
31
- fields.each do |field|
32
- @entries[field[0]] = entry {
33
- label field[1]
34
- text @existing_student[field[0]] unless @existing_student.nil?
35
-
36
- read_only field[2] unless @existing_student.nil?
37
- }
38
- end
39
- }
40
-
41
- button('Сохранить') {
42
- stretchy false
43
-
44
- on_clicked {
45
- values = @entries.transform_values { |v| v.text.force_encoding("utf-8").strip }
46
- values.transform_values! { |v| v.empty? ? nil : v}
47
- @controller.process_fields(values)
48
- @controller.refresh
49
- }
50
- }
51
- }
52
- }
53
- on_create
54
- @root_container
55
- end
56
-
57
- def set_value(field, value)
58
- return unless @entries.include?(field)
59
- @entries[field].text = value
60
- end
61
-
62
- def make_readonly(*fields)
63
- fields.each do |field|
64
- @entries[field].read_only = true
65
- end
66
- end
67
-
68
- def close
69
- @root_container.destroy
70
- end
71
- end
data/Lab2/tab_students.rb DELETED
@@ -1,157 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # frozen_string_literal: true
4
- require 'glimmer-dsl-libui'
5
- require_relative '../mvcStudentXD/lib/student_list_controller'
6
- require_relative '../mvcStudentXD/lib/b'
7
-
8
- class TabStudents
9
- include Glimmer
10
- STUDENTS_PER_PAGE = 20
11
-
12
- def initialize
13
- @controller = StudentListController.new(self)
14
- @current_page = 1
15
- @total_count = 0
16
- end
17
-
18
- def on_create
19
- @controller.on_view_created
20
- @controller.refresh_data(@current_page, STUDENTS_PER_PAGE)
21
- end
22
-
23
- # Метод наблюдателя datalist
24
- def on_datalist_changed(new_table)
25
- arr = new_table.to_2d_array
26
- @table.model_array = arr
27
- end
28
-
29
- def update_student_count(new_cnt)
30
- @total_count = new_cnt
31
- @page_label.text = "#{@current_page} / #{(@total_count / STUDENTS_PER_PAGE.to_f).ceil}"
32
- end
33
-
34
- def create
35
- root = horizontal_box {
36
- # Секция 1
37
- vertical_box {
38
- stretchy false
39
-
40
- form {
41
- stretchy false
42
-
43
- @filter_last_name_initials = entry {
44
- label 'ФИО'
45
- }
46
-
47
- @filters = {}
48
- fields = [[:git, 'Github'], [:email, 'Почта'], [:phone, 'Телефон'], [:telegram, 'Телеграм']]
49
-
50
- fields.each do |field|
51
- @filters[field[0]] = {}
52
-
53
- @filters[field[0]][:combobox] = combobox {
54
- label "#{field[1]}?"
55
- items ['Не важно', 'Есть', 'Нет']
56
- selected 0
57
-
58
- on_selected do
59
- if @filters[field[0]][:combobox].selected == 1
60
- @filters[field[0]][:entry].read_only = false
61
- else
62
- @filters[field[0]][:entry].text = ''
63
- @filters[field[0]][:entry].read_only = true
64
- end
65
- end
66
- }
67
-
68
- @filters[field[0]][:entry] = entry {
69
- label field[1]
70
- read_only true
71
- }
72
- end
73
- }
74
- }
75
-
76
- # Секция 2
77
- vertical_box {
78
- @table = refined_table(
79
- table_editable: false,
80
- filter: lambda do |row_hash, query|
81
- utf8_query = query.force_encoding("utf-8")
82
- row_hash['Фамилия И. О'].include?(utf8_query)
83
- end,
84
- table_columns: {
85
- '#' => :text,
86
- 'Фамилия И. О' => :text,
87
- 'Гит' => :text,
88
- 'Контакт' => :text,
89
- },
90
- per_page: STUDENTS_PER_PAGE
91
- )
92
-
93
- @pages = horizontal_box {
94
- stretchy false
95
-
96
- button("<") { stretchy true }
97
- button("<") {
98
- stretchy true
99
-
100
- on_clicked do
101
- @current_page = [@current_page - 1, 1].max
102
- @controller.refresh_data(@current_page, STUDENTS_PER_PAGE)
103
- end
104
-
105
- }
106
- @page_label = label("...") { stretchy false }
107
- button(">") { stretchy true }
108
- button(">") {
109
- stretchy true
110
-
111
- on_clicked do
112
- @current_page = [@current_page + 1, (@total_count / STUDENTS_PER_PAGE.to_f).ceil].min
113
- @controller.refresh_data(@current_page, STUDENTS_PER_PAGE)
114
- end
115
- }
116
- }
117
- }
118
-
119
- # Секция 3
120
- vertical_box {
121
- stretchy true
122
-
123
- button('Добавить') {
124
- stretchy false
125
-
126
- on_clicked {
127
- @controller.show_modal_add()
128
- }
129
- }
130
- button('Изменить') {
131
- stretchy false
132
-
133
- on_clicked {
134
- @controller.show_modal_edit(@current_page, STUDENTS_PER_PAGE, @table.selection) unless @table.selection.nil?
135
- }
136
- }
137
- button('Удалить') {
138
- stretchy false
139
-
140
- on_clicked {
141
- @controller.delete_selected(@current_page, STUDENTS_PER_PAGE, @table.selection) unless @table.selection.nil?
142
- @controller.refresh_data(@current_page, STUDENTS_PER_PAGE)
143
- }
144
- }
145
- button('Обновить') {
146
- stretchy false
147
- on_clicked{
148
- @controller.refresh_data(@current_page, STUDENTS_PER_PAGE)
149
- }
150
- }
151
- }
152
- }
153
- on_create
154
- root
155
- end
156
-
157
- end
@@ -1,91 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'minitest/autorun'
3
- require 'json'
4
- require_relative '../../mvcStudentXD/lib/model/Student'
5
-
6
- class StudentTest < Minitest::Test
7
- def setup
8
- @student = Student.new(
9
- 'Лукашев',
10
- 'Алексей',
11
- 'Андреевич',
12
- id: 10,
13
- phone: '89099997499',
14
- telegram: '@lehadrilla',
15
- email: 'leha@gmail.com',
16
- git: '@netuOnNeftyanik'
17
- )
18
- end
19
-
20
- def teardown
21
- # Do nothing
22
- end
23
-
24
- def test_student_init_all_params_correct
25
- assert @student.last_name == 'Лукашев'
26
- assert @student.first_name == 'Алексей'
27
- assert @student.parental_name == 'Андреевич'
28
- assert @student.id == 10
29
- assert @student.phone == '89099997499'
30
- assert @student.telegram == '@lehadrilla'
31
- assert @student.email == 'leha@gmail.com'
32
- assert @student.git == '@netuOnNeftyanik'
33
- end
34
-
35
- def test_student_empty_options
36
- Student.new('Сергеев', 'Сергей', 'Сергеевич')
37
- end
38
-
39
- def test_student_short_contact
40
- short_contact = @student.get_short_contact
41
-
42
-
43
- assert short_contact[:type] == :telegram
44
- assert short_contact[:val] == '@lehadrilla'
45
- end
46
-
47
- def test_student_has_contacts
48
- assert @student.valid_cont? == true
49
- end
50
-
51
- def test_student_set_contacts
52
- stud = Student.new('Орфов', 'Орф', 'Орфович')
53
- stud.set_contacts(phone: '89097768999', telegram: '@kasha', email: 'kasha@gmail.com')
54
-
55
- assert stud.phone == '89097768999'
56
- assert stud.telegram == '@kasha'
57
- assert stud.email == 'kasha@gmail.com'
58
- end
59
-
60
- def test_student_get_short_fio
61
- assert @student.get_short_fio == 'fio:Лукашев А. А.'
62
- end
63
-
64
-
65
- def test_student_from_and_to_hash
66
- test_hash = {
67
- last_name: 'Жанов',
68
- first_name: 'Жан',
69
- parental_name: 'Жанович',
70
- id: 5,
71
- phone: '87776665544',
72
- telegram: '@abv',
73
- email: 'abv@mail.ru',
74
- git: '@abvG'
75
- }
76
-
77
-
78
- stud = Student.from_hash(test_hash)
79
-
80
- assert stud.last_name == 'Жанов'
81
- assert stud.first_name == 'Жан'
82
- assert stud.parental_name == 'Жанович'
83
- assert stud.id == 5
84
- assert stud.phone == '87776665544'
85
- assert stud.telegram == '@abv'
86
- assert stud.email == 'abv@mail.ru'
87
- assert stud.git == '@abvG'
88
-
89
- assert stud.to_hash == test_hash
90
- end
91
- end
data/mvcStudentXD/Gemfile DELETED
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- # Specify your gem's dependencies in mvcStudentXD.gemspec
6
- gemspec
7
-
8
- gem "rake", "~> 13.0"
9
-
10
- gem "minitest", "~> 5.0"
11
-
12
- gem "rubocop", "~> 1.21"
13
-
14
- gem "mysql2"
15
-
16
- gem "glimmer-dsl-libui", '~> 0.7.4'
17
-
18
- gem 'win32api'
19
-
20
- gem 'sinatra', '~> 3.0', '>= 3.0.6'
21
-
22
- gem 'thin', '~> 1.8', '>= 1.8.2'
@@ -1,97 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- mvcStudentXD (1.1.2)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- array_include_methods (1.4.0)
10
- ast (2.4.2)
11
- chunky_png (1.4.0)
12
- color (1.8)
13
- daemons (1.4.1)
14
- equalizer (0.0.11)
15
- eventmachine (1.2.7)
16
- facets (3.1.0)
17
- glimmer (2.7.3)
18
- array_include_methods (~> 1.4.0)
19
- facets (>= 3.1.0, < 4.0.0)
20
- glimmer-dsl-libui (0.7.5)
21
- chunky_png (~> 1.4.0)
22
- color (~> 1.8)
23
- equalizer (= 0.0.11)
24
- glimmer (~> 2.7.3)
25
- libui (~> 0.1.2.pre)
26
- os (>= 1.0.0, < 2.0.0)
27
- perfect-shape (~> 1.0.7)
28
- rouge (>= 3.26.0, < 4.0.0)
29
- super_module (~> 1.4.1)
30
- json (2.6.3)
31
- libui (0.1.2.pre-x64-mingw)
32
- matrix (0.4.2)
33
- method_source (1.0.0)
34
- minitest (5.18.0)
35
- mustermann (3.0.0)
36
- ruby2_keywords (~> 0.0.1)
37
- mysql2 (0.5.5)
38
- os (1.1.4)
39
- parallel (1.23.0)
40
- parser (3.2.2.1)
41
- ast (~> 2.4.1)
42
- perfect-shape (1.0.7)
43
- equalizer (>= 0.0.11, < 1.1.0)
44
- matrix (>= 0.4.2, < 1.1.0)
45
- rack (2.2.7)
46
- rack-protection (3.0.6)
47
- rack
48
- rainbow (3.1.1)
49
- rake (13.0.6)
50
- regexp_parser (2.8.0)
51
- rexml (3.2.5)
52
- rouge (3.30.0)
53
- rubocop (1.50.2)
54
- json (~> 2.3)
55
- parallel (~> 1.10)
56
- parser (>= 3.2.0.0)
57
- rainbow (>= 2.2.2, < 4.0)
58
- regexp_parser (>= 1.8, < 3.0)
59
- rexml (>= 3.2.5, < 4.0)
60
- rubocop-ast (>= 1.28.0, < 2.0)
61
- ruby-progressbar (~> 1.7)
62
- unicode-display_width (>= 2.4.0, < 3.0)
63
- rubocop-ast (1.28.1)
64
- parser (>= 3.2.1.0)
65
- ruby-progressbar (1.13.0)
66
- ruby2_keywords (0.0.5)
67
- sinatra (3.0.6)
68
- mustermann (~> 3.0)
69
- rack (~> 2.2, >= 2.2.4)
70
- rack-protection (= 3.0.6)
71
- tilt (~> 2.0)
72
- super_module (1.4.1)
73
- method_source (>= 0.8.2, < 1.1.0)
74
- thin (1.8.2)
75
- daemons (~> 1.0, >= 1.0.9)
76
- eventmachine (~> 1.0, >= 1.0.4)
77
- rack (>= 1, < 3)
78
- tilt (2.1.0)
79
- unicode-display_width (2.4.2)
80
- win32api (0.1.0)
81
-
82
- PLATFORMS
83
- x64-mingw-ucrt
84
-
85
- DEPENDENCIES
86
- glimmer-dsl-libui (~> 0.7.4)
87
- minitest (~> 5.0)
88
- mvcStudentXD!
89
- mysql2
90
- rake (~> 13.0)
91
- rubocop (~> 1.21)
92
- sinatra (~> 3.0, >= 3.0.6)
93
- thin (~> 1.8, >= 1.8.2)
94
- win32api
95
-
96
- BUNDLED WITH
97
- 2.4.12
@@ -1,35 +0,0 @@
1
- # MvcStudentXD
2
-
3
- TODO: Delete this and the text below, and describe your gem
4
-
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/mvcStudentXD`. To experiment with that code, run `bin/console` for an interactive prompt.
6
-
7
- ## Installation
8
-
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
-
11
- Install the gem and add to the application's Gemfile by executing:
12
-
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
14
-
15
- If bundler is not being used to manage dependencies, install the gem by executing:
16
-
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
18
-
19
- ## Usage
20
-
21
- TODO: Write usage instructions here
22
-
23
- ## Development
24
-
25
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
-
27
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
-
29
- ## Contributing
30
-
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/mvcStudentXD. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/mvcStudentXD/blob/master/CODE_OF_CONDUCT.md).
32
-
33
- ## Code of Conduct
34
-
35
- Everyone interacting in the MvcStudentXD project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/mvcStudentXD/blob/master/CODE_OF_CONDUCT.md).
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "bundler/setup"
5
- require "mvcStudentXD"
6
-
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- require "irb"
11
- IRB.start(__FILE__)
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "mvcStudentXD/version"
4
-
5
- module MvcStudentXD
6
- Dir[File.dirname(__FILE__) + 'source/**/*.rb'].each { |file|
7
- puts file
8
- require file
9
- }
10
- end
@@ -1,15 +0,0 @@
1
- require_relative "lib/mvcStudentXD/version"
2
-
3
- Gem::Specification.new do |spec|
4
- spec.name = "mvcStudentXD"
5
- spec.version = MvcStudentXD::VERSION
6
- spec.authors = ["papaSquid"]
7
- spec.email = ["bakladjant@mail.ru"]
8
- spec.summary = "DeadInside"
9
- spec.description = "А simple ruby gem"
10
- spec.homepage = "https://github.com/KiTTeNqz/mvcStudentXD"
11
- spec.license = "MIT"
12
- spec.required_ruby_version = ">= 2.6.0"
13
- spec.add_dependency 'win32api'
14
- spec.files = Dir.glob("**/*")
15
- end
@@ -1,91 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'minitest/autorun'
3
- require 'json'
4
- require_relative '../../Lab2/udentXD/lib/Student'
5
-
6
- class StudentTest < Minitest::Test
7
- def setup
8
- @student = Student.new(
9
- 'Лукашев',
10
- 'Алексей',
11
- 'Андреевич',
12
- id: 10,
13
- phone: '89099997499',
14
- telegram: '@lehadrilla',
15
- email: 'leha@gmail.com',
16
- git: '@netuOnNeftyanik'
17
- )
18
- end
19
-
20
- def teardown
21
- # Do nothing
22
- end
23
-
24
- def test_student_init_all_params_correct
25
- assert @student.last_name == 'Лукашев'
26
- assert @student.first_name == 'Алексей'
27
- assert @student.parental_name == 'Андреевич'
28
- assert @student.id == 10
29
- assert @student.phone == '89099997499'
30
- assert @student.telegram == '@lehadrilla'
31
- assert @student.email == 'leha@gmail.com'
32
- assert @student.git == '@netuOnNeftyanik'
33
- end
34
-
35
- def test_student_empty_options
36
- Student.new('Сергеев', 'Сергей', 'Сергеевич')
37
- end
38
-
39
- def test_student_short_contact
40
- short_contact = @student.get_short_contact
41
-
42
-
43
- assert short_contact[:type] == :telegram
44
- assert short_contact[:val] == '@lehadrilla'
45
- end
46
-
47
- def test_student_has_contacts
48
- assert @student.valid_cont? == true
49
- end
50
-
51
- def test_student_set_contacts
52
- stud = Student.new('Орфов', 'Орф', 'Орфович')
53
- stud.set_contacts(phone: '89097768999', telegram: '@kasha', email: 'kasha@gmail.com')
54
-
55
- assert stud.phone == '89097768999'
56
- assert stud.telegram == '@kasha'
57
- assert stud.email == 'kasha@gmail.com'
58
- end
59
-
60
- def test_student_get_short_fio
61
- assert @student.get_short_fio == 'fio:Лукашев А. А.'
62
- end
63
-
64
-
65
- def test_student_from_and_to_hash
66
- test_hash = {
67
- last_name: 'Жанов',
68
- first_name: 'Жан',
69
- parental_name: 'Жанович',
70
- id: 5,
71
- phone: '87776665544',
72
- telegram: '@abv',
73
- email: 'abv@mail.ru',
74
- git: '@abvG'
75
- }
76
-
77
-
78
- stud = Student.from_hash(test_hash)
79
-
80
- assert stud.last_name == 'Жанов'
81
- assert stud.first_name == 'Жан'
82
- assert stud.parental_name == 'Жанович'
83
- assert stud.id == 5
84
- assert stud.phone == '87776665544'
85
- assert stud.telegram == '@abv'
86
- assert stud.email == 'abv@mail.ru'
87
- assert stud.git == '@abvG'
88
-
89
- assert stud.to_hash == test_hash
90
- end
91
- end
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
4
- require "mvcStudentXD"
5
-
6
- require "minitest/autorun"
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "test_helper"
4
-
5
- class TestMvcStudentXD < Minitest::Test
6
- def test_that_it_has_a_version_number
7
- refute_nil ::MvcStudentXD::VERSION
8
- end
9
-
10
- def test_it_does_something_useful
11
- assert false
12
- end
13
- end
File without changes