seeing_is_believing 2.1.3 → 2.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,10 +20,12 @@ Gem::Specification.new do |s|
20
20
  s.require_paths = ["lib"]
21
21
 
22
22
  s.add_dependency "parser", "~> 2.1.4"
23
+ s.add_dependency "psych", "~> 2.0"
23
24
 
24
- s.add_development_dependency "haiti", "~> 0.0.3"
25
+ s.add_development_dependency "pry", "~> 0.10.0"
26
+ s.add_development_dependency "haiti", "~> 0.1.0"
25
27
  s.add_development_dependency "rake", "~> 10.0.3"
26
- s.add_development_dependency "rspec", "~> 2.12.0"
28
+ s.add_development_dependency "rspec", "~> 3.0.0"
27
29
  s.add_development_dependency "cucumber", "~> 1.2.1"
28
30
  s.add_development_dependency "ichannel", "~> 5.1.1"
29
31
 
@@ -1,3 +1,4 @@
1
+ require 'spec_helper'
1
2
  require 'seeing_is_believing/binary/clean_body'
2
3
 
3
4
  describe SeeingIsBelieving::Binary::CleanBody do
@@ -8,58 +9,58 @@ describe SeeingIsBelieving::Binary::CleanBody do
8
9
  end
9
10
 
10
11
  context 'when told to clean out value annotations' do
11
- example { call("1#=>1", true).should == "1" }
12
- example { call("1 #=>1", true).should == "1" }
13
- example { call("1 #=>1", true).should == "1" }
14
- example { call("1 #=> 1", true).should == "1" }
15
- example { call("1 #=> 1", true).should == "1" }
16
- example { call("1 #=> 1", true).should == "1" }
17
- example { call("\n1 # => 1", true).should == "\n1" }
12
+ example { expect(call "1#=>1", true).to eq "1" }
13
+ example { expect(call "1 #=>1", true).to eq "1" }
14
+ example { expect(call "1 #=>1", true).to eq "1" }
15
+ example { expect(call "1 #=> 1", true).to eq "1" }
16
+ example { expect(call "1 #=> 1", true).to eq "1" }
17
+ example { expect(call "1 #=> 1", true).to eq "1" }
18
+ example { expect(call "\n1 # => 1", true).to eq "\n1" }
18
19
  end
19
20
 
20
21
  context 'when told not to clean out value annotations' do
21
- example { call("1#=>1", false).should == "1#=>1" }
22
- example { call("1 #=>1", false).should == "1 #=>1" }
23
- example { call("1 #=>1", false).should == "1 #=>1" }
24
- example { call("1 #=> 1", false).should == "1 #=> 1" }
25
- example { call("1 #=> 1", false).should == "1 #=> 1" }
26
- example { call("1 #=> 1", false).should == "1 #=> 1" }
27
- example { call("\n1 # => 1", false).should == "\n1 # => 1" }
22
+ example { expect(call "1#=>1", false).to eq "1#=>1" }
23
+ example { expect(call "1 #=>1", false).to eq "1 #=>1" }
24
+ example { expect(call "1 #=>1", false).to eq "1 #=>1" }
25
+ example { expect(call "1 #=> 1", false).to eq "1 #=> 1" }
26
+ example { expect(call "1 #=> 1", false).to eq "1 #=> 1" }
27
+ example { expect(call "1 #=> 1", false).to eq "1 #=> 1" }
28
+ example { expect(call "\n1 # => 1", false).to eq "\n1 # => 1" }
28
29
  end
29
30
 
30
31
  context 'cleaning inline exception annotations' do
31
- example { call("1#~>1").should == "1" }
32
- example { call("1 #~>1").should == "1" }
33
- example { call("1 #~>1").should == "1" }
34
- example { call("1 #~> 1").should == "1" }
35
- example { call("1 #~> 1").should == "1" }
36
- example { call("1 #~> 1").should == "1" }
37
- example { call("\n1 # ~> 1").should == "\n1" }
38
-
39
- example { call("# >> 1").should == "" }
40
- example { call("# !> 1").should == "" }
32
+ example { expect(call "1#~>1" ).to eq "1" }
33
+ example { expect(call "1 #~>1" ).to eq "1" }
34
+ example { expect(call "1 #~>1" ).to eq "1" }
35
+ example { expect(call "1 #~> 1" ).to eq "1" }
36
+ example { expect(call "1 #~> 1" ).to eq "1" }
37
+ example { expect(call "1 #~> 1" ).to eq "1" }
38
+ example { expect(call "\n1 # ~> 1").to eq "\n1" }
39
+
40
+ example { expect(call "# >> 1").to eq "" }
41
+ example { expect(call "# !> 1").to eq "" }
41
42
  end
42
43
 
43
44
  context 'cleaning stdout annotations' do
44
- example { call(<<-CODE).should == "1" }
45
+ example { expect(call(<<-CODE)).to eq "1" }
45
46
  1
46
47
  # >> 2
47
48
  CODE
48
49
 
49
- example { call(<<-CODE).should == "1" }
50
+ example { expect(call(<<-CODE)).to eq "1" }
50
51
  1
51
52
 
52
53
  # >> 2
53
54
  CODE
54
55
 
55
- example { call(<<-CODE).should == "1\n" }
56
+ example { expect(call(<<-CODE)).to eq "1\n" }
56
57
  1
57
58
 
58
59
 
59
60
  # >> 2
60
61
  CODE
61
62
 
62
- example { call(<<-CODE).should == "1\n" }
63
+ example { expect(call(<<-CODE)).to eq "1\n" }
63
64
  1
64
65
 
65
66
 
@@ -69,7 +70,7 @@ describe SeeingIsBelieving::Binary::CleanBody do
69
70
  CODE
70
71
 
71
72
 
72
- example { call(<<-CODE).should == "1\n" }
73
+ example { expect(call(<<-CODE)).to eq "1\n" }
73
74
  1
74
75
 
75
76
 
@@ -79,25 +80,25 @@ describe SeeingIsBelieving::Binary::CleanBody do
79
80
  end
80
81
 
81
82
  context 'cleaning stderr annotations' do
82
- example { call(<<-CODE).should == "1" }
83
+ example { expect(call(<<-CODE)).to eq "1" }
83
84
  1
84
85
  # !> 2
85
86
  CODE
86
87
 
87
- example { call(<<-CODE).should == "1" }
88
+ example { expect(call(<<-CODE)).to eq "1" }
88
89
  1
89
90
 
90
91
  # !> 2
91
92
  CODE
92
93
 
93
- example { call(<<-CODE).should == "1" }
94
+ example { expect(call(<<-CODE)).to eq "1" }
94
95
  1
95
96
 
96
97
  # !> 2
97
98
  # !> 3
98
99
  CODE
99
100
 
100
- example { call(<<-CODE).should == "1\n" }
101
+ example { expect(call(<<-CODE)).to eq "1\n" }
101
102
  1
102
103
 
103
104
 
@@ -109,25 +110,25 @@ describe SeeingIsBelieving::Binary::CleanBody do
109
110
 
110
111
 
111
112
  context 'cleaning end of file exception annotations' do
112
- example { call(<<-CODE).should == "1" }
113
+ example { expect(call(<<-CODE)).to eq "1" }
113
114
  1
114
115
  # ~>2
115
116
  CODE
116
117
 
117
- example { call(<<-CODE).should == "1" }
118
+ example { expect(call(<<-CODE)).to eq "1" }
118
119
  1
119
120
 
120
121
  # ~> 2
121
122
  CODE
122
123
 
123
- example { call(<<-CODE).should == "1" }
124
+ example { expect(call(<<-CODE)).to eq "1" }
124
125
  1
125
126
 
126
127
  # ~> 2
127
128
  # ~> 3
128
129
  CODE
129
130
 
130
- example { call(<<-CODE).should == "1\n" }
131
+ example { expect(call(<<-CODE)).to eq "1\n" }
131
132
  1
132
133
 
133
134
 
@@ -136,7 +137,7 @@ describe SeeingIsBelieving::Binary::CleanBody do
136
137
  # ~> 2
137
138
  CODE
138
139
 
139
- example { call(<<-CODE).should == "1\n" }
140
+ example { expect(call(<<-CODE)).to eq "1\n" }
140
141
  1 # ~> error
141
142
 
142
143
 
@@ -145,7 +146,7 @@ describe SeeingIsBelieving::Binary::CleanBody do
145
146
  end
146
147
 
147
148
  context 'putting it all together' do
148
- example { call(<<-CODE).should == "1" }
149
+ example { expect(call(<<-CODE)).to eq "1" }
149
150
  1
150
151
 
151
152
  # >> 1
@@ -158,7 +159,7 @@ describe SeeingIsBelieving::Binary::CleanBody do
158
159
  # ~> 6
159
160
  CODE
160
161
 
161
- example { call(<<-CODE).should == "1" }
162
+ example { expect(call(<<-CODE)).to eq "1" }
162
163
  1
163
164
 
164
165
  # >> 1
@@ -174,7 +175,7 @@ describe SeeingIsBelieving::Binary::CleanBody do
174
175
  # ~> 6
175
176
  CODE
176
177
 
177
- example { call(<<-CODE).should == "1" }
178
+ example { expect(call(<<-CODE)).to eq "1" }
178
179
  1
179
180
 
180
181
  # >> 1
@@ -185,7 +186,7 @@ describe SeeingIsBelieving::Binary::CleanBody do
185
186
  # ~> 6
186
187
  CODE
187
188
 
188
- example { call(<<-CODE).should == "1\n3" }
189
+ example { expect(call(<<-CODE)).to eq "1\n3" }
189
190
  1
190
191
  # >> 1
191
192
  # >> 2
@@ -194,7 +195,7 @@ describe SeeingIsBelieving::Binary::CleanBody do
194
195
  # !> 5
195
196
  CODE
196
197
 
197
- example { call(<<-CODE).should == "1\n3\n6" }
198
+ example { expect(call(<<-CODE)).to eq "1\n3\n6" }
198
199
  1
199
200
  # >> 1
200
201
  # >> 2
@@ -206,7 +207,7 @@ describe SeeingIsBelieving::Binary::CleanBody do
206
207
  # ~> 8
207
208
  CODE
208
209
 
209
- example { call(<<-CODE).should == "1\n\nputs \"omg\"" }
210
+ example { expect(call(<<-CODE)).to eq "1\n\nputs \"omg\"" }
210
211
  1 # => 1
211
212
 
212
213
  puts "omg" # ~> RuntimeError: omg
@@ -1,3 +1,4 @@
1
+ require 'spec_helper'
1
2
  require 'seeing_is_believing/binary/comment_formatter'
2
3
 
3
4
  describe SeeingIsBelieving::Binary::CommentFormatter do
@@ -6,49 +7,49 @@ describe SeeingIsBelieving::Binary::CommentFormatter do
6
7
  end
7
8
 
8
9
  specify 'it returns the consolidated result if there are no truncations' do
9
- result_for(1, '=>', '12345').should == '=>12345'
10
+ expect(result_for 1, '=>', '12345').to eq '=>12345'
10
11
  end
11
12
 
12
13
  specify 'result_length truncates a result to the specified length, using elipses up to that length if appropriate' do
13
14
  line_length = 1
14
15
  separator = '=>'
15
16
  result = '12345'
16
- result_for(line_length, separator, result, max_result_length: Float::INFINITY).should == '=>12345'
17
- result_for(line_length, separator, result, max_result_length: 7).should == '=>12345'
18
- result_for(line_length, separator, result, max_result_length: 6).should == '=>1...'
19
- result_for(line_length, separator, result, max_result_length: 5).should == '=>...'
20
- result_for(line_length, separator, result, max_result_length: 4).should == ''
21
- result_for(line_length, separator, result, max_result_length: 0).should == ''
17
+ expect(result_for line_length, separator, result, max_result_length: Float::INFINITY).to eq '=>12345'
18
+ expect(result_for line_length, separator, result, max_result_length: 7 ).to eq '=>12345'
19
+ expect(result_for line_length, separator, result, max_result_length: 6 ).to eq '=>1...'
20
+ expect(result_for line_length, separator, result, max_result_length: 5 ).to eq '=>...'
21
+ expect(result_for line_length, separator, result, max_result_length: 4 ).to eq ''
22
+ expect(result_for line_length, separator, result, max_result_length: 0 ).to eq ''
22
23
  end
23
24
 
24
25
  specify 'line_length truncates a result to the specified length, minus the length of the line' do
25
26
  line_length = 1
26
27
  separator = '=>'
27
28
  result = '12345'
28
- result_for(line_length, separator, result).should == '=>12345'
29
- result_for(line_length, separator, result, max_line_length: Float::INFINITY).should == '=>12345'
30
- result_for(line_length, separator, result, max_line_length: 8).should == '=>12345'
31
- result_for(line_length, separator, result, max_line_length: 7).should == '=>1...'
32
- result_for(line_length, separator, result, max_line_length: 6).should == '=>...'
33
- result_for(line_length, separator, result, max_line_length: 5).should == ''
34
- result_for(line_length, separator, result, max_line_length: 0).should == ''
29
+ expect(result_for line_length, separator, result ).to eq '=>12345'
30
+ expect(result_for line_length, separator, result, max_line_length: Float::INFINITY).to eq '=>12345'
31
+ expect(result_for line_length, separator, result, max_line_length: 8 ).to eq '=>12345'
32
+ expect(result_for line_length, separator, result, max_line_length: 7 ).to eq '=>1...'
33
+ expect(result_for line_length, separator, result, max_line_length: 6 ).to eq '=>...'
34
+ expect(result_for line_length, separator, result, max_line_length: 5 ).to eq ''
35
+ expect(result_for line_length, separator, result, max_line_length: 0 ).to eq ''
35
36
  end
36
37
 
37
38
  specify 'pad_to will pad the length that the line is displayed in' do
38
- result_for(1, '=>', '2', pad_to: 0).should == '=>2'
39
- result_for(1, '=>', '2', pad_to: 1).should == '=>2'
40
- result_for(1, '=>', '2', pad_to: 2).should == ' =>2'
39
+ expect(result_for 1, '=>', '2', pad_to: 0).to eq '=>2'
40
+ expect(result_for 1, '=>', '2', pad_to: 1).to eq '=>2'
41
+ expect(result_for 1, '=>', '2', pad_to: 2).to eq ' =>2'
41
42
  end
42
43
 
43
44
  specify 'pad_to is ignored when separator/result will not be printed' do
44
- result_for(1, '=>', '12345', pad_to: 2, max_line_length: 2).should == ''
45
- result_for(1, '=>', '12345', pad_to: 2, max_result_length: 2).should == ''
45
+ expect(result_for 1, '=>', '12345', pad_to: 2, max_line_length: 2).to eq ''
46
+ expect(result_for 1, '=>', '12345', pad_to: 2, max_result_length: 2).to eq ''
46
47
  end
47
48
 
48
49
  specify 'they can all work together' do
49
- result_for(1, '=>', '12345', max_line_length: 100, max_result_length: 100, pad_to: 2).should == ' =>12345'
50
- result_for(1, '=>', '12345', max_line_length: 8, max_result_length: 100, pad_to: 2).should == ' =>1...'
51
- result_for(1, '=>', '12345', max_line_length: 100, max_result_length: 6, pad_to: 2).should == ' =>1...'
52
- result_for(1, '=>', '12345', max_line_length: 100, max_result_length: 6, pad_to: 2).should == ' =>1...'
50
+ expect(result_for 1, '=>', '12345', max_line_length: 100, max_result_length: 100, pad_to: 2).to eq ' =>12345'
51
+ expect(result_for 1, '=>', '12345', max_line_length: 8, max_result_length: 100, pad_to: 2).to eq ' =>1...'
52
+ expect(result_for 1, '=>', '12345', max_line_length: 100, max_result_length: 6, pad_to: 2).to eq ' =>1...'
53
+ expect(result_for 1, '=>', '12345', max_line_length: 100, max_result_length: 6, pad_to: 2).to eq ' =>1...'
53
54
  end
54
55
  end
@@ -1,3 +1,4 @@
1
+ require 'spec_helper'
1
2
  require 'seeing_is_believing/binary/comment_lines'
2
3
 
3
4
  describe SeeingIsBelieving::Binary::CommentLines, 'passes in the each commentable line and the line number, and adds the returned text (whitespace+comment) to the end' do
@@ -6,17 +7,17 @@ describe SeeingIsBelieving::Binary::CommentLines, 'passes in the each commentabl
6
7
  end
7
8
 
8
9
  example 'just checking some edge cases' do
9
- call("") { ';' }.should == ";"
10
- call("__END__\n1") { ';' }.should == "__END__\n1"
11
- call("1\n__END__") { ';' }.should == "1;\n__END__"
10
+ expect(call("") { ';' }).to eq ";"
11
+ expect(call("__END__\n1") { ';' }).to eq "__END__\n1"
12
+ expect(call("1\n__END__") { ';' }).to eq "1;\n__END__"
12
13
  end
13
14
 
14
15
  it "doesn't comment lines whose newline is escaped" do
15
- call("1 +\\\n2") { |_, line_number| "--#{line_number}--" }.should == "1 +\\\n2--2--"
16
+ expect(call("1 +\\\n2") { |_, line_number| "--#{line_number}--" }).to eq "1 +\\\n2--2--"
16
17
  end
17
18
 
18
19
  it "doesn't comment lines inside of strings" do
19
- call(<<-INPUT) { |_, line_number| "--#{line_number}--" }.should == <<-OUTPUT
20
+ expect(call(<<-INPUT) { |_, line_number| "--#{line_number}--" }).to eq <<-OUTPUT
20
21
  "a\#{1+1
21
22
  }"
22
23
  "a
@@ -46,7 +47,7 @@ describe SeeingIsBelieving::Binary::CommentLines, 'passes in the each commentabl
46
47
  end
47
48
 
48
49
  it 'does comment the first line of a heredoc' do
49
- call(<<-INPUT.gsub(/^ */, '')) { |_, line_number| "--#{line_number}--" }.should == <<-OUTPUT.gsub(/^ */, '')
50
+ expect(call(<<-INPUT.gsub(/^ */, '')) { |_, line_number| "--#{line_number}--" }).to eq <<-OUTPUT.gsub(/^ */, '')
50
51
  <<A
51
52
  1
52
53
  A
@@ -92,7 +93,7 @@ describe SeeingIsBelieving::Binary::CommentLines, 'passes in the each commentabl
92
93
  end
93
94
 
94
95
  it "doesn't comment lines inside of regexes" do
95
- call(<<-INPUT) { |_, line_number| "--#{line_number}--" }.should == <<-OUTPUT
96
+ expect(call(<<-INPUT) { |_, line_number| "--#{line_number}--" }).to eq <<-OUTPUT
96
97
  /a\#{1+1
97
98
  }/
98
99
  /a
@@ -110,7 +111,7 @@ describe SeeingIsBelieving::Binary::CommentLines, 'passes in the each commentabl
110
111
  end
111
112
 
112
113
  it "doesn't comment lines inside of backticks/%x" do
113
- call(<<-INPUT) { |_, line_number| "--#{line_number}--" }.should == <<-OUTPUT
114
+ expect(call(<<-INPUT) { |_, line_number| "--#{line_number}--" }).to eq <<-OUTPUT
114
115
  `a\#{1+1
115
116
  }`
116
117
  %x[\#{1+1
@@ -136,7 +137,7 @@ describe SeeingIsBelieving::Binary::CommentLines, 'passes in the each commentabl
136
137
  end
137
138
 
138
139
  it "doesn't comment lines inside of string arrays" do
139
- call(<<-INPUT) { |_, line_number| "--#{line_number}--" }.should == <<-OUTPUT
140
+ expect(call(<<-INPUT) { |_, line_number| "--#{line_number}--" }).to eq <<-OUTPUT
140
141
  %w[
141
142
  a
142
143
  ]
@@ -158,26 +159,26 @@ describe SeeingIsBelieving::Binary::CommentLines, 'passes in the each commentabl
158
159
  "'4\n"\
159
160
  "5'+\n"\
160
161
  "%Q'\n"\
161
- " \#{5+6} 7'\n") do |line, line_number|
162
- lines << line
163
- "--#{line_number}--"
164
- end
165
-
166
- lines.should == [ "1 +",
167
- " 2",
168
- "",
169
- "5'+",
170
- " \#{5+6} 7'"]
171
-
172
- result.should == "1 +--1--\n"\
173
- " 2--2--\n"\
174
- "--3--\n"\
175
- "# just a comment\n"\
176
- "3 # already has a comment\n"\
177
- "'4\n"\
178
- "5'+--7--\n"\
179
- "%Q'\n"\
180
- " \#{5+6} 7'--9--\n"
162
+ " \#{5+6} 7'\n") { |line, line_number|
163
+ lines << line
164
+ "--#{line_number}--"
165
+ }
166
+
167
+ expect(lines).to eq ["1 +",
168
+ " 2",
169
+ "",
170
+ "5'+",
171
+ " \#{5+6} 7'"]
172
+
173
+ expect(result).to eq "1 +--1--\n"\
174
+ " 2--2--\n"\
175
+ "--3--\n"\
176
+ "# just a comment\n"\
177
+ "3 # already has a comment\n"\
178
+ "'4\n"\
179
+ "5'+--7--\n"\
180
+ "%Q'\n"\
181
+ " \#{5+6} 7'--9--\n"
181
182
  end
182
183
 
183
184
 
@@ -838,6 +839,6 @@ __END__
838
839
  1
839
840
  OUTPUT
840
841
 
841
- call(input) { ';' }.should == output
842
+ expect(call(input) { ';' }).to eq output
842
843
  end
843
844
  end
@@ -1,3 +1,4 @@
1
+ require 'spec_helper'
1
2
  require 'seeing_is_believing/binary/parse_args'
2
3
 
3
4
  describe SeeingIsBelieving::Binary::ParseArgs do
@@ -13,29 +14,29 @@ describe SeeingIsBelieving::Binary::ParseArgs do
13
14
  end
14
15
  end
15
16
 
16
- failure_message_for_should do |options|
17
+ failure_message do |options|
17
18
  "#{error_assertion.inspect} should have matched one of the errors: #{options[:errors].inspect}"
18
19
  end
19
20
 
20
- failure_message_for_should_not do |options|
21
+ failure_message_when_negated do |options|
21
22
  "#{error_assertion.inspect} should NOT have matched any of the errors: #{options[:errors].inspect}"
22
23
  end
23
24
  end
24
25
 
25
26
  def parse(args, outstream=nil)
26
- described_class.call args, outstream
27
+ SeeingIsBelieving::Binary::ParseArgs.call args, outstream
27
28
  end
28
29
 
29
30
  shared_examples 'it requires a positive int argument' do |flags|
30
31
  it 'expects an integer argument' do
31
32
  flags.each do |flag|
32
- parse([flag, '1']).should_not have_error /#{flag}/
33
- parse([flag, '0']).should have_error /#{flag}/
34
- parse([flag, '-1']).should have_error /#{flag}/
35
- parse([flag, '1.0']).should have_error /#{flag}/
36
- parse([flag, 'a']).should have_error /#{flag}/
37
- parse([flag, '' ]).should have_error /#{flag}/
38
- parse([flag ]).should have_error /#{flag}/
33
+ expect(parse([flag, '1'])).to_not have_error /#{flag}/
34
+ expect(parse([flag, '0'])).to have_error /#{flag}/
35
+ expect(parse([flag, '-1'])).to have_error /#{flag}/
36
+ expect(parse([flag, '1.0'])).to have_error /#{flag}/
37
+ expect(parse([flag, 'a'])).to have_error /#{flag}/
38
+ expect(parse([flag, '' ])).to have_error /#{flag}/
39
+ expect(parse([flag ])).to have_error /#{flag}/
39
40
  end
40
41
  end
41
42
  end
@@ -43,60 +44,60 @@ describe SeeingIsBelieving::Binary::ParseArgs do
43
44
  shared_examples 'it requires a non-negative float or int' do |flags|
44
45
  it 'expects a non-negative float or int argument' do
45
46
  flags.each do |flag|
46
- parse([flag, '1']).should_not have_error /#{flag}/
47
- parse([flag, '0']).should_not have_error /#{flag}/
48
- parse([flag, '-1']).should have_error /#{flag}/
49
- parse([flag,'-1.0']).should have_error /#{flag}/
50
- parse([flag, '1.0']).should_not have_error /#{flag}/
51
- parse([flag, 'a']).should have_error /#{flag}/
52
- parse([flag, '' ]).should have_error /#{flag}/
53
- parse([flag ]).should have_error /#{flag}/
47
+ expect(parse([flag, '1'])).to_not have_error /#{flag}/
48
+ expect(parse([flag, '0'])).to_not have_error /#{flag}/
49
+ expect(parse([flag, '-1'])).to have_error /#{flag}/
50
+ expect(parse([flag,'-1.0'])).to have_error /#{flag}/
51
+ expect(parse([flag, '1.0'])).to_not have_error /#{flag}/
52
+ expect(parse([flag, 'a'])).to have_error /#{flag}/
53
+ expect(parse([flag, '' ])).to have_error /#{flag}/
54
+ expect(parse([flag ])).to have_error /#{flag}/
54
55
  end
55
56
  end
56
57
  end
57
58
 
58
59
  specify 'unknown options set an error' do
59
- parse(['--xyz']).should have_error 'Unknown option: "--xyz"'
60
- parse(['-y']).should have_error 'Unknown option: "-y"'
61
- parse(['-y', 'b']).should have_error 'Unknown option: "-y"'
60
+ expect(parse(['--xyz'])).to have_error 'Unknown option: "--xyz"'
61
+ expect(parse(['-y'])).to have_error 'Unknown option: "-y"'
62
+ expect(parse(['-y', 'b'])).to have_error 'Unknown option: "-y"'
62
63
  end
63
64
 
64
65
  example 'example: multiple args' do
65
66
  options = parse(%w[filename -l 12 -L 20 -h -r torequire])
66
- options[:filename].should == 'filename'
67
- options[:start_line].should == 12
68
- options[:end_line].should == 20
69
- options[:require].should == ['torequire']
70
- options[:help].should be_a_kind_of String
71
- options[:errors].should be_empty
67
+ expect(options[:filename]).to eq 'filename'
68
+ expect(options[:start_line]).to eq 12
69
+ expect(options[:end_line]).to eq 20
70
+ expect(options[:require]).to eq ['torequire']
71
+ expect(options[:help]).to be_a_kind_of String
72
+ expect(options[:errors]).to be_empty
72
73
  end
73
74
 
74
75
  describe ':filename' do
75
76
  it 'defaults to nil' do
76
- parse([])[:filename].should be_nil
77
+ expect(parse([])[:filename]).to be_nil
77
78
  end
78
79
 
79
80
  it 'is the first non-flag' do
80
- parse(['a'])[:filename].should == 'a'
81
- parse(['-x', 'a'])[:filename].should == 'a'
82
- parse(['a', '-x'])[:filename].should == 'a'
81
+ expect(parse(['a'])[:filename]).to eq 'a'
82
+ expect(parse(['-x', 'a'])[:filename]).to eq 'a'
83
+ expect(parse(['a', '-x'])[:filename]).to eq 'a'
83
84
  end
84
85
 
85
86
  it 'sets an error if given multiple filenames' do
86
- parse([]).should_not have_error /name/
87
- parse(['a']).should_not have_error /Can only have one filename/
88
- parse(['a', 'b']).should have_error 'Can only have one filename, but had: "a", "b"'
87
+ expect(parse([])).to_not have_error /name/
88
+ expect(parse(['a'])).to_not have_error /Can only have one filename/
89
+ expect(parse(['a', 'b'])).to have_error 'Can only have one filename, but had: "a", "b"'
89
90
  end
90
91
  end
91
92
 
92
93
  describe ':start_line' do
93
94
  it 'defaults to 1' do
94
- parse([])[:start_line].should equal 1
95
+ expect(parse([])[:start_line]).to equal 1
95
96
  end
96
97
 
97
98
  it 'is set with -l and --start-line' do
98
- parse(['-l', '1'])[:start_line].should == 1
99
- parse(['--start-line', '12'])[:start_line].should == 12
99
+ expect(parse(['-l', '1'])[:start_line]).to eq 1
100
+ expect(parse(['--start-line', '12'])[:start_line]).to eq 12
100
101
  end
101
102
 
102
103
  it_behaves_like 'it requires a positive int argument', ['-l', '--start-line']
@@ -104,30 +105,30 @@ describe SeeingIsBelieving::Binary::ParseArgs do
104
105
 
105
106
  describe ':end_line' do
106
107
  it 'defaults to infinity' do
107
- parse([])[:end_line].should equal Float::INFINITY
108
+ expect(parse([])[:end_line]).to equal Float::INFINITY
108
109
  end
109
110
 
110
111
  it 'is set with -L and --end-line' do
111
- parse(['-L', '1'])[:end_line].should == 1
112
- parse(['--end-line', '12'])[:end_line].should == 12
112
+ expect(parse(['-L', '1'])[:end_line]).to eq 1
113
+ expect(parse(['--end-line', '12'])[:end_line]).to eq 12
113
114
  end
114
115
 
115
116
  it_behaves_like 'it requires a positive int argument', ['-L', '--end-line']
116
117
  end
117
118
 
118
119
  it 'swaps start and end line around if they are out of order' do
119
- parse(%w[-l 2 -L 1])[:start_line].should == 1
120
- parse(%w[-l 2 -L 1])[:end_line].should == 2
120
+ expect(parse(%w[-l 2 -L 1])[:start_line]).to eq 1
121
+ expect(parse(%w[-l 2 -L 1])[:end_line]).to eq 2
121
122
  end
122
123
 
123
124
  describe ':result_length' do
124
125
  it 'defaults to infinity' do
125
- parse([])[:max_result_length].should == Float::INFINITY
126
+ expect(parse([])[:max_result_length]).to eq Float::INFINITY
126
127
  end
127
128
 
128
129
  it 'is set with -D and --result-length' do
129
- parse(['-D', '10'])[:max_result_length].should == 10
130
- parse(['--result-length', '10'])[:max_result_length].should == 10
130
+ expect(parse(['-D', '10'])[:max_result_length]).to eq 10
131
+ expect(parse(['--result-length', '10'])[:max_result_length]).to eq 10
131
132
  end
132
133
 
133
134
  it_behaves_like 'it requires a positive int argument', ['-D', '--result-length']
@@ -135,12 +136,12 @@ describe SeeingIsBelieving::Binary::ParseArgs do
135
136
 
136
137
  describe ':max_line_length' do
137
138
  it 'defaults to infinity' do
138
- parse([])[:max_line_length].should == Float::INFINITY
139
+ expect(parse([])[:max_line_length]).to eq Float::INFINITY
139
140
  end
140
141
 
141
142
  it 'is set with -d and --line-length' do
142
- parse(['-d', '10'])[:max_line_length].should == 10
143
- parse(['--line-length', '10'])[:max_line_length].should == 10
143
+ expect(parse(['-d', '10'])[:max_line_length]).to eq 10
144
+ expect(parse(['--line-length', '10'])[:max_line_length]).to eq 10
144
145
  end
145
146
 
146
147
  it_behaves_like 'it requires a positive int argument', ['-d', '--line-length']
@@ -148,148 +149,148 @@ describe SeeingIsBelieving::Binary::ParseArgs do
148
149
 
149
150
  describe :require do
150
151
  it 'defaults to an empty array' do
151
- parse([])[:require].should be_empty
152
+ expect(parse([])[:require]).to be_empty
152
153
  end
153
154
 
154
155
  it '-r and --require sets each required file into the result array' do
155
- parse(%w[-r f1 --require f2])[:require].should == %w[f1 f2]
156
+ expect(parse(%w[-r f1 --require f2])[:require]).to eq %w[f1 f2]
156
157
  end
157
158
 
158
159
  it 'sets an error if not provided with a filename' do
159
- parse(['--require', 'f']).should_not have_error /-r/
160
- parse(['-r']).should have_error /-r\b/
161
- parse(['--require']).should have_error /--require\b/
160
+ expect(parse(['--require', 'f'])).to_not have_error /-r/
161
+ expect(parse(['-r'])).to have_error /-r\b/
162
+ expect(parse(['--require'])).to have_error /--require\b/
162
163
  end
163
164
  end
164
165
 
165
166
  describe ':help' do
166
167
  it 'defaults to nil' do
167
- parse([])[:help].should be_nil
168
+ expect(parse([])[:help]).to be_nil
168
169
  end
169
170
 
170
171
  it 'is set to the flag only help screen with -h and --help and -help' do
171
- parse(['-h'])[:help].should include 'Usage:'
172
- parse(['--help'])[:help].should include 'Usage:'
172
+ expect(parse(['-h'])[:help]).to include 'Usage:'
173
+ expect(parse(['--help'])[:help]).to include 'Usage:'
173
174
 
174
- parse(['-h'])[:help].should_not include 'Examples:'
175
- parse(['--help'])[:help].should_not include 'Examples:'
175
+ expect(parse(['-h'])[:help]).to_not include 'Examples:'
176
+ expect(parse(['--help'])[:help]).to_not include 'Examples:'
176
177
  end
177
178
 
178
179
  it 'is set to the flag with examples help screen with --help+ and -h+' do
179
- parse(['-h+'])[:help].should include 'Usage:'
180
- parse(['--help+'])[:help].should include 'Usage:'
180
+ expect(parse(['-h+'])[:help]).to include 'Usage:'
181
+ expect(parse(['--help+'])[:help]).to include 'Usage:'
181
182
 
182
- parse(['-h+'])[:help].should include 'Examples:'
183
- parse(['--help+'])[:help].should include 'Examples:'
183
+ expect(parse(['-h+'])[:help]).to include 'Examples:'
184
+ expect(parse(['--help+'])[:help]).to include 'Examples:'
184
185
  end
185
186
  end
186
187
 
187
188
  describe ':program' do
188
189
  it 'defaults to nil' do
189
- parse([])[:program].should be_nil
190
+ expect(parse([])[:program]).to be_nil
190
191
  end
191
192
 
192
193
  it 'is set with -e or --program, and takes the next arg' do
193
- parse(['-e', '1'])[:program].should == '1'
194
- parse(['--program', '1'])[:program].should == '1'
194
+ expect(parse(['-e', '1'])[:program]).to eq '1'
195
+ expect(parse(['--program', '1'])[:program]).to eq '1'
195
196
  end
196
197
 
197
198
  it 'sets an error if not given a program' do
198
- parse([]).should_not have_error /-e/
199
- parse([]).should_not have_error /--program/
200
- parse(['-e']).should have_error /-e/
201
- parse(['--program']).should have_error /--program/
199
+ expect(parse([])).to_not have_error /-e/
200
+ expect(parse([])).to_not have_error /--program/
201
+ expect(parse(['-e'])).to have_error /-e/
202
+ expect(parse(['--program'])).to have_error /--program/
202
203
  end
203
204
 
204
205
  it 'sets an error if a filename is also give' do
205
- parse(['-e', '1']).should_not have_error /-e/
206
- parse(['-e', '1', 'abc']).should have_error /"abc"/
206
+ expect(parse(['-e', '1'])).to_not have_error /-e/
207
+ expect(parse(['-e', '1', 'abc'])).to have_error /"abc"/
207
208
  end
208
209
  end
209
210
 
210
211
  describe':load_path' do
211
212
  it 'defaults to an empty array' do
212
- parse([])[:load_path].should be_empty
213
+ expect(parse([])[:load_path]).to be_empty
213
214
  end
214
215
 
215
216
  specify '-I and --load-path sets each required file into the result array' do
216
- parse(%w[-I f1 --load-path f2])[:load_path].should == %w[f1 f2]
217
+ expect(parse(%w[-I f1 --load-path f2])[:load_path]).to eq %w[f1 f2]
217
218
  end
218
219
 
219
220
  it 'sets an error if not provided with a dir' do
220
- parse(['--load-path', 'f']).should_not have_error /-I/
221
- parse(['-I']).should have_error /-I\b/
222
- parse(['--load-path']).should have_error /--load-path\b/
221
+ expect(parse(['--load-path', 'f'])).to_not have_error /-I/
222
+ expect(parse(['-I'])).to have_error /-I\b/
223
+ expect(parse(['--load-path'])).to have_error /--load-path\b/
223
224
  end
224
225
  end
225
226
 
226
227
  describe ':encoding' do
227
228
  it 'defaults to nil' do
228
- parse([])[:encoding].should be_nil
229
+ expect(parse([])[:encoding]).to be_nil
229
230
  end
230
231
 
231
232
  specify '-K and --encoding sets the encoding to the next argument' do
232
- parse(%w[-K u])[:encoding].should == 'u'
233
- parse(%w[--encoding u])[:encoding].should == 'u'
233
+ expect(parse(%w[-K u])[:encoding]).to eq 'u'
234
+ expect(parse(%w[--encoding u])[:encoding]).to eq 'u'
234
235
  end
235
236
 
236
237
  specify 'with -K, the argument can be placed immediately after it (e.g. -Ku) because Ruby allows this' do
237
- parse(['-Ku'])[:encoding].should == 'u'
238
- parse(['-Ku']).should_not have_error /-K/
238
+ expect(parse(['-Ku'])[:encoding]).to eq 'u'
239
+ expect(parse(['-Ku'])).to_not have_error /-K/
239
240
  end
240
241
 
241
242
  it 'sets an error if not provided with an encoding' do
242
- parse(['-Ku']).should_not have_error /-K/
243
- parse(['-K u']).should_not have_error /-K/
244
- parse(['--encoding', 'u']).should_not have_error /--encoding/
245
- parse(['-K']).should have_error /-K/
246
- parse(['--encoding']).should have_error /--encoding/
243
+ expect(parse(['-Ku'])).to_not have_error /-K/
244
+ expect(parse(['-K u'])).to_not have_error /-K/
245
+ expect(parse(['--encoding', 'u'])).to_not have_error /--encoding/
246
+ expect(parse(['-K'])).to have_error /-K/
247
+ expect(parse(['--encoding'])).to have_error /--encoding/
247
248
  end
248
249
  end
249
250
 
250
251
  describe ':as' do
251
252
  it 'defaults to nil' do
252
- parse([])[:as].should be_nil
253
+ expect(parse([])[:as]).to be_nil
253
254
  end
254
255
 
255
256
  it 'can be set with -a and --as' do
256
- parse(%w[-a abc])[:as].should == 'abc'
257
- parse(%w[--as abc])[:as].should == 'abc'
257
+ expect(parse(%w[-a abc])[:as]).to eq 'abc'
258
+ expect(parse(%w[--as abc])[:as]).to eq 'abc'
258
259
  end
259
260
 
260
261
  it 'sets an error if not provided with a filename' do
261
- parse(%w[-a f]).should_not have_error /-a/
262
- parse(%w[-as f]).should_not have_error /--as/
263
- parse(%w[-a ]).should have_error /-a/
264
- parse(%w[--as ]).should have_error /--as/
262
+ expect(parse(%w[-a f])).to_not have_error /-a/
263
+ expect(parse(%w[-as f])).to_not have_error /--as/
264
+ expect(parse(%w[-a ])).to have_error /-a/
265
+ expect(parse(%w[--as ])).to have_error /--as/
265
266
  end
266
267
  end
267
268
 
268
269
  describe ':clean' do
269
270
  it 'defaults to false' do
270
- parse([])[:clean].should == false
271
+ expect(parse([])[:clean]).to eq false
271
272
  end
272
273
 
273
274
  it 'can be set with -c and --clean' do
274
- parse(%w[-c])[:clean].should == true
275
- parse(%w[--clean])[:clean].should == true
275
+ expect(parse(%w[-c])[:clean]).to eq true
276
+ expect(parse(%w[--clean])[:clean]).to eq true
276
277
  end
277
278
  end
278
279
 
279
280
  describe ':version' do
280
281
  it 'defaults to false' do
281
- parse([])[:version].should == false
282
+ expect(parse([])[:version]).to eq false
282
283
  end
283
284
 
284
285
  it 'can be set with -v and --version' do
285
- parse(%w[-v])[:version].should == true
286
- parse(%w[--version])[:version].should == true
286
+ expect(parse(%w[-v])[:version]).to eq true
287
+ expect(parse(%w[--version])[:version]).to eq true
287
288
  end
288
289
  end
289
290
 
290
291
  describe ':timeout' do
291
292
  it 'defaults to 0' do
292
- parse([])[:timeout].should == 0
293
+ expect(parse([])[:timeout]).to eq 0
293
294
  end
294
295
 
295
296
  it_behaves_like 'it requires a non-negative float or int', ['-t', '--timeout']
@@ -302,87 +303,87 @@ describe SeeingIsBelieving::Binary::ParseArgs do
302
303
 
303
304
  # maybe change the default?
304
305
  it 'defaults to AlignChunk' do
305
- parse([])[:alignment_strategy].should == AlignChunk
306
+ expect(parse([])[:alignment_strategy]).to eq AlignChunk
306
307
  end
307
308
 
308
309
  specify '-s and --alignment-strategy sets the alignment strategy' do
309
- parse(['-s', 'chunk'])[:alignment_strategy].should == AlignChunk
310
- parse(['--alignment-strategy', 'chunk'])[:alignment_strategy].should == AlignChunk
310
+ expect(parse(['-s', 'chunk'])[:alignment_strategy]).to eq AlignChunk
311
+ expect(parse(['--alignment-strategy', 'chunk'])[:alignment_strategy]).to eq AlignChunk
311
312
  end
312
313
 
313
314
  it 'accepts values: file, line, chunk' do
314
- parse(['-s', 'file'])[:alignment_strategy].should == AlignFile
315
- parse(['-s', 'line'])[:alignment_strategy].should == AlignLine
316
- parse(['-s', 'chunk'])[:alignment_strategy].should == AlignChunk
315
+ expect(parse(['-s', 'file'])[:alignment_strategy]).to eq AlignFile
316
+ expect(parse(['-s', 'line'])[:alignment_strategy]).to eq AlignLine
317
+ expect(parse(['-s', 'chunk'])[:alignment_strategy]).to eq AlignChunk
317
318
  end
318
319
 
319
320
  it 'sets an error if not provided with a strategy, or if provided with an unknown strategy' do
320
- parse(['-s', 'file']).should_not have_error /alignment-strategy/
321
- parse(['-s', 'abc']).should have_error /alignment-strategy/
322
- parse(['-s' ]).should have_error /alignment-strategy/
321
+ expect(parse(['-s', 'file'])).to_not have_error /alignment-strategy/
322
+ expect(parse(['-s', 'abc'])).to have_error /alignment-strategy/
323
+ expect(parse(['-s' ])).to have_error /alignment-strategy/
323
324
  end
324
325
  end
325
326
 
326
327
  describe ':inherit_exit_status' do
327
328
  it 'defaults to false' do
328
- parse([])[:inherit_exit_status].should be_false
329
+ expect(parse([])[:inherit_exit_status]).to eq false
329
330
  end
330
331
 
331
332
  it 'can be set with --inherit-exit-status or -i' do
332
- parse(['--inherit-exit-status'])[:inherit_exit_status].should be_true
333
- parse(['-i'])[:inherit_exit_status].should be_true
333
+ expect(parse(['--inherit-exit-status'])[:inherit_exit_status]).to be true
334
+ expect(parse(['-i'])[:inherit_exit_status]).to be true
334
335
  end
335
336
  end
336
337
 
337
338
  describe ':xmpfilter_style' do
338
339
  it 'defaults to false' do
339
- parse([])[:xmpfilter_style].should be_false
340
+ expect(parse([])[:xmpfilter_style]).to be false
340
341
  end
341
342
 
342
343
  it 'can be set with --xmpfilter-style or -x' do
343
- parse(['--xmpfilter-style'])[:xmpfilter_style].should be_true
344
- parse(['-x'])[:xmpfilter_style].should be_true
344
+ expect(parse(['--xmpfilter-style'])[:xmpfilter_style]).to be true
345
+ expect(parse(['-x'])[:xmpfilter_style]).to be true
345
346
  end
346
347
  end
347
348
 
348
349
  describe ':debugger' do
349
350
  it 'defaults to a debugger that is disabled' do
350
- parse([], :fake_stream)[:debugger].should_not be_enabled
351
+ expect(parse([], :fake_stream)[:debugger]).to_not be_enabled
351
352
  end
352
353
 
353
354
  it 'can be enabled with --debug or -g' do
354
- parse(['--debug'], :fake_stream)[:debugger].should be_enabled
355
- parse(['-g'], :fake_stream)[:debugger].should be_enabled
355
+ expect(parse(['--debug'], :fake_stream)[:debugger]).to be_enabled
356
+ expect(parse(['-g'], :fake_stream)[:debugger]).to be_enabled
356
357
  end
357
358
 
358
359
  it 'sets the stream to the one passed in' do
359
- parse(['-g'], :fake_stream)[:debugger].stream.should == :fake_stream
360
+ expect(parse(['-g'], :fake_stream)[:debugger].stream).to eq :fake_stream
360
361
  end
361
362
  end
362
363
 
363
364
  describe ':shebang' do
364
365
  it 'defaults to "ruby"' do
365
- parse([])[:shebang].should == 'ruby'
366
+ expect(parse([])[:shebang]).to eq 'ruby'
366
367
  end
367
368
 
368
369
  it 'can be enabled with --shebang' do
369
- parse(['--shebang', 'not_ruby'])[:shebang].should == 'not_ruby'
370
+ expect(parse(['--shebang', 'not_ruby'])[:shebang]).to eq 'not_ruby'
370
371
  end
371
372
 
372
373
  it 'sets an error if not given a next arg to execute' do
373
- parse([]).should_not have_error /--shebang/
374
- parse(['--shebang']).should have_error /--shebang/
374
+ expect(parse([])).to_not have_error /--shebang/
375
+ expect(parse(['--shebang'])).to have_error /--shebang/
375
376
  end
376
377
  end
377
378
 
378
379
  describe ':number_of_captures' do
379
380
  it 'defaults to infinity' do
380
- parse([])[:number_of_captures].should == Float::INFINITY
381
+ expect(parse([])[:number_of_captures]).to eq Float::INFINITY
381
382
  end
382
383
 
383
384
  it 'can be set with --number-of-captures or -n' do
384
- parse(['-n', '10'])[:number_of_captures].should == 10
385
- parse(['--number-of-captures', '10'])[:number_of_captures].should == 10
385
+ expect(parse(['-n', '10'])[:number_of_captures]).to eq 10
386
+ expect(parse(['--number-of-captures', '10'])[:number_of_captures]).to eq 10
386
387
  end
387
388
 
388
389
  it_behaves_like 'it requires a positive int argument', ['-n', '--number-of-captures']
@@ -390,12 +391,12 @@ describe SeeingIsBelieving::Binary::ParseArgs do
390
391
 
391
392
  describe ':result_as_json' do
392
393
  it 'defaults to false' do
393
- parse([])[:result_as_json].should == false
394
+ expect(parse([])[:result_as_json]).to eq false
394
395
  end
395
396
 
396
397
  it 'can be enabled with --json or -j' do
397
- parse(['--json'])[:result_as_json].should == true
398
- parse(['-j'])[:result_as_json].should == true
398
+ expect(parse(['--json'])[:result_as_json]).to eq true
399
+ expect(parse(['-j'])[:result_as_json]).to eq true
399
400
  end
400
401
  end
401
402
  end