File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ def interpolation_part_of(actual)
4242 interpolation . first
4343 end
4444end
45+
4546describe "Your code" do
4647 [ [ 'solution::code' ] ]
4748
Original file line number Diff line number Diff line change 11require 'rspec'
2+ require 'rspec/expectations'
3+
4+ RSpec ::Matchers . define :use_multiplication_of_strings do
5+ match { |actual | actual =~ /['"]o['"]\s ?\* \s ?\d +/ }
6+
7+ failure_message do |actual |
8+ %Q{Your code doesn't use the * method to add the "o"s}
9+ end
10+ end
11+
12+ RSpec ::Matchers . define :concat_the_ordinal_number do |expected |
13+ match { |actual | actual =~ /(<<[\( \s ]?#{ expected } \) ?|\. concat[\( \s ]#{ expected } \( ?)/ }
14+
15+ failure_message do |actual |
16+ %Q{Your code doesn't add "#{ expected . chr } " by using the ordinal number}
17+ end
18+ end
19+
20+ def code_line
21+ %q{[['solution::code']]}
22+ end
23+
24+ def code
25+ @code ||= eval ( code_line )
26+ end
227
328describe 'Your code' do
29+ it 'creates a String' do
30+ expect ( code ) . to be_a String
31+ end
32+
33+ it 'adds whitespace by using the ordinal number' do
34+ expect ( code_line ) . to concat_the_ordinal_number 32
35+ end
36+
37+ it 'uses the * method to create the "ooooo"' do
38+ expect ( code_line ) . to use_multiplication_of_strings
39+ end
40+
41+ it 'adds an exclamation mark by using the ordinal number' do
42+ expect ( code_line ) . to concat_the_ordinal_number 33
43+ end
44+
445
46+ if code . is_a? ( String )
47+ it 'forms the String "Ruby rooooocks!"' do
48+ expect ( code . strip ) . to eq 'Ruby rooooocks!'
49+ end
50+ end
551end
You can’t perform that action at this time.
0 commit comments