boson 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/boson/view.rb CHANGED
@@ -1,5 +1,51 @@
1
1
  module Boson
2
- # Handles {Hirb}[http://tagaholic.me/hirb/]-based views.
2
+ # This module generates views for a command by handing it to {Hirb}[http://tagaholic.me/hirb/]. Since Hirb can be customized
3
+ # to generate any view, commands can have any views associated with them!
4
+ #
5
+ # === Views with Render Options
6
+ # To pass rendering options to a Hirb helper as command options, a command has to define the options with
7
+ # the render_options method attribute:
8
+ #
9
+ # # @render_options :fields=>[:a,:b]
10
+ # def list(options={})
11
+ # [{:a=>1, :b=>2}, {:a=>10,:b=>11}]
12
+ # end
13
+ #
14
+ # # To see that the render_options method attribute actually passes the :fields option by default:
15
+ # >> list '-p' # or list '--pretend'
16
+ # Arguments: []
17
+ # Global options: {:pretend=>true, :fields=>[:a, :b]}
18
+ #
19
+ # >> list
20
+ # +----+----+
21
+ # | a | b |
22
+ # +----+----+
23
+ # | 1 | 2 |
24
+ # | 10 | 11 |
25
+ # +----+----+
26
+ # 2 rows in set
27
+ #
28
+ # # To create a vertical table, we can pass --vertical, one of the default global render options.
29
+ # >> list '-V' # or list '--vertical'
30
+ # *** 1. row ***
31
+ # a: 1
32
+ # b: 2
33
+ # ...
34
+ #
35
+ # # To get the original return value use the global option --render
36
+ # >> list '-r' # or list '--render'
37
+ # => [{:a=>1, :b=>2}, {:a=>10,:b=>11}]
38
+ #
39
+ # === Boson and Hirb
40
+ # Since Boson uses {Hirb's auto table helper}[http://tagaholic.me/hirb/doc/classes/Hirb/Helpers/AutoTable.html]
41
+ # by default, you may want to read up on its many options. To use any of them in commands, define them locally
42
+ # with render_options or globally by adding them under the :render_options key of the main config.
43
+ # What if you want to use your own helper class? No problem. Simply pass it with the global :class option.
44
+ #
45
+ # When using the default helper, one of the most important options to define is :fields. Aside from controlling what fields
46
+ # are displayed, it's used to set :values option attributes for related options i.e. :sort and :query. This provides handy option
47
+ # value aliasing via OptionParser. If you don't set :fields, Boson will try to set its :values with field-related options i.e.
48
+ # :change_fields, :filters and :headers.
3
49
  module View
4
50
  extend self
5
51
 
@@ -12,23 +58,13 @@ module Boson
12
58
  # Renders any object via Hirb. Options are passed directly to
13
59
  # {Hirb::Console.render_output}[http://tagaholic.me/hirb/doc/classes/Hirb/Console.html#M000011].
14
60
  def render(object, options={}, return_obj=false)
15
- if silent_object?(object)
16
- puts(object.inspect) unless options[:silence_booleans]
61
+ if options[:inspect]
62
+ puts(object.inspect)
17
63
  else
18
- render_object(object, options, return_obj)
64
+ render_object(object, options, return_obj) unless silent_object?(object)
19
65
  end
20
66
  end
21
67
 
22
- # Searches and sorts an array of objects or hashes using options :query, :sort and :reverse_sort.
23
- # The :query option is a hash of fields mapped to their search terms. Searches are OR-ed.
24
- def search_and_sort(object, options)
25
- if object.is_a?(Array)
26
- object = search_object(object, options[:query]) if options[:query]
27
- object = sort_object(object, options[:sort], options[:reverse_sort]) if object.size > 0 && options[:sort]
28
- end
29
- object
30
- end
31
-
32
68
  #:stopdoc:
33
69
  def toggle_pager
34
70
  Hirb::View.toggle_pager
@@ -43,56 +79,6 @@ module Boson
43
79
  render_result = Hirb::Console.render_output(object, options)
44
80
  return_obj ? object : render_result
45
81
  end
46
-
47
- def search_object(object, query_hash)
48
- if object[0].is_a?(Hash)
49
- TableCallbacks.search_callback(object, :query=>query_hash)
50
- else
51
- query_hash.map {|field,query| object.select {|e| e.send(field).to_s =~ /#{query}/i } }.flatten.uniq
52
- end
53
- rescue NoMethodError
54
- $stderr.puts "Query failed with nonexistant method '#{$!.message[/`(.*)'/,1]}'"
55
- end
56
-
57
- def sort_object(object, sort, reverse_sort=false)
58
- if object[0].is_a?(Hash)
59
- TableCallbacks.sort_callback(object, :sort=>sort, :reverse_sort=>reverse_sort)
60
- else
61
- sort_lambda = object.all? {|e| e.send(sort).respond_to?(:<=>) } ? lambda {|e| e.send(sort) || ''} :
62
- lambda {|e| e.send(sort).to_s }
63
- object = object.sort_by &sort_lambda
64
- object = object.reverse if reverse_sort
65
- object
66
- end
67
- rescue NoMethodError, ArgumentError
68
- $stderr.puts "Sort failed with nonexistant method '#{sort}'"
69
- end
70
82
  #:startdoc:
71
-
72
- # Callbacks used by Hirb::Helpers::Table to search and sort arrays of hashes.
73
- module TableCallbacks
74
- extend self
75
- # Case-insensitive searches an array of hashes using the option :query. Numerical string keys
76
- # in :query are converted to actual numbers to interface with Hirb. See View.search_and_sort for more
77
- # about :query.
78
- def search_callback(obj, options)
79
- !options[:query] ? obj : begin
80
- options[:query].map {|field,query|
81
- field = field.to_i if field.to_s[/^\d+$/]
82
- obj.select {|e| e[field].to_s =~ /#{query}/i }
83
- }.flatten.uniq
84
- end
85
- end
86
-
87
- # Sorts an array of hashes using :sort option and reverses the sort with :reverse_sort option.
88
- def sort_callback(obj, options)
89
- sort = options[:sort].to_s[/^\d+$/] ? options[:sort].to_i : options[:sort]
90
- sort_lambda = (obj.all? {|e| e[sort].respond_to?(:<=>) } ? lambda {|e| e[sort] } : lambda {|e| e[sort].to_s })
91
- obj = obj.sort_by &sort_lambda
92
- obj = obj.reverse if options[:reverse_sort]
93
- obj
94
- end
95
- end
96
83
  end
97
84
  end
98
- Hirb::Helpers::Table.send :include, Boson::View::TableCallbacks
@@ -109,24 +109,24 @@ module Boson
109
109
  def index(options={})
110
110
  Manager.expects(:load).with {|*args| args[0][0].is_a?(Module) ? true : args[0] == options[:load]
111
111
  }.at_least(1).returns(!options[:fails])
112
- Index.expects(:write)
112
+ Index.indexes[0].expects(:write)
113
113
  end
114
114
 
115
115
  test "with index option, no existing index and core command updates index and prints index message" do
116
116
  index :load=>Runner.all_libraries
117
- Index.stubs(:exists?).returns(false)
117
+ Index.indexes[0].stubs(:exists?).returns(false)
118
118
  capture_stdout { start("--index", "libraries") }.should =~ /Generating index/
119
119
  end
120
120
 
121
121
  test "with index option, existing index and core command updates incremental index" do
122
122
  index :load=>['changed']
123
- Index.stubs(:exists?).returns(true)
123
+ Index.indexes[0].stubs(:exists?).returns(true)
124
124
  capture_stdout { start("--index=changed", "libraries")}.should =~ /Indexing.*changed/
125
125
  end
126
126
 
127
127
  test "with index option, failed indexing prints error" do
128
128
  index :load=>['changed'], :fails=>true
129
- Index.stubs(:exists?).returns(true)
129
+ Index.indexes[0].stubs(:exists?).returns(true)
130
130
  Manager.stubs(:failed_libraries).returns(['changed'])
131
131
  capture_stderr {
132
132
  capture_stdout { start("--index=changed", "libraries")}.should =~ /Indexing.*changed/
@@ -134,7 +134,7 @@ module Boson
134
134
  end
135
135
 
136
136
  test "with core command updates index and doesn't print index message" do
137
- Index.expects(:write)
137
+ Index.indexes[0].expects(:write)
138
138
  Boson.main_object.expects(:send).with('libraries')
139
139
  capture_stdout { start 'libraries'}.should_not =~ /index/i
140
140
  end
@@ -142,18 +142,59 @@ module Boson
142
142
  test "with non-core command finding library doesn't update index" do
143
143
  Index.expects(:find_library).returns('sweet_lib')
144
144
  Manager.expects(:load).with {|*args| args[0].is_a?(String) ? args[0] == 'sweet_lib' : true}.at_least(1)
145
- Index.expects(:update).never
145
+ Index.indexes[0].expects(:update).never
146
146
  capture_stderr { start("sweet") }.should =~ /sweet/
147
147
  end
148
148
 
149
149
  test "with non-core command not finding library, does update index" do
150
150
  Index.expects(:find_library).returns(nil, 'sweet_lib').times(2)
151
151
  Manager.expects(:load).with {|*args| args[0].is_a?(String) ? args[0] == 'sweet_lib' : true}.at_least(1)
152
- Index.expects(:update).returns(true)
152
+ Index.indexes[0].expects(:update).returns(true)
153
153
  capture_stderr { start("sweet") }.should =~ /sweet/
154
154
  end
155
155
  end
156
156
 
157
+ context "render_output" do
158
+ before(:each) { Scientist.rendered = false; BinRunner.instance_eval "@options = {}" }
159
+
160
+ test "doesn't render when nil, false or true" do
161
+ View.expects(:render).never
162
+ [nil, false, true].each do |e|
163
+ BinRunner.render_output e
164
+ end
165
+ end
166
+
167
+ test "doesn't render when rendered with Scientist" do
168
+ Scientist.rendered = true
169
+ View.expects(:render).never
170
+ BinRunner.render_output 'blah'
171
+ end
172
+
173
+ test "render with puts when non-string" do
174
+ View.expects(:render).with('dude', {:method => 'puts'})
175
+ BinRunner.render_output 'dude'
176
+ end
177
+
178
+ test "renders with inspect when non-array and non-string" do
179
+ [{:a=>true}, :ok].each do |e|
180
+ View.expects(:puts).with(e.inspect)
181
+ BinRunner.render_output e
182
+ end
183
+ end
184
+
185
+ test "renders with inspect when Scientist rendering toggled off with :render" do
186
+ Scientist.global_options = {:render=>true}
187
+ View.expects(:puts).with([1,2].inspect)
188
+ BinRunner.render_output [1,2]
189
+ Scientist.global_options = nil
190
+ end
191
+
192
+ test "renders with hirb when array" do
193
+ View.expects(:render_object)
194
+ BinRunner.render_output [1,2,3]
195
+ end
196
+ end
197
+
157
198
  test "parse_args only translates options before command" do
158
199
  BinRunner.parse_args(['-v', 'com', '-v']).should == ["com", {:verbose=>true}, ['-v']]
159
200
  BinRunner.parse_args(['com', '-v']).should == ["com", {}, ['-v']]
@@ -84,16 +84,17 @@ module Boson
84
84
  end
85
85
 
86
86
  test "scrape all comment types with implicit desc" do
87
- @lines = ["module Foo", '# @render_options :b=>1', ' # @options {:a=>true}', '#blah', " def foo", " end", "end"]
88
- expected = {:desc=>"blah", :options=>{:a=>true}, :render_options=>{:b=>1}}
89
- CommentInspector.scrape(@lines.join("\n"), 5, Optional).should == expected
87
+ @lines = ["module Foo", '# @config :a=>true', '# @render_options :b=>1', ' # @options {:a=>true}',
88
+ '#blah', " def foo", " end", "end"]
89
+ expected = {:desc=>"blah", :options=>{:a=>true}, :render_options=>{:b=>1}, :config=>{:a=>true}}
90
+ CommentInspector.scrape(@lines.join("\n"), 6, Optional).should == expected
90
91
  end
91
92
 
92
93
  test "scrape all comment types with explicit desc" do
93
94
  @lines = ["module Foo", '#@desc blah', '# @render_options :b=>1,', '# :c=>2',
94
- ' # @options {:a=>true}', " def foo", " end", "end"]
95
- expected = {:desc=>"blah", :options=>{:a=>true}, :render_options=>{:b=>1, :c=>2}}
96
- CommentInspector.scrape(@lines.join("\n"), 6, Optional).should == expected
95
+ ' # @options {:a=>true}', ' # @config :a=>true', " def foo", " end", "end"]
96
+ expected = {:desc=>"blah", :options=>{:a=>true}, :render_options=>{:b=>1, :c=>2}, :config=>{:a=>true}}
97
+ CommentInspector.scrape(@lines.join("\n"), 7, Optional).should == expected
97
98
  end
98
99
  end
99
100
  end
Binary file
@@ -37,27 +37,6 @@ module Boson
37
37
  test "prints error for file library with multiple modules" do
38
38
  capture_stderr { load(:blah, :file_string=>"module Doo; end; module Daa; end") }.should =~ /Can't.*config/
39
39
  end
40
-
41
- test "with same module reloads" do
42
- load(:blah, :file_string=>"module Blah; def blah; end; end")
43
- File.stubs(:exists?).returns(true)
44
- File.stubs(:read).returns("module Blah; def bling; end; end")
45
- Manager.reload('blah').should == true
46
- command_exists?('bling')
47
- library('blah').commands.size.should == 2
48
- end
49
-
50
- test "with different module reloads" do
51
- load(:blah, :file_string=>"module Blah; def blah; end; end")
52
- File.stubs(:exists?).returns(true)
53
- File.stubs(:read).returns("module Bling; def bling; end; end")
54
- Manager.reload('blah').should == true
55
- library_has_module('blah', "Boson::Commands::Bling")
56
- command_exists?('bling')
57
- command_exists?('blah', false)
58
- library('blah').commands.size.should == 1
59
- end
60
-
61
40
  end
62
41
  end
63
- end
42
+ end
data/test/loader_test.rb CHANGED
@@ -35,6 +35,11 @@ module Boson
35
35
  end
36
36
  end
37
37
 
38
+ test "from inspector attribute config sets command's config" do
39
+ load :blah, :file_string=>"module Blah; config :alias=>'ok'\n; def bling; end; end"
40
+ library('blah').command_object('bling').alias.should == 'ok'
41
+ end
42
+
38
43
  test "hash from inspector recursively merged with user's config" do
39
44
  with_config(:libraries=>{'blah'=>{:commands=>{'blung'=>{:args=>[], :render_options=>{:sort=>'this'}}}}}) do
40
45
  CommentInspector.expects(:scrape).returns({:render_options=>{:fields=>['this']}})
@@ -227,18 +232,5 @@ module Boson
227
232
  end
228
233
  end
229
234
  end
230
-
231
- context "reload" do
232
- before(:each) { reset }
233
- test "loads currently unloaded library" do
234
- create_library('blah')
235
- Manager.expects(:load).with('blah', anything)
236
- Manager.reload('blah')
237
- end
238
-
239
- test "doesn't load nonexistent library" do
240
- capture_stdout { Manager.reload('bling', :verbose=>true) }.should =~ /bling doesn't/
241
- end
242
- end
243
235
  end
244
236
  end
data/test/manager_test.rb CHANGED
@@ -74,14 +74,14 @@ module Boson
74
74
  }
75
75
 
76
76
  test "are deleted" do
77
- Scientist.expects(:create_option_command).with(anything, @foo)
78
- Manager.create_option_commands(@library, @library.commands)
77
+ Scientist.expects(:redefine_command).with(anything, @foo)
78
+ Manager.redefine_commands(@library, @library.commands)
79
79
  end
80
80
 
81
81
  test "are deleted and printed when verbose" do
82
- Scientist.expects(:create_option_command).with(anything, @foo)
82
+ Scientist.expects(:redefine_command).with(anything, @foo)
83
83
  @library.instance_eval("@options = {:verbose=>true}")
84
- capture_stdout { Manager.create_option_commands(@library, @library.commands) } =~ /options.*blah/
84
+ capture_stdout { Manager.redefine_commands(@library, @library.commands) } =~ /options.*blah/
85
85
  end
86
86
  end
87
87
 
@@ -36,9 +36,14 @@ module Boson
36
36
  parse("render_options :z=>true; def zee; end")[:render_options].should == {"zee"=>{:z=>true}}
37
37
  end
38
38
 
39
- test "neither options or desc set, sets method_locations" do
39
+ test "config sets config" do
40
+ parse("config :z=>true; def zee; end")[:config].should == {"zee"=>{:z=>true}}
41
+ end
42
+
43
+ test "not all method attributes set causes method_locations to be set" do
40
44
  MethodInspector.stubs(:find_method_locations).returns(["/some/path", 10])
41
- parsed = parse "desc 'yo'; def yo; end; options :yep=>1; def yep; end; render_options :a=>1; desc 'z'; options :a=>1; def az; end"
45
+ parsed = parse "desc 'yo'; def yo; end; options :yep=>1; def yep; end; " +
46
+ "render_options :a=>1; config :a=>1; desc 'z'; options :a=>1; def az; end"
42
47
  parsed[:method_locations].key?('yo').should == true
43
48
  parsed[:method_locations].key?('yep').should == true
44
49
  parsed[:method_locations].key?('az').should == false
@@ -1,57 +1,57 @@
1
1
  require File.join(File.dirname(__FILE__), 'test_helper')
2
2
 
3
3
  module Boson
4
- class ViewTest < Test::Unit::TestCase
4
+ class PipeTest < Test::Unit::TestCase
5
5
  before(:all) {
6
6
  @hashes = [{:a=>'some', :b=>'thing'}, {:a=>:more, :b=>:yep}]
7
- Ab = Struct.new(:a, :b) unless ViewTest.const_defined?(:Ab)
7
+ Ab = Struct.new(:a, :b) unless PipeTest.const_defined?(:Ab)
8
8
  @objects = [Ab.new('some', 'thing'), Ab.new(:more, :yep)]
9
9
  }
10
10
  context "search_object" do
11
11
 
12
12
  test "searches one query" do
13
13
  [@hashes, @objects].each {|e|
14
- View.search_object(e, :a=>'some').should == e[0,1]
14
+ Pipe.search_object(e, :a=>'some').should == e[0,1]
15
15
  }
16
16
  end
17
17
 
18
18
  test "searches non-string values" do
19
19
  [@hashes, @objects].each {|e|
20
- View.search_object(e, :a=>'more').should == e[1,1]
20
+ Pipe.search_object(e, :a=>'more').should == e[1,1]
21
21
  }
22
22
  end
23
23
 
24
24
  test "searches multiple search terms" do
25
25
  [@hashes, @objects].each {|e|
26
- View.search_object(e, :a=>'some', :b=>'yep').size.should == 2
26
+ Pipe.search_object(e, :a=>'some', :b=>'yep').size.should == 2
27
27
  }
28
28
  end
29
29
 
30
30
  test "prints error for invalid search field" do
31
- capture_stderr { View.search_object(@objects, :blah=>'blah') }.should =~ /failed.*'blah'/
31
+ capture_stderr { Pipe.search_object(@objects, :blah=>'blah') }.should =~ /failed.*'blah'/
32
32
  end
33
33
  end
34
34
 
35
35
  context "sort_object" do
36
36
  test "sorts objects with values of different types" do
37
- View.sort_object(@objects, :a).should == @objects.reverse
37
+ Pipe.sort_object(@objects, :a).should == @objects.reverse
38
38
  end
39
39
 
40
40
  test "sorts hashes with values of different types" do
41
- View.sort_object(@hashes, :a).should == @hashes.reverse
41
+ Pipe.sort_object(@hashes, :a).should == @hashes.reverse
42
42
  end
43
43
 
44
44
  test "sorts numeric values" do
45
45
  hashes = [{:a=>10, :b=>4}, {:a=>5, :b=>3}]
46
- View.sort_object(hashes, :a).should == hashes.reverse
46
+ Pipe.sort_object(hashes, :a).should == hashes.reverse
47
47
  end
48
48
 
49
49
  test "sorts and reverses sort" do
50
- View.sort_object(@hashes, :a, true).should == @hashes
50
+ Pipe.sort_object(@hashes, :a, true).should == @hashes
51
51
  end
52
52
 
53
53
  test "prints error for invalid sort field" do
54
- capture_stderr { View.sort_object(@objects, :blah)}.should =~ /failed.*'blah'/
54
+ capture_stderr { Pipe.sort_object(@objects, :blah)}.should =~ /failed.*'blah'/
55
55
  end
56
56
  end
57
57
  end
@@ -1,18 +1,18 @@
1
1
  require File.join(File.dirname(__FILE__), 'test_helper')
2
2
 
3
3
  module Boson
4
- class IndexTest < Test::Unit::TestCase
4
+ class RepoIndexTest < Test::Unit::TestCase
5
5
  # since we're defining our own @commands, @libraries, @lib_hashes
6
- before(:all) { Index.instance_variable_set "@read", true }
6
+ before(:all) { @index = RepoIndex.new(Boson.repo); @index.instance_variable_set "@read", true }
7
7
 
8
8
  context "read_and_transfer" do
9
- before(:each) { reset_boson; Index.instance_eval "@libraries = @commands = nil" }
9
+ before(:each) { reset_boson; @index.instance_eval "@libraries = @commands = nil" }
10
10
 
11
11
  def transfers(options={})
12
- Index.instance_variable_set "@libraries", [Library.new(:name=>'blah', :commands=>['blurb']),
12
+ @index.instance_variable_set "@libraries", [Library.new(:name=>'blah', :commands=>['blurb']),
13
13
  Library.new(:name=>'bling')]
14
- Index.instance_variable_set "@commands", [Command.new(:name=>'blurb', :lib=>'blah')]
15
- Index.read_and_transfer options[:ignored] || []
14
+ @index.instance_variable_set "@commands", [Command.new(:name=>'blurb', :lib=>'blah')]
15
+ @index.read_and_transfer options[:ignored] || []
16
16
  Boson.libraries.map {|e| e.name}.should == options[:libraries]
17
17
  Boson.commands.map {|e| e.name}.should == options[:commands]
18
18
  end
@@ -42,43 +42,43 @@ module Boson
42
42
  commands = [Command.new(:name=>'blurb', :lib=>'blah', :alias=>'bb'),
43
43
  Command.new(:name=>'sub', :lib=>'bling', :alias=>'s')
44
44
  ]
45
- Index.instance_variable_set "@commands", commands
46
- Index.instance_variable_set "@libraries", [Library.new(:name=>'blah'), Library.new(:name=>'bling', :namespace=>'bling')]
45
+ @index.instance_variable_set "@commands", commands
46
+ @index.instance_variable_set "@libraries", [Library.new(:name=>'blah'), Library.new(:name=>'bling', :namespace=>'bling')]
47
47
  }
48
48
 
49
49
  test "finds command aliased or not" do
50
- Index.find_library('blurb').should == 'blah'
51
- Index.find_library('bb').should == 'blah'
50
+ @index.find_library('blurb').should == 'blah'
51
+ @index.find_library('bb').should == 'blah'
52
52
  end
53
53
 
54
54
  test "doesn't find command" do
55
- Index.find_library('blah').should == nil
55
+ @index.find_library('blah').should == nil
56
56
  end
57
57
 
58
58
  test "finds a subcommand aliased or not" do
59
- Index.find_library('bling.sub').should == 'bling'
60
- # Index.find_library('bl.s').should == 'bling'
59
+ @index.find_library('bling.sub').should == 'bling'
60
+ # @index.find_library('bl.s').should == 'bling'
61
61
  end
62
62
 
63
63
  test "finds namespace command aliased or not without a subcommand" do
64
- Index.find_library('bling').should == 'bling'
65
- # Index.find_library('bl').should == 'bling'
64
+ @index.find_library('bling').should == 'bling'
65
+ # @index.find_library('bl').should == 'bling'
66
66
  end
67
67
 
68
68
  test "doesn't find a subcommand" do
69
- Index.find_library('d.d').should == nil
69
+ @index.find_library('d.d').should == nil
70
70
  end
71
71
  end
72
72
 
73
73
  context "changed_libraries" do
74
- before(:all) { Index.instance_eval "@lib_hashes = nil" }
74
+ before(:all) { @index.instance_eval "@lib_hashes = nil" }
75
75
 
76
76
  def changed(string, all_libs=['file1'])
77
- Runner.expects(:all_libraries).returns(all_libs)
78
- Index.instance_variable_set "@lib_hashes", {"file1"=>Digest::MD5.hexdigest("state1")}
77
+ @index.repo.expects(:all_libraries).returns(all_libs)
78
+ @index.instance_variable_set "@lib_hashes", {"file1"=>Digest::MD5.hexdigest("state1")}
79
79
  File.stubs(:exists?).returns(true)
80
80
  File.expects(:read).returns(string)
81
- Index.changed_libraries
81
+ @index.changed_libraries
82
82
  end
83
83
 
84
84
  test "detects changed libraries" do
@@ -99,19 +99,19 @@ module Boson
99
99
  reset_boson
100
100
  Boson.commands << Command.new(:name=>'blah', :lib=>'blah', :args=>[['arg1', {}], ['arg2', self.class]])
101
101
  Boson.libraries << Library.new(:name=>'blah', :module=>self.class)
102
- Index.expects(:latest_hashes)
102
+ @index.expects(:latest_hashes)
103
103
  libraries = commands = []
104
- Index.expects(:save_marshal_index).with {|str| libraries, commands, hashes = Marshal.load(str) ; true}
105
- Index.write
106
- @index = {:libraries=>libraries, :commands=>commands}
104
+ @index.expects(:save_marshal_index).with {|str| libraries, commands, hashes = Marshal.load(str) ; true}
105
+ @index.write
106
+ @index_hash = {:libraries=>libraries, :commands=>commands}
107
107
  }
108
108
 
109
109
  test "saves library module constants as strings" do
110
- @index[:libraries][0].module.class.should == String
110
+ @index_hash[:libraries][0].module.class.should == String
111
111
  end
112
112
 
113
113
  test "save commands with arg values as strings" do
114
- @index[:commands][0].args.each {|e| e[1].class.should == String}
114
+ @index_hash[:commands][0].args.each {|e| e[1].class.should == String}
115
115
  end
116
116
  end
117
117
  end