trick_bag 0.45.1 → 0.46.0
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.
- checksums.yaml +4 -4
- data/RELEASE_NOTES.md +18 -0
- data/lib/trick_bag/enumerables/compound_enumerable.rb +1 -1
- data/lib/trick_bag/formatters/formatters.rb +21 -0
- data/lib/trick_bag/io/temp_files.rb +1 -2
- data/lib/trick_bag/meta/classes.rb +2 -2
- data/lib/trick_bag/timing/timing.rb +1 -1
- data/lib/trick_bag/validations/gem_dependency_script.rb +18 -2
- data/lib/trick_bag/validations/other_validations.rb +21 -0
- data/lib/trick_bag/version.rb +1 -1
- data/spec/spec_helper.rb +0 -1
- data/spec/trick_bag/core_types_spec.rb +1 -1
- data/spec/trick_bag/enumerables/buffered_enumerable_spec.rb +0 -1
- data/spec/trick_bag/enumerables/file_line_reader_spec.rb +4 -4
- data/spec/trick_bag/formatters/formatters_spec.rb +28 -1
- data/spec/trick_bag/functional/functional_spec.rb +9 -13
- data/spec/trick_bag/io/temp_files_spec.rb +2 -2
- data/spec/trick_bag/meta/classes_spec.rb +13 -13
- data/spec/trick_bag/numeric/start_and_max_spec.rb +8 -8
- data/spec/trick_bag/system_spec.rb +4 -4
- data/spec/trick_bag/validations/{hashes_validations_spec.rb → hash_validations_spec.rb} +0 -0
- data/spec/trick_bag/validations/other_validations_spec.rb +11 -2
- data/trick_bag.gemspec +3 -4
- metadata +18 -32
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 57ae02e1d4096731aaa9594252922acc1ade8cea
|
|
4
|
+
data.tar.gz: c42a91603f217852a041a7dbaf5ee44a36c6ff29
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 54c102e7e407cb063106c8b387731dfb8844d69580dbc97ff6dc138fa1c40dd06f8c5faa7897fb2f408b5dea9e88437a36923b442653a96ac7bcc291f3f62785
|
|
7
|
+
data.tar.gz: 8be1ece013e697c268106a184a1e66250b3bfa323e3557930f4a222b99eba7fd91313b2f74a5bb14c9a7b589155ba6863ee621f1ed29bbf4157fb85da93369b5
|
data/RELEASE_NOTES.md
CHANGED
|
@@ -1,11 +1,28 @@
|
|
|
1
|
+
## v0.46.0
|
|
2
|
+
|
|
3
|
+
* Add array_diff and array_as_multiline_string to Formatters.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## v0.45.3
|
|
7
|
+
|
|
8
|
+
* Upgrade to RSpec 3.0. Other minor improvements.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## v0.45.2
|
|
12
|
+
|
|
13
|
+
* Fix gem dependency versions; remove refs to pry & guard; doc fixes & additions.
|
|
14
|
+
|
|
15
|
+
|
|
1
16
|
## v0.45.1
|
|
2
17
|
|
|
3
18
|
* Fix commit omissions.
|
|
4
19
|
|
|
20
|
+
|
|
5
21
|
## v0.45.0
|
|
6
22
|
|
|
7
23
|
* Add GemDependencyScript.
|
|
8
24
|
|
|
25
|
+
|
|
9
26
|
## v0.44.0
|
|
10
27
|
|
|
11
28
|
* Fix missing require 'ostruct' in erb_renderer.rb.
|
|
@@ -40,6 +57,7 @@
|
|
|
40
57
|
* Added FileLineReader.to_s.
|
|
41
58
|
git
|
|
42
59
|
|
|
60
|
+
|
|
43
61
|
## v0.38.0
|
|
44
62
|
|
|
45
63
|
* Added documentation.
|
|
@@ -4,7 +4,7 @@ require 'trick_bag/meta/classes'
|
|
|
4
4
|
module TrickBag
|
|
5
5
|
module Enumerables
|
|
6
6
|
|
|
7
|
-
# An enumerator
|
|
7
|
+
# An enumerator used to provide all combinations of a set of Enumerables.
|
|
8
8
|
|
|
9
9
|
# For example, for blood types [:a, :b, :ab, :o] and rh [:+, :-],
|
|
10
10
|
# provides an enumerator whose 'each' method gives:
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'date'
|
|
2
|
+
require 'diffy'
|
|
2
3
|
|
|
3
4
|
module TrickBag
|
|
4
5
|
module Formatters
|
|
@@ -121,6 +122,26 @@ module Formatters
|
|
|
121
122
|
string.replace(dos2unix(string, strategy))
|
|
122
123
|
end
|
|
123
124
|
|
|
125
|
+
|
|
126
|
+
# Returns a string representation of the array as would be output by puts,
|
|
127
|
+
# one line per element.
|
|
128
|
+
def array_as_multiline_string(array)
|
|
129
|
+
sio = StringIO.new
|
|
130
|
+
sio.puts(array)
|
|
131
|
+
sio.string
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
# Shows a visual diff of 2 arrays by comparing the string representations
|
|
136
|
+
# of the arrays with one element per line.
|
|
137
|
+
# @param format can be any valid Diffy option, e.g. :color
|
|
138
|
+
# see https://github.com/samg/diffy/blob/master/lib/diffy/format.rb
|
|
139
|
+
def array_diff(array1, array2, format = :text)
|
|
140
|
+
string1 = array_as_multiline_string(array1)
|
|
141
|
+
string2 = array_as_multiline_string(array2)
|
|
142
|
+
Diffy::Diff.new(string1, string2).to_s(format)
|
|
143
|
+
end
|
|
144
|
+
|
|
124
145
|
end
|
|
125
146
|
end
|
|
126
147
|
|
|
@@ -10,7 +10,7 @@ module TempFiles
|
|
|
10
10
|
# @param text the text to write to the temporary file
|
|
11
11
|
# @param file_prefix optional prefix for the temporary file's name
|
|
12
12
|
# @yield filespec of the temporary file
|
|
13
|
-
def
|
|
13
|
+
def file_containing(text, file_prefix = '')
|
|
14
14
|
raise "This method must be called with a code block." unless block_given?
|
|
15
15
|
|
|
16
16
|
filespec = nil
|
|
@@ -24,7 +24,6 @@ module TempFiles
|
|
|
24
24
|
File.delete filespec if filespec && File.exist?(filespec)
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
|
-
|
|
28
27
|
end
|
|
29
28
|
end
|
|
30
29
|
end
|
|
@@ -31,13 +31,13 @@ module Classes
|
|
|
31
31
|
|
|
32
32
|
unless read_access == :none
|
|
33
33
|
attr_reader(*attrs)
|
|
34
|
-
send(read_access, *attrs)
|
|
34
|
+
send(read_access, *attrs) # e.g. results in protected :foo, :bar
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
unless write_access == :none
|
|
38
38
|
attr_writer(*attrs)
|
|
39
39
|
writers = attrs.map { |attr| "#{attr}=".to_sym }
|
|
40
|
-
send(write_access, *writers)
|
|
40
|
+
send(write_access, *writers) # e.g. results in private :foo=, :bar=
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
|
|
@@ -54,7 +54,7 @@ module Timing
|
|
|
54
54
|
# e.g. benchmark('time to loop 1,000,000 times') { 1_000_000.times { 42 }; 'hi' }
|
|
55
55
|
# outputs the following string:
|
|
56
56
|
# 0.050000 0.000000 0.050000 ( 0.042376): time to loop 1,000,000 times
|
|
57
|
-
# and returns:
|
|
57
|
+
# and returns: 'hi'
|
|
58
58
|
#
|
|
59
59
|
# @param caption the text fragment to print after the timing data
|
|
60
60
|
# @param out_stream object responding to << that will get the output string
|
|
@@ -3,7 +3,15 @@ require 'fileutils'
|
|
|
3
3
|
|
|
4
4
|
module TrickBag
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# NOTE! If the gem you are testing defines a .gemspec file,
|
|
7
|
+
# then this approach may be eliminated by instead
|
|
8
|
+
# running the following command in the project root (thank you, Rob Kidd):
|
|
9
|
+
|
|
10
|
+
# bundle exec ruby -e "require 'my_gem_name'"
|
|
11
|
+
|
|
12
|
+
# (A bundle install will need to have been done with the current configuration.)
|
|
13
|
+
|
|
14
|
+
# Creates and optionally writes to file a script that will check to see that
|
|
7
15
|
# the gemspec/Gemfile includes all necessary gems.
|
|
8
16
|
#
|
|
9
17
|
# Testing this by doing a simple 'require' instead does not test for the
|
|
@@ -16,7 +24,12 @@ module TrickBag
|
|
|
16
24
|
# Assumes also that any *gem files in the project root are not needed, and deletes them!
|
|
17
25
|
#
|
|
18
26
|
# Call one of the methods to get the script content, and be sure to source it when you
|
|
19
|
-
# run it, otherwise rvm may complain that it is not a login shell.
|
|
27
|
+
# run it, otherwise rvm may complain that it is not a login shell. For example,
|
|
28
|
+
# gem install trick_bag and then, in your gem project root do:
|
|
29
|
+
#
|
|
30
|
+
# ruby -e "require 'trick_bag'; TrickBag::GemDependencyScript.write_script_for('', 'test_gem_dep')" && . ./test_gem_dep
|
|
31
|
+
#
|
|
32
|
+
# ...where, of course, you replace 'my_gem' with the name of your gem.
|
|
20
33
|
module GemDependencyScript
|
|
21
34
|
|
|
22
35
|
module_function
|
|
@@ -52,6 +65,7 @@ gemset_name()
|
|
|
52
65
|
|
|
53
66
|
}
|
|
54
67
|
|
|
68
|
+
# Returns a string containing a shell script that will test the gem (see above for details).
|
|
55
69
|
def script_for(gem_name, script_name = DEFAULT_SCRIPT_NAME)
|
|
56
70
|
require_command = "require '#{gem_name}'"
|
|
57
71
|
|
|
@@ -88,6 +102,8 @@ gemset_name()
|
|
|
88
102
|
end
|
|
89
103
|
|
|
90
104
|
|
|
105
|
+
# Writes to file a a shell script that will test the gem (see above for details),
|
|
106
|
+
# and sets the permission to be executable so it can be run as a shell command.
|
|
91
107
|
def write_script_for(gem_name, filespec = DEFAULT_SCRIPT_NAME)
|
|
92
108
|
File.write(filespec, script_for(gem_name, filespec))
|
|
93
109
|
FileUtils.chmod("u=wrx,go=rx", filespec)
|
|
@@ -29,6 +29,27 @@ module Validations
|
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
+
|
|
33
|
+
# When a gem project has a .gemspec, this uses bundle exec to verify that requiring
|
|
34
|
+
# that gem name does not result in an error. (An error would occur, for example,
|
|
35
|
+
# if a gem required by the project gem is not specified as a dependency in
|
|
36
|
+
# the .gemspec file.
|
|
37
|
+
#
|
|
38
|
+
# @return a hash containing the :exit_status (0 = success), output (stdout + stderr),
|
|
39
|
+
# and the :process_status (Process::Status object).
|
|
40
|
+
def test_gem_dependency_specs(gem_name)
|
|
41
|
+
command = %Q{bundle exec ruby -e "require '#{gem_name}'"}
|
|
42
|
+
|
|
43
|
+
output, process_status = Open3.capture2e(command)
|
|
44
|
+
|
|
45
|
+
output.prepend(command + "\n\n")
|
|
46
|
+
|
|
47
|
+
{
|
|
48
|
+
exit_status: process_status.exitstatus,
|
|
49
|
+
output: output,
|
|
50
|
+
process_status: process_status
|
|
51
|
+
}
|
|
52
|
+
end
|
|
32
53
|
end
|
|
33
54
|
end
|
|
34
55
|
|
data/lib/trick_bag/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
|
@@ -38,7 +38,7 @@ nbc.com
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
it "should create a temporary file" do
|
|
41
|
-
expect(File.exist?(@tempfile.path)).to
|
|
41
|
+
expect(File.exist?(@tempfile.path)).to eq(true)
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
it "should produce an array" do
|
|
@@ -46,15 +46,15 @@ nbc.com
|
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
it "should produce a nonempty array" do
|
|
49
|
-
expect(subject.to_a.empty?).to
|
|
49
|
+
expect(subject.to_a.empty?).to eq(false)
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
it "should produce a nonempty array containing 'abc.com'" do
|
|
53
|
-
expect(subject.to_a.include
|
|
53
|
+
expect(subject.to_a).to include('abc.com')
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
it "should produce an array without blank lines" do
|
|
57
|
-
expect(subject.to_a.include
|
|
57
|
+
expect(subject.to_a).not_to include('')
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
it "should produce an array without beginning comment characters" do
|
|
@@ -69,7 +69,7 @@ describe Formatters do
|
|
|
69
69
|
expect(s).to eq('2000-01-02_15-44-37')
|
|
70
70
|
#regex = /^\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d$/
|
|
71
71
|
#puts s
|
|
72
|
-
#expect(regex === s).to
|
|
72
|
+
#expect(regex === s).to eq(true)
|
|
73
73
|
#
|
|
74
74
|
#
|
|
75
75
|
end
|
|
@@ -122,6 +122,33 @@ describe Formatters do
|
|
|
122
122
|
|
|
123
123
|
end
|
|
124
124
|
end
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
context 'array_as_multiline_string' do
|
|
128
|
+
specify 'string representation is correct when array is NOT empty' do
|
|
129
|
+
array = [1, 2, 3]
|
|
130
|
+
expect(Formatters.array_as_multiline_string(array)).to eq("1\n2\n3\n")
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
specify 'string representation is correct when array is empty' do
|
|
134
|
+
array = []
|
|
135
|
+
expect(Formatters.array_as_multiline_string(array)).to eq("")
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
context 'array_diff' do
|
|
141
|
+
specify 'text is correct' do
|
|
142
|
+
a1 = [1, 2, 3]
|
|
143
|
+
a2 = [ 2, 3, 4]
|
|
144
|
+
actual_text = Formatters.array_diff(a1, a2, :color)
|
|
145
|
+
expected_text = "-1\n 2\n 3\n+4\n"
|
|
146
|
+
expect(actual_text).to eq(expected_text)
|
|
147
|
+
puts
|
|
148
|
+
puts actual_text
|
|
149
|
+
puts
|
|
150
|
+
end
|
|
151
|
+
end
|
|
125
152
|
end
|
|
126
153
|
|
|
127
154
|
end
|
|
@@ -17,15 +17,15 @@ module TrickBag
|
|
|
17
17
|
context "none?" do
|
|
18
18
|
|
|
19
19
|
specify "returns true when all are false" do
|
|
20
|
-
expect(TrickBag.none_with_object?(all_false_funcs, 1)).to
|
|
20
|
+
expect(TrickBag.none_with_object?(all_false_funcs, 1)).to eq(true)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
specify "returns false when all are true" do
|
|
24
|
-
expect(TrickBag.none_with_object?(all_true_funcs, 1)).to
|
|
24
|
+
expect(TrickBag.none_with_object?(all_true_funcs, 1)).to eq(false)
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
specify "returns false when some are false and some are true" do
|
|
28
|
-
expect(TrickBag.none_with_object?(mixed_true_false_funcs, 1)).to
|
|
28
|
+
expect(TrickBag.none_with_object?(mixed_true_false_funcs, 1)).to eq(false)
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
|
|
@@ -33,15 +33,15 @@ module TrickBag
|
|
|
33
33
|
context "any?" do
|
|
34
34
|
|
|
35
35
|
specify "returns false when all are false" do
|
|
36
|
-
expect(TrickBag.any_with_object?(all_false_funcs, 1)).to
|
|
36
|
+
expect(TrickBag.any_with_object?(all_false_funcs, 1)).to eq(false)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
specify "returns true when all are true" do
|
|
40
|
-
expect(TrickBag.any_with_object?(all_true_funcs, 1)).to
|
|
40
|
+
expect(TrickBag.any_with_object?(all_true_funcs, 1)).to eq(true)
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
specify "returns true when some are false and some are true" do
|
|
44
|
-
expect(TrickBag.any_with_object?(mixed_true_false_funcs, 1)).to
|
|
44
|
+
expect(TrickBag.any_with_object?(mixed_true_false_funcs, 1)).to eq(true)
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
47
|
|
|
@@ -49,20 +49,16 @@ module TrickBag
|
|
|
49
49
|
context "all?" do
|
|
50
50
|
|
|
51
51
|
specify "returns false when all are false" do
|
|
52
|
-
expect(TrickBag.all_with_object?(all_false_funcs, 1)).to
|
|
52
|
+
expect(TrickBag.all_with_object?(all_false_funcs, 1)).to eq(false)
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
specify "returns true when all are true" do
|
|
56
|
-
expect(TrickBag.all_with_object?(all_true_funcs, 1)).to
|
|
56
|
+
expect(TrickBag.all_with_object?(all_true_funcs, 1)).to eq(true)
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
specify "returns false when some are false and some are true" do
|
|
60
|
-
expect(TrickBag.all_with_object?(mixed_true_false_funcs, 1)).to
|
|
60
|
+
expect(TrickBag.all_with_object?(mixed_true_false_funcs, 1)).to eq(false)
|
|
61
61
|
end
|
|
62
62
|
end
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
63
|
end
|
|
67
|
-
|
|
68
64
|
end
|
|
@@ -17,14 +17,14 @@ describe TempFiles do
|
|
|
17
17
|
TempFiles.file_containing('foo') do |fspec|
|
|
18
18
|
filespec = fspec
|
|
19
19
|
end
|
|
20
|
-
expect(File.exist?(filespec)).to
|
|
20
|
+
expect(File.exist?(filespec)).to eq(false)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
it 'uses the prefix in the filespec' do
|
|
24
24
|
prefix = 'jsiapewrqms'
|
|
25
25
|
TempFiles.file_containing('', prefix) do |filespec|
|
|
26
26
|
filename = File.split(filespec).last
|
|
27
|
-
expect(filename.start_with?(prefix)).to
|
|
27
|
+
expect(filename.start_with?(prefix)).to eq(true)
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
end
|
|
@@ -14,15 +14,15 @@ describe Classes do
|
|
|
14
14
|
context 'class?' do
|
|
15
15
|
|
|
16
16
|
it 'should recognize String as a class' do
|
|
17
|
-
expect(Classes.class?('String')).to
|
|
17
|
+
expect(Classes.class?('String')).to eq(true)
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
it 'should recognize that RUBY_PLATFORM is not a class even though it is a defined constant' do
|
|
21
|
-
expect(Classes.class?('RUBY_PLATFORM')).to
|
|
21
|
+
expect(Classes.class?('RUBY_PLATFORM')).to eq(false)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
it 'should recognize a nonexistent constant as not being a class' do
|
|
25
|
-
expect(Classes.class?('Afjkdiurqpweruwiqopurqpweriuqewprzvxcvzxcvzxvzvzvzvcxzvzv')).to
|
|
25
|
+
expect(Classes.class?('Afjkdiurqpweruwiqopurqpweriuqewprzvxcvzxcvzxvzvzvzvcxzvzv')).to eq(false)
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
|
|
@@ -56,7 +56,7 @@ end
|
|
|
56
56
|
|
|
57
57
|
it "should be a private method" do
|
|
58
58
|
fn_create_class.()
|
|
59
|
-
expect(ClassPatchTestClass.private_method_defined?(:foo)).to
|
|
59
|
+
expect(ClassPatchTestClass.private_method_defined?(:foo)).to eq(true)
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
|
|
@@ -74,7 +74,7 @@ end
|
|
|
74
74
|
|
|
75
75
|
it "should be a private method" do
|
|
76
76
|
fn_create_class.()
|
|
77
|
-
expect(ClassPatchTestClass.private_method_defined?(:foo=)).to
|
|
77
|
+
expect(ClassPatchTestClass.private_method_defined?(:foo=)).to eq(true)
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
80
|
|
|
@@ -99,8 +99,8 @@ end
|
|
|
99
99
|
|
|
100
100
|
it "should be private reader and writer" do
|
|
101
101
|
fn_create_class.()
|
|
102
|
-
expect(ClassPatchTestClass.private_method_defined?(:foo)).to
|
|
103
|
-
expect(ClassPatchTestClass.private_method_defined?(:foo=)).to
|
|
102
|
+
expect(ClassPatchTestClass.private_method_defined?(:foo)).to eq(true)
|
|
103
|
+
expect(ClassPatchTestClass.private_method_defined?(:foo=)).to eq(true)
|
|
104
104
|
end
|
|
105
105
|
end
|
|
106
106
|
|
|
@@ -126,12 +126,12 @@ end
|
|
|
126
126
|
|
|
127
127
|
it "should be a public reader" do
|
|
128
128
|
fn_create_class.()
|
|
129
|
-
expect(ClassPatchTestClass.public_method_defined?(:foo)).to
|
|
129
|
+
expect(ClassPatchTestClass.public_method_defined?(:foo)).to eq(true)
|
|
130
130
|
end
|
|
131
131
|
|
|
132
132
|
it "should be a private writer" do
|
|
133
133
|
fn_create_class.()
|
|
134
|
-
expect(ClassPatchTestClass.private_method_defined?(:foo=)).to
|
|
134
|
+
expect(ClassPatchTestClass.private_method_defined?(:foo=)).to eq(true)
|
|
135
135
|
end
|
|
136
136
|
end
|
|
137
137
|
|
|
@@ -147,14 +147,14 @@ end
|
|
|
147
147
|
|
|
148
148
|
it "should be a private reader" do
|
|
149
149
|
fn_create_class.()
|
|
150
|
-
expect(ClassPatchTestClass.private_method_defined?(:foo)).to
|
|
150
|
+
expect(ClassPatchTestClass.private_method_defined?(:foo)).to eq(true)
|
|
151
151
|
end
|
|
152
152
|
|
|
153
153
|
it 'should not contain a writer at all' do
|
|
154
154
|
fn_create_class.()
|
|
155
|
-
expect(ClassPatchTestClass.private_method_defined?(:foo=)).to
|
|
156
|
-
expect(ClassPatchTestClass.protected_method_defined?(:foo=)).to
|
|
157
|
-
expect(ClassPatchTestClass.public_method_defined?(:foo=)).to
|
|
155
|
+
expect(ClassPatchTestClass.private_method_defined?(:foo=)).to eq(false)
|
|
156
|
+
expect(ClassPatchTestClass.protected_method_defined?(:foo=)).to eq(false)
|
|
157
|
+
expect(ClassPatchTestClass.public_method_defined?(:foo=)).to eq(false)
|
|
158
158
|
end
|
|
159
159
|
end
|
|
160
160
|
end
|
|
@@ -10,37 +10,37 @@ module Numeric
|
|
|
10
10
|
|
|
11
11
|
context '#start_position_reached?' do
|
|
12
12
|
it 'considers first element to be included when no start position and max are specified' do
|
|
13
|
-
expect(StartAndMax.new.start_position_reached?(0)).to
|
|
13
|
+
expect(StartAndMax.new.start_position_reached?(0)).to eq(true)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
it 'considers first element to be included when start position == n' do
|
|
17
|
-
expect(StartAndMax.new(n).start_position_reached?(n)).to
|
|
17
|
+
expect(StartAndMax.new(n).start_position_reached?(n)).to eq(true)
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
it 'considers first element to be included when start position < n' do
|
|
21
|
-
expect(StartAndMax.new(n).start_position_reached?(n + 1)).to
|
|
21
|
+
expect(StartAndMax.new(n).start_position_reached?(n + 1)).to eq(true)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
it 'considers first element NOT to be included when start position is specified but n < start' do
|
|
25
|
-
expect(StartAndMax.new(n).start_position_reached?(n - 1)).to
|
|
25
|
+
expect(StartAndMax.new(n).start_position_reached?(n - 1)).to eq(false)
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
context '#max_count_reached?' do
|
|
30
30
|
it 'returns false for a very large number when max is not specified' do
|
|
31
|
-
expect(StartAndMax.new.max_count_reached?(10 ** 100)).to
|
|
31
|
+
expect(StartAndMax.new.max_count_reached?(10 ** 100)).to eq(false)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
it 'returns true when when n == max' do
|
|
35
|
-
expect(StartAndMax.new(0, n).max_count_reached?(n)).to
|
|
35
|
+
expect(StartAndMax.new(0, n).max_count_reached?(n)).to eq(true)
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
it 'returns false when when n < max' do
|
|
39
|
-
expect(StartAndMax.new(0, n).max_count_reached?(n - 1)).to
|
|
39
|
+
expect(StartAndMax.new(0, n).max_count_reached?(n - 1)).to eq(false)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
it 'returns true when when n > max' do
|
|
43
|
-
expect(StartAndMax.new(0, n).max_count_reached?(n + 1)).to
|
|
43
|
+
expect(StartAndMax.new(0, n).max_count_reached?(n + 1)).to eq(true)
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
end
|
|
@@ -10,11 +10,11 @@ module System
|
|
|
10
10
|
|
|
11
11
|
context "#command_available" do
|
|
12
12
|
specify 'which ls returns true' do
|
|
13
|
-
expect(System.command_available?('ls')).to
|
|
13
|
+
expect(System.command_available?('ls')).to eq(true)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
specify 'which fsdfiuowqpfeqpxumwfuqiufqpiufpqwmiurqpruiiqwmxrqupruxmqowiruqmpmu returns false' do
|
|
17
|
-
expect(System.command_available?('fsdfiuowqpfeqpxumwfuqiufqpiufpqwmiurqpruiiqwmxrqupruxmqowiruqmpmu')).to
|
|
17
|
+
expect(System.command_available?('fsdfiuowqpfeqpxumwfuqiufqpiufpqwmiurqpruiiqwmxrqupruxmqowiruqmpmu')).to eq(false)
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
@@ -22,8 +22,8 @@ module System
|
|
|
22
22
|
context ".lsof" do
|
|
23
23
|
specify "returns ruby lines" do
|
|
24
24
|
lines = System.lsof
|
|
25
|
-
has_ruby_line = lines.
|
|
26
|
-
expect(has_ruby_line).to
|
|
25
|
+
has_ruby_line = lines.any? { |line| /ruby/ === line }
|
|
26
|
+
expect(has_ruby_line).to eq(true)
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
end
|
|
File without changes
|
|
@@ -21,10 +21,19 @@ module TrickBag
|
|
|
21
21
|
raise_on_invalid_value('foo', [:bar, :baz], 'manufacturer')
|
|
22
22
|
fail "Should have raised an error"
|
|
23
23
|
rescue => error
|
|
24
|
-
expect(
|
|
25
|
-
expect(
|
|
24
|
+
expect(error.message).to match(/manufacturer/)
|
|
25
|
+
expect(error.message).to match(/:bar/)
|
|
26
26
|
expect(error.message).to eq("Invalid manufacturer 'foo'; must be one of: [:bar, :baz].")
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
|
+
|
|
30
|
+
specify 'this gem contains all necessary gem dependency specifications' do
|
|
31
|
+
require 'open3'
|
|
32
|
+
result = test_gem_dependency_specs('trick_bag')
|
|
33
|
+
exit_status = result[:exit_status]
|
|
34
|
+
if exit_status != 0
|
|
35
|
+
fail "Exit status was #{exit_status}, output was:\n#{output}."
|
|
36
|
+
end
|
|
37
|
+
end
|
|
29
38
|
end
|
|
30
39
|
end
|
data/trick_bag.gemspec
CHANGED
|
@@ -19,10 +19,9 @@ Gem::Specification.new do |spec|
|
|
|
19
19
|
spec.require_paths = ["lib"]
|
|
20
20
|
|
|
21
21
|
spec.add_dependency "os", '~> 0'
|
|
22
|
+
spec.add_dependency "diffy", '~> 3.0'
|
|
22
23
|
|
|
23
24
|
spec.add_development_dependency "bundler", "~> 1.3"
|
|
24
|
-
spec.add_development_dependency "rake", '~> 10'
|
|
25
|
-
spec.add_development_dependency "rspec", '~>
|
|
26
|
-
spec.add_development_dependency "guard", '~> 2'
|
|
27
|
-
spec.add_development_dependency "guard-rspec", '~> 4'
|
|
25
|
+
spec.add_development_dependency "rake", '~> 10.1'
|
|
26
|
+
spec.add_development_dependency "rspec", '~> 3.0'
|
|
28
27
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: trick_bag
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.46.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Keith Bennett
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-
|
|
11
|
+
date: 2014-07-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: os
|
|
@@ -25,75 +25,61 @@ dependencies:
|
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
28
|
+
name: diffy
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
34
|
-
type: :
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - "~>"
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '1.3'
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: rake
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - "~>"
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '10'
|
|
48
|
-
type: :development
|
|
33
|
+
version: '3.0'
|
|
34
|
+
type: :runtime
|
|
49
35
|
prerelease: false
|
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
37
|
requirements:
|
|
52
38
|
- - "~>"
|
|
53
39
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '
|
|
40
|
+
version: '3.0'
|
|
55
41
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
42
|
+
name: bundler
|
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
|
58
44
|
requirements:
|
|
59
45
|
- - "~>"
|
|
60
46
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
47
|
+
version: '1.3'
|
|
62
48
|
type: :development
|
|
63
49
|
prerelease: false
|
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
51
|
requirements:
|
|
66
52
|
- - "~>"
|
|
67
53
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
54
|
+
version: '1.3'
|
|
69
55
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
56
|
+
name: rake
|
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
|
72
58
|
requirements:
|
|
73
59
|
- - "~>"
|
|
74
60
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '
|
|
61
|
+
version: '10.1'
|
|
76
62
|
type: :development
|
|
77
63
|
prerelease: false
|
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
65
|
requirements:
|
|
80
66
|
- - "~>"
|
|
81
67
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: '
|
|
68
|
+
version: '10.1'
|
|
83
69
|
- !ruby/object:Gem::Dependency
|
|
84
|
-
name:
|
|
70
|
+
name: rspec
|
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
|
86
72
|
requirements:
|
|
87
73
|
- - "~>"
|
|
88
74
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: '
|
|
75
|
+
version: '3.0'
|
|
90
76
|
type: :development
|
|
91
77
|
prerelease: false
|
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
79
|
requirements:
|
|
94
80
|
- - "~>"
|
|
95
81
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: '
|
|
82
|
+
version: '3.0'
|
|
97
83
|
description: Miscellaneous general useful tools for general purpose programming.
|
|
98
84
|
email:
|
|
99
85
|
- keithrbennett@gmail.com
|
|
@@ -153,7 +139,7 @@ files:
|
|
|
153
139
|
- spec/trick_bag/operators/operators_spec.rb
|
|
154
140
|
- spec/trick_bag/system_spec.rb
|
|
155
141
|
- spec/trick_bag/timing/timing_spec.rb
|
|
156
|
-
- spec/trick_bag/validations/
|
|
142
|
+
- spec/trick_bag/validations/hash_validations_spec.rb
|
|
157
143
|
- spec/trick_bag/validations/object_validations_spec.rb
|
|
158
144
|
- spec/trick_bag/validations/other_validations_spec.rb
|
|
159
145
|
- trick_bag.gemspec
|
|
@@ -177,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
177
163
|
version: '0'
|
|
178
164
|
requirements: []
|
|
179
165
|
rubyforge_project:
|
|
180
|
-
rubygems_version: 2.2.
|
|
166
|
+
rubygems_version: 2.2.2
|
|
181
167
|
signing_key:
|
|
182
168
|
specification_version: 4
|
|
183
169
|
summary: Miscellaneous general useful tools.
|
|
@@ -202,6 +188,6 @@ test_files:
|
|
|
202
188
|
- spec/trick_bag/operators/operators_spec.rb
|
|
203
189
|
- spec/trick_bag/system_spec.rb
|
|
204
190
|
- spec/trick_bag/timing/timing_spec.rb
|
|
205
|
-
- spec/trick_bag/validations/
|
|
191
|
+
- spec/trick_bag/validations/hash_validations_spec.rb
|
|
206
192
|
- spec/trick_bag/validations/object_validations_spec.rb
|
|
207
193
|
- spec/trick_bag/validations/other_validations_spec.rb
|