hirb 0.2.9 → 0.2.10
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.
- data/CHANGELOG.rdoc +13 -0
- data/LICENSE.txt +1 -1
- data/README.rdoc +1 -1
- data/VERSION.yml +3 -2
- data/lib/hirb.rb +22 -9
- data/lib/hirb/formatter.rb +1 -5
- data/lib/hirb/helpers/active_record_table.rb +1 -1
- data/lib/hirb/helpers/object_table.rb +2 -3
- data/lib/hirb/helpers/table.rb +104 -90
- data/lib/hirb/helpers/table/filters.rb +10 -0
- data/lib/hirb/helpers/table/resizer.rb +82 -0
- data/lib/hirb/helpers/vertical_table.rb +12 -6
- data/lib/hirb/menu.rb +204 -36
- data/lib/hirb/util.rb +11 -2
- data/lib/hirb/view.rb +29 -10
- data/test/auto_table_test.rb +8 -23
- data/test/formatter_test.rb +2 -2
- data/test/hirb_test.rb +13 -4
- data/test/menu_test.rb +134 -5
- data/test/object_table_test.rb +23 -4
- data/test/pager_test.rb +1 -1
- data/test/resizer_test.rb +61 -0
- data/test/table_test.rb +182 -75
- data/test/util_test.rb +5 -0
- data/test/view_test.rb +36 -4
- metadata +6 -2
data/test/util_test.rb
CHANGED
@@ -2,6 +2,11 @@ require File.join(File.dirname(__FILE__), 'test_helper')
|
|
2
2
|
|
3
3
|
module Hirb
|
4
4
|
class UtilTest < Test::Unit::TestCase
|
5
|
+
test "camelize converts underscore lowercase to camelcase" do
|
6
|
+
Util.camelize('hirb/util').should == "Hirb::Util"
|
7
|
+
Util.camelize('hirb_hash').should == "HirbHash"
|
8
|
+
end
|
9
|
+
|
5
10
|
test "any_const_get returns nested class" do
|
6
11
|
Util.any_const_get("Test::Unit").should == ::Test::Unit
|
7
12
|
end
|
data/test/view_test.rb
CHANGED
@@ -13,7 +13,7 @@ module Hirb
|
|
13
13
|
View.page_output('blah').should be(true)
|
14
14
|
Hirb.disable
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
test "page_output doesn't page when view is disabled" do
|
18
18
|
Hirb.enable
|
19
19
|
Hirb.disable
|
@@ -23,6 +23,7 @@ module Hirb
|
|
23
23
|
end
|
24
24
|
|
25
25
|
test "view_output catches unexpected errors and prints them" do
|
26
|
+
reset_config
|
26
27
|
Hirb.enable
|
27
28
|
View.expects(:render_output).raises('blah')
|
28
29
|
capture_stderr { View.view_output([1,2,3]) }.should =~ /Hirb Error: blah/
|
@@ -38,21 +39,52 @@ module Hirb
|
|
38
39
|
context_stub = stub(:last_value=>'')
|
39
40
|
::IRB::Irb.new(context_stub).output_value
|
40
41
|
end
|
42
|
+
|
41
43
|
test "is enabled?" do
|
42
44
|
Hirb.enable
|
43
45
|
assert View.enabled?
|
44
46
|
end
|
45
47
|
|
48
|
+
def output_class_config(klass)
|
49
|
+
{ :output=>{klass=>{:class=>:auto_table}} }
|
50
|
+
end
|
51
|
+
|
52
|
+
test "when called multiple times merges configs" do
|
53
|
+
Hirb.config = nil
|
54
|
+
# default config + config_file
|
55
|
+
Hirb.expects(:read_config_file).returns(output_class_config('Regexp'))
|
56
|
+
Hirb.enable output_class_config('String')
|
57
|
+
|
58
|
+
# add config file and explicit config
|
59
|
+
[{:config_file=>'ok'}, output_class_config('Struct')].each do |config|
|
60
|
+
Hirb.expects(:read_config_file).times(2).returns(
|
61
|
+
output_class_config('ActiveRecord::Base'), output_class_config('Array'))
|
62
|
+
Hirb.enable config
|
63
|
+
end
|
64
|
+
|
65
|
+
Hirb.config_files.include?('ok').should == true
|
66
|
+
output_keys = %w{ActiveRecord::Base Array Regexp String Struct}
|
67
|
+
Hirb::View.config[:output].keys.sort.should == output_keys
|
68
|
+
end
|
69
|
+
|
70
|
+
test "when called multiple times without config doesn't affect config" do
|
71
|
+
Hirb.enable
|
72
|
+
old_config = Hirb::View.config
|
73
|
+
Hirb.expects(:read_config_file).never
|
74
|
+
Hirb::View.expects(:load_config).never
|
75
|
+
Hirb.enable
|
76
|
+
Hirb::View.config.should == old_config
|
77
|
+
end
|
78
|
+
|
46
79
|
test "works without irb" do
|
47
80
|
Object.stubs(:const_defined?).with(:IRB).returns(false)
|
48
81
|
Hirb.enable
|
49
82
|
assert formatter_config.size > 0
|
50
83
|
end
|
51
84
|
|
52
|
-
test "with config_file option
|
53
|
-
Hirb.config_file.should_not == 'test_file'
|
85
|
+
test "with config_file option adds to config_file" do
|
54
86
|
Hirb.enable :config_file=> 'test_file'
|
55
|
-
Hirb.
|
87
|
+
Hirb.config_files.include?('test_file').should == true
|
56
88
|
end
|
57
89
|
|
58
90
|
test "with output_method option realiases output_method" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hirb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Horner
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-02-16 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -38,6 +38,8 @@ files:
|
|
38
38
|
- lib/hirb/helpers/object_table.rb
|
39
39
|
- lib/hirb/helpers/parent_child_tree.rb
|
40
40
|
- lib/hirb/helpers/table.rb
|
41
|
+
- lib/hirb/helpers/table/filters.rb
|
42
|
+
- lib/hirb/helpers/table/resizer.rb
|
41
43
|
- lib/hirb/helpers/tree.rb
|
42
44
|
- lib/hirb/helpers/vertical_table.rb
|
43
45
|
- lib/hirb/import_object.rb
|
@@ -56,6 +58,7 @@ files:
|
|
56
58
|
- test/menu_test.rb
|
57
59
|
- test/object_table_test.rb
|
58
60
|
- test/pager_test.rb
|
61
|
+
- test/resizer_test.rb
|
59
62
|
- test/table_test.rb
|
60
63
|
- test/test_helper.rb
|
61
64
|
- test/tree_test.rb
|
@@ -99,6 +102,7 @@ test_files:
|
|
99
102
|
- test/menu_test.rb
|
100
103
|
- test/object_table_test.rb
|
101
104
|
- test/pager_test.rb
|
105
|
+
- test/resizer_test.rb
|
102
106
|
- test/table_test.rb
|
103
107
|
- test/test_helper.rb
|
104
108
|
- test/tree_test.rb
|