rabbit-slide-giosakti-201710-self-testing-code-ruby 2017.10.16.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: be2374201421f3324dc50abd6b6ffe86915e82ab
4
+ data.tar.gz: 6369b6a58f4610eda8a5969306344fad3f6500d0
5
+ SHA512:
6
+ metadata.gz: 7f717b5034a0bde3489ea06836d174200b4c042f539d8e79462c9087e91ade0ac1c4e5db71b6bface646529895ac4dc089d0109178be307e14276db6666aca60
7
+ data.tar.gz: cfd8b9487eed02eb132e4f21ca03033ffa6307452567807769b71449130ae09313ed90ade54f2f3d50c6def6ecf9dd7273ba2095ef40c8192bd11b082c3a32fe
data/.rabbit ADDED
@@ -0,0 +1 @@
1
+ self-testing-code-ruby.rab
@@ -0,0 +1,36 @@
1
+ # Self-testing Code in Ruby
2
+
3
+ This talk explains the concept of self-testing code with practices in ruby using rspec.
4
+
5
+ ## License
6
+
7
+ ### Slide
8
+
9
+ MIT
10
+
11
+ Use the followings for notation of the author:
12
+
13
+ * Giovanni Sakti
14
+
15
+ ## For author
16
+
17
+ ### Show
18
+
19
+ rake
20
+
21
+ ### Publish
22
+
23
+ rake publish
24
+
25
+ # or for rubygems only
26
+ rake publish:rubygems
27
+
28
+ ## For viewers
29
+
30
+ ### Install
31
+
32
+ gem install rabbit-slide-giosakti-201710-self-testing-code-ruby
33
+
34
+ ### Show
35
+
36
+ rabbit rabbit-slide-giosakti-201710-self-testing-code-ruby.gem
@@ -0,0 +1,20 @@
1
+ require "rabbit/task/slide"
2
+
3
+ # Edit ./config.yaml to customize meta data
4
+
5
+ spec = nil
6
+ Rabbit::Task::Slide.new do |task|
7
+ spec = task.spec
8
+ spec.files += Dir.glob("images/**/*.*")
9
+ # spec.files -= Dir.glob("private/**/*.*")
10
+
11
+ # You may include other themes here
12
+ # spec.add_runtime_dependency("rabbit-theme-nyankosakana")
13
+ # spec.add_runtime_dependency("rabbit-theme-yart")
14
+ end
15
+
16
+ desc "Tag #{spec.version}"
17
+ task :tag do
18
+ sh("git", "tag", "-a", spec.version.to_s, "-m", "Publish #{spec.version}")
19
+ sh("git", "push", "--tags")
20
+ end
@@ -0,0 +1,23 @@
1
+ ---
2
+ id: 201710-self-testing-code-ruby
3
+ base_name: 201710-self-testing-code-ruby
4
+ tags:
5
+ - rabbit
6
+ - ruby
7
+ - rspec
8
+ presentation_date: 2017-10-16
9
+ version: 2017.10.16.2
10
+ licenses:
11
+ - MIT
12
+ slideshare_id:
13
+ speaker_deck_id:
14
+ ustream_id:
15
+ vimeo_id:
16
+ youtube_id:
17
+ author:
18
+ markup_language: :rd
19
+ name: Giovanni Sakti
20
+ email: giosakti@gmail.com
21
+ rubygems_user: giosakti
22
+ slideshare_user:
23
+ speaker_deck_user: giosakti
@@ -0,0 +1,176 @@
1
+ = Self-testing Code in Ruby
2
+
3
+ % : subtitle
4
+ % in Ruby
5
+ : author
6
+ Giovanni Sakti
7
+ : institution
8
+ Starqle
9
+ % : content-source
10
+ % id_ruby
11
+ % : date
12
+ % 2017-10-16
13
+ : theme
14
+ .
15
+
16
+ = Self-testing code
17
+
18
+ (('tag:center'))What is Self-testing code?
19
+
20
+ == properties
21
+ : hide-title
22
+ true
23
+
24
+ = Self-testing code
25
+
26
+ * Code that have built-in tests
27
+ * The tests serve as a binding contract
28
+ * The tests can be run arbitrarily
29
+
30
+ = TDD
31
+
32
+ (('tag:center'))What is TDD? How it differs from self-testing code?
33
+
34
+ == properties
35
+ : hide-title
36
+ true
37
+
38
+ = TDD
39
+
40
+ * Practices of writing ((*tests*)) before the code
41
+ * Ensure that the code is self-tested
42
+ * It is, however, ((*optional*)) to do TDD to write self-testing code
43
+
44
+ = TDD
45
+
46
+ (('tag:center'))But some companies enforce TDD because TDD enforces ((*YAGNI*)) principle
47
+
48
+ = TDD
49
+
50
+ (('tag:center'))We'll see why...
51
+
52
+ = TDD Steps
53
+
54
+ * Write a test
55
+ * Run the test, it should fail
56
+ * Write code just enough to pass the test
57
+ * Run the test
58
+ * Repeat
59
+
60
+ = TDD & YAGNI
61
+
62
+ (('tag:center'))Because we only write just enough code to pass the test, there will be no unnecessary codes
63
+
64
+ = Test in Ruby
65
+
66
+ (('tag:center'))There are several tools for doing testing in ruby
67
+
68
+ = Test in Ruby
69
+
70
+ * RSpec
71
+ * Minitest
72
+ * test-unit
73
+
74
+ = Test in Ruby
75
+
76
+ (('tag:center'))Let's try using RSpec
77
+
78
+ = RSpec Install
79
+
80
+ # rouge console
81
+
82
+ % gem install rspec
83
+
84
+ = RSpec Help
85
+
86
+ # rouge console
87
+
88
+ % rspec --help
89
+
90
+ = TDD with RSpec
91
+
92
+ (('tag:center'))Now let's do TDD practice using RSpec
93
+
94
+ == properties
95
+ : hide-title
96
+ true
97
+
98
+ = TDD with RSpec (1)
99
+
100
+ Create a simple test of program that we want to create
101
+
102
+ # rouge ruby
103
+
104
+ # game_spec.rb
105
+
106
+ RSpec.describe Game do
107
+ describe "#score" do
108
+ it "returns 0 for new game" do
109
+ game = Game.new
110
+ expect(game.score).to eq(0)
111
+ end
112
+ end
113
+ end
114
+
115
+ = TDD with RSpec (2)
116
+
117
+ Run the example and watch it fail
118
+
119
+ # rouge console
120
+
121
+ % rspec game_spec.rb
122
+ uninitialized constant Object::Game (NameError)
123
+
124
+ = TDD with RSpec (3)
125
+
126
+ Now write just enough code to make it pass
127
+
128
+ # rouge ruby
129
+
130
+ # game.rb
131
+
132
+ class Game
133
+ attr_reader :score
134
+
135
+ def initialize
136
+ @score = 0
137
+ end
138
+ end
139
+
140
+ = TDD with RSpec (3)
141
+
142
+ Now write just enough code to make it pass
143
+
144
+ # rouge ruby
145
+
146
+ # game_spec.rb
147
+
148
+ require './game'
149
+ ...
150
+
151
+ = TDD with RSpec (4)
152
+
153
+ Run the example and the test shall pass
154
+
155
+ # rouge console
156
+
157
+ % rspec game_spec.rb --color --format doc
158
+
159
+ Game
160
+ #score
161
+ returns 0 for all gutter game
162
+
163
+ Finished in 0.00057 seconds
164
+ 1 example, 0 failures
165
+
166
+ = TDD with RSpec (5)
167
+
168
+ (('tag:center'))Repeat with new features
169
+
170
+ = Thanks
171
+
172
+ (('tag:center'))Thanks
173
+
174
+ == properties
175
+ : hide-title
176
+ true
@@ -0,0 +1,24 @@
1
+ @margin_left = screen_x(1)
2
+ @margin_right = screen_x(1)
3
+
4
+ # @title_slide_title_font_size = @large_font_size
5
+ # @title_slide_subtitle_font_size = @small_font_size
6
+
7
+ match(Slide, HeadLine) do |headlines|
8
+ headlines.horizontal_centering = true
9
+
10
+ # This code below already available as default theme
11
+ # I put it here to show on how to style specific slide
12
+ # headlines.each do |headline|
13
+ # slide = headline.slide
14
+ # headline.hide if slide["hide-title"] == true
15
+ # end
16
+ end
17
+
18
+ match(Slide, Body) do |bodies|
19
+ bodies.vertical_centering = true
20
+ end
21
+
22
+ include_theme("default")
23
+ # include_theme("rabbit-theme-nyankosakana")
24
+ # include_theme("rabbit-theme-yart")
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rabbit-slide-giosakti-201710-self-testing-code-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 2017.10.16.2
5
+ platform: ruby
6
+ authors:
7
+ - Giovanni Sakti
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-10-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rabbit
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 2.0.2
27
+ description: This talk explains the concept of self-testing code with practices in
28
+ ruby using rspec.
29
+ email:
30
+ - giosakti@gmail.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".rabbit"
36
+ - README.md
37
+ - Rakefile
38
+ - config.yaml
39
+ - pdf/201710-self-testing-code-ruby-201710-self-testing-code-ruby.pdf
40
+ - self-testing-code-ruby.rab
41
+ - theme.rb
42
+ homepage: http://slide.rabbit-shocker.org/authors/giosakti/201710-self-testing-code-ruby/
43
+ licenses:
44
+ - MIT
45
+ metadata: {}
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubyforge_project:
62
+ rubygems_version: 2.6.13
63
+ signing_key:
64
+ specification_version: 4
65
+ summary: Self-testing Code in Ruby
66
+ test_files: []