bob_test 0.0.2

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.
Files changed (4) hide show
  1. data/README +3 -0
  2. data/lib/Bt.rb +15 -0
  3. data/lib/bob_test.rb +77 -0
  4. metadata +57 -0
data/README ADDED
@@ -0,0 +1,3 @@
1
+ HIYO!
2
+
3
+ require 'bob_test'
data/lib/Bt.rb ADDED
@@ -0,0 +1,15 @@
1
+ class Bt
2
+
3
+ def run_tests
4
+ self.class.send(:methods_to_test).all?{|meth| self.send meth.intern}
5
+ end
6
+
7
+ def sassy
8
+ puts "FUCK OFF"
9
+ end
10
+
11
+ def self.methods_to_test
12
+ self.new.methods - self.methods - ['run_tests']
13
+ end
14
+
15
+ end
data/lib/bob_test.rb ADDED
@@ -0,0 +1,77 @@
1
+ # get_line and get_lines unabashedly stolen from the command_history.rb file in the Utility Belt gem.
2
+ module BobTest
3
+ def self.included(base)
4
+ base.send :extend, ClassMethods
5
+ end
6
+ module ClassMethods
7
+ require 'ftools'
8
+ class << self; attr_accessor :test; end
9
+
10
+ def start_test(name = Time.now.to_s)
11
+ @test = BobTest.new
12
+ @test.start_line = Readline::HISTORY.size - 1
13
+ @test.name = name
14
+ end
15
+
16
+ # todo figure out why there's an off by 1 error. Would expect size - 1 to be the last command.
17
+ def end_test
18
+ @test.end_line = Readline::HISTORY.size - 3
19
+ @test.get_lines(@test.start_line..@test.end_line)
20
+ # TODO figure out how to find path to rails project.
21
+ path_to_file = File.expand_path(File.dirname(__FILE__)) + "/../test/unit/bob/"
22
+ File.makedirs(path_to_file)
23
+ filename ="#{self.class_name.underscore}_bob_test.rb"
24
+ filename_with_path = path_to_file + filename
25
+ File.open(filename_with_path, 'w+') do |f|
26
+ f.write("class #{self.class_name}BobTest < Bt\nend\n")
27
+ end unless File.exists?(filename_with_path)
28
+ @test.write_to_file(filename_with_path)
29
+ end
30
+ end
31
+
32
+
33
+ # need to figure out what File.open('/path/to/file', 'wb' ) does # the wb part. (w means write, b means binary)
34
+ # commands.rb in rails source
35
+
36
+ class BobTest
37
+
38
+ attr_accessor :name, :start_line, :end_line, :contents, :indentable_words
39
+
40
+ @indentable_words = %w{begin break case def do else elsif end ensure if in next redo rescue retry return
41
+ super then unless until when while yield}
42
+
43
+ def get_lines(lines = [])
44
+ out = []
45
+ lines = lines.to_a if lines.is_a? Range
46
+ lines.each do |l|
47
+ out << Readline::HISTORY[l]
48
+ end
49
+ @contents = out
50
+ end
51
+
52
+ def write_to_file(file)
53
+ File.open(file, 'r+') do |f|
54
+ lines = f.readlines
55
+ e = lines.pop
56
+ until e.eql?("end\n")
57
+ e = lines.pop
58
+ break if lines.empty?
59
+ end
60
+ f.pos = 0
61
+ f.write lines
62
+ f.write " def #{name.gsub(/\W/,'_')}\n"
63
+ @contents.each do |line|
64
+ f.write " #{line}\n"
65
+ end
66
+ f.write " end\n"
67
+ f.write e
68
+ f.truncate f.pos
69
+ end
70
+ # gonna have to run a file indenter !
71
+ # gotta figure out how to load the files this produces
72
+ # pluginify this
73
+ end
74
+
75
+ end
76
+
77
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bob_test
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - deathbob
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-02-07 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: bob_test is dangerous.
17
+ email: larrick@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - README
26
+ - lib/Bt.rb
27
+ - lib/bob_test.rb
28
+ has_rdoc: true
29
+ homepage: http://github.com/deathbob/bob_test
30
+ licenses: []
31
+
32
+ post_install_message:
33
+ rdoc_options: []
34
+
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: "0"
42
+ version:
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ version:
49
+ requirements: []
50
+
51
+ rubyforge_project:
52
+ rubygems_version: 1.3.5
53
+ signing_key:
54
+ specification_version: 3
55
+ summary: bob_test is a testing strategy for people named bob.
56
+ test_files: []
57
+