rasta 0.1.8-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,337 @@
1
+ TOPDIR = File.join(File.dirname(__FILE__), '..')
2
+ $LOAD_PATH.unshift File.expand_path(TOPDIR)
3
+
4
+
5
+ require 'spec'
6
+ require 'lib/rasta/spreadsheet'
7
+
8
+ TESTFILE = TOPDIR + '/test/spreadsheets/spreadsheet_parsing.xls'
9
+
10
+ describe "Book Initialization" do
11
+ it 'should populate the Excel Constants' do
12
+ # Do this test first or the constants get loaded by Book.new
13
+ Rasta::Spreadsheet::ExcelConst.constants.should == []
14
+ book = Rasta::Spreadsheet::Book.new(TESTFILE)
15
+ Rasta::Spreadsheet::ExcelConst.constants.should_not == []
16
+ end
17
+ it 'should fail if file not specified' do
18
+ lambda {
19
+ book = Rasta::Spreadsheet::Book.new()
20
+ }.should raise_error
21
+ end
22
+ it 'should fail if file not found' do
23
+ lambda {
24
+ book = Rasta::Spreadsheet::Book.new('examples/invalid_file_name')
25
+ }.should raise_error
26
+ end
27
+ it 'should initialize properly with valid filename' do
28
+ lambda {
29
+ book = Rasta::Spreadsheet::Book.new(TESTFILE)
30
+ }.should_not raise_error
31
+ end
32
+ it 'should have default options set' do
33
+ excel = Rasta::Spreadsheet::Excel.instance
34
+ book = Rasta::Spreadsheet::Book.new(TESTFILE)
35
+ excel.visible.should be_false
36
+ excel.continue.should be_false
37
+ end
38
+ it 'should handle passed options' do
39
+ excel = Rasta::Spreadsheet::Excel.instance
40
+ excel.continue = 'test'
41
+ book = Rasta::Spreadsheet::Book.new(TESTFILE)
42
+ excel.visible.should be_false
43
+ excel.continue.should == 'test'
44
+ excel.continue = false
45
+ end
46
+ it 'should have have a method for returning the filename' do
47
+ book = Rasta::Spreadsheet::Book.new(TESTFILE)
48
+ book.filename.should == TESTFILE
49
+ end
50
+ it 'should return an ole_object for the workbook' do
51
+ book = Rasta::Spreadsheet::Book.new(TESTFILE)
52
+ book.ole_object.class.should == WIN32OLE
53
+ end
54
+ end
55
+
56
+ describe 'SpreadsheetTab', :shared => true do
57
+ before(:all) do
58
+ @book = Rasta::Spreadsheet::Book.new(TESTFILE)
59
+ @sheet = nil
60
+ end
61
+ after(:all) do
62
+ Rasta::Spreadsheet::Excel.instance.cleanup
63
+ end
64
+ end
65
+
66
+ describe 'BasicStyles', :shared => true do
67
+ it_should_behave_like 'SpreadsheetTab'
68
+ it 'should locate the headers' do
69
+ @sheet.headers.should == ['a','b']
70
+ end
71
+ end
72
+
73
+ describe 'Sheet style :col (1)' do
74
+ it_should_behave_like 'BasicStyles'
75
+ before(:each) do
76
+ @sheet = @book['ColStyle.1']
77
+ end
78
+ it 'should find the data range' do
79
+ @sheet.firstrow.should == 2
80
+ @sheet.firstcol.should == 1
81
+ @sheet.lastrow.should == 7
82
+ @sheet.lastcol.should == 2
83
+ end
84
+ end
85
+ describe 'Sheet style :col (2)' do
86
+ it_should_behave_like 'BasicStyles'
87
+ before(:each) do
88
+ @sheet = @book['ColStyle.2']
89
+ end
90
+ it 'should find the data range' do
91
+ @sheet.firstrow.should == 2
92
+ @sheet.firstcol.should == 2
93
+ @sheet.lastrow.should == 7
94
+ @sheet.lastcol.should == 3
95
+ end
96
+ end
97
+ describe 'Sheet style :col (3)' do
98
+ it_should_behave_like 'BasicStyles'
99
+ before(:each) do
100
+ @sheet = @book['ColStyle.3']
101
+ end
102
+ it 'should find the data range' do
103
+ @sheet.firstrow.should == 2
104
+ @sheet.firstcol.should == 1
105
+ @sheet.lastrow.should == 7
106
+ @sheet.lastcol.should == 2
107
+ end
108
+ end
109
+ describe 'Sheet style :col (4)' do
110
+ it_should_behave_like 'BasicStyles'
111
+ before(:each) do
112
+ @sheet = @book['ColStyle.4']
113
+ end
114
+ it 'should find the data range' do
115
+ @sheet.firstrow.should == 2
116
+ @sheet.firstcol.should == 2
117
+ @sheet.lastrow.should == 7
118
+ @sheet.lastcol.should == 3
119
+ end
120
+ end
121
+
122
+ describe 'Sheet style :row (1)' do
123
+ it_should_behave_like 'BasicStyles'
124
+ before(:each) do
125
+ @sheet = @book['RowStyle.1']
126
+ end
127
+ it 'should find the data range' do
128
+ @sheet.firstrow.should == 1
129
+ @sheet.firstcol.should == 2
130
+ @sheet.lastrow.should == 2
131
+ @sheet.lastcol.should == 7
132
+ end
133
+ end
134
+ describe 'Sheet style :row (2)' do
135
+ it_should_behave_like 'BasicStyles'
136
+ before(:each) do
137
+ @sheet = @book['RowStyle.2']
138
+ end
139
+ it 'should find the data range' do
140
+ @sheet.firstrow.should == 2
141
+ @sheet.firstcol.should == 2
142
+ @sheet.lastrow.should == 3
143
+ @sheet.lastcol.should == 7
144
+ end
145
+ end
146
+ describe 'Sheet style :row (3)' do
147
+ it_should_behave_like 'BasicStyles'
148
+ before(:each) do
149
+ @sheet = @book['RowStyle.3']
150
+ end
151
+ it 'should find the data range' do
152
+ @sheet.firstrow.should == 1
153
+ @sheet.firstcol.should == 2
154
+ @sheet.lastrow.should == 2
155
+ @sheet.lastcol.should == 7
156
+ end
157
+ end
158
+ describe 'Sheet style :row (4)' do
159
+ it_should_behave_like 'BasicStyles'
160
+ before(:each) do
161
+ @sheet = @book['RowStyle.4']
162
+ end
163
+ it 'should find the data range' do
164
+ @sheet.firstrow.should == 2
165
+ @sheet.firstcol.should == 2
166
+ @sheet.lastrow.should == 3
167
+ @sheet.lastcol.should == 7
168
+ end
169
+ end
170
+
171
+ describe 'Datatypes' do
172
+ it_should_behave_like 'SpreadsheetTab'
173
+ before(:each) do
174
+ @sheet = @book['Datatypes']
175
+ end
176
+ it 'should handle integers' do
177
+ @sheet[2][1].value.class.should == Fixnum
178
+ @sheet[2][1].value.should == 1
179
+ end
180
+ it 'should handle floats' do
181
+ @sheet[2][2].value.class.should == Float
182
+ @sheet[2][2].value.should == 2.0
183
+ end
184
+ it 'should handle hashes' do
185
+ @sheet[2][3].value.class.should == Hash
186
+ @sheet[2][3].value.should == { 'a'=>1, 'b'=>2 }
187
+ end
188
+ it 'should handle arrays' do
189
+ @sheet[2][4].value.class.should == Array
190
+ @sheet[2][4].value.should == ['c', 'd', 'e']
191
+ end
192
+ it 'should handle boolean uppercase' do
193
+ @sheet[2][5].value.class.should == TrueClass
194
+ @sheet[2][5].value.should == true
195
+ end
196
+ it 'should handle boolean lowercase' do
197
+ @sheet[2][6].value.class.should == FalseClass
198
+ @sheet[2][6].value.should == false
199
+ end
200
+ end
201
+
202
+ describe 'Whitespace' do
203
+ it_should_behave_like 'SpreadsheetTab'
204
+ before(:each) do
205
+ @sheet = @book['Whitespace']
206
+ end
207
+ it 'should trim leading whitespace' do
208
+ @sheet[2][1].value.should == 'test'
209
+ end
210
+ it 'should trim trailing whitespace' do
211
+ @sheet[2][2].value.should == 'test'
212
+ end
213
+ it 'should not trim middle whitespace' do
214
+ @sheet[2][3].value.should == 'this is a test'
215
+ end
216
+ it 'should trim leading and trailing whitespace' do
217
+ @sheet[2][4].value.should == 'test'
218
+ end
219
+ end
220
+
221
+ describe 'Control Flow - Tabs' do
222
+ it_should_behave_like 'SpreadsheetTab'
223
+ it 'should not include hidden tabs' do
224
+ lambda{ @sheet = @book['ControlFlow.hidden'] }.should raise_error
225
+ end
226
+ it 'should not include colored tabs' do
227
+ lambda{ @sheet = @book['ControlFlow.1'] }.should raise_error
228
+ end
229
+ it 'should not include commented tabs' do
230
+ lambda{ @sheet = @book['ControlFlow.2'] }.should raise_error
231
+ end
232
+ end
233
+
234
+ describe 'Control Flow - Worksheet' do
235
+ it_should_behave_like 'SpreadsheetTab'
236
+ it 'should select worksheet without error' do
237
+ lambda{
238
+ @sheet = @book['ColStyle.1'] #select called implicitly
239
+ }.should_not raise_error
240
+ end
241
+ it 'should raise error when calling bogus worksheet' do
242
+ lambda{
243
+ @sheet = @book['Bogus'] #select called implicitly
244
+ }.should raise_error
245
+ end
246
+ it 'should select the home cell without error' do
247
+ @sheet = @book['ColStyle.1']
248
+ lambda{ @sheet.select_home_cell }.should_not raise_error
249
+ end
250
+ it 'should properly identify data cells' do
251
+ @sheet = @book['ColStyle.1']
252
+ @sheet.datacell?(1,1).should == false
253
+ @sheet.datacell?(1,2).should == false
254
+ @sheet.datacell?(2,1).should == true
255
+ @sheet.datacell?(2,2).should == true
256
+ end
257
+ it 'should be able to get a range for a :row style' do
258
+ @sheet = @book['ColStyle.1']
259
+ lambda{ @sheet.cellrange(2) }.should_not raise_error
260
+ end
261
+ it 'should be able to get a range of cell values for a :row style' do
262
+ @sheet = @book['ColStyle.1']
263
+ @sheet.cellrangevals(2).should == [1.0,2.0]
264
+ end
265
+ it 'should be able to get a range for a :col style' do
266
+ @sheet = @book['RowStyle.1']
267
+ @sheet.cellrangevals(2).should == [1.0,2.0]
268
+ end
269
+ it 'should be able to get a worksheet column name from a column index' do
270
+ @sheet = @book['ColStyle.1']
271
+ @sheet.colname(1).should == 'A'
272
+ @sheet.colname(2).should == 'B'
273
+ end
274
+ it 'should gracefully handle a sheet with no data' do
275
+ @sheet = @book['Blank']
276
+ lambda{ @sheet.cellrange(2) }.should_not raise_error
277
+ end
278
+ end
279
+
280
+ describe 'Sheet initialization' do
281
+ it_should_behave_like 'SpreadsheetTab'
282
+
283
+ it 'should provide the reference to the Book' do
284
+ @book['ColStyle.1'].book.class.should == Rasta::Spreadsheet::Book
285
+ end
286
+
287
+ it 'should return a valid ole_object for the Sheet' do
288
+ @book['ColStyle.1'].ole_object.class.should == WIN32OLE
289
+ end
290
+
291
+ it 'should return the name of the worksheet tab' do
292
+ @book['ColStyle.1'].name.should == 'ColStyle.1'
293
+ end
294
+
295
+ it 'should provide metadata with to_s' do
296
+ metadata = "firstrow = 2\n" +
297
+ "firstcol = 1\n" +
298
+ "lastrow = 7\n" +
299
+ "lastcol = 2\n" +
300
+ "style = row\n"
301
+ @book['ColStyle.1'].to_s.should == metadata
302
+ end
303
+ end
304
+
305
+ # Apparently the WIN32OLE returns a string for a range
306
+ # with a single value and an array for multiple values
307
+ # so test for the corner case. This series of tests
308
+ # makes sure we can properly handle a spreadsheet
309
+ # with that single data cell
310
+ describe 'Single data cell' do
311
+ it_should_behave_like 'SpreadsheetTab'
312
+
313
+ it 'should properly identify data cells for :col' do
314
+ @sheet = @book['SingleCell.col']
315
+ @sheet.datacell?(2,1).should == true
316
+ end
317
+ it 'should get data from cell for :col' do
318
+ @sheet = @book['SingleCell.col']
319
+ @sheet.headers.should == ['number']
320
+ end
321
+ it 'should be able to get a range for a :col style' do
322
+ @sheet = @book['SingleCell.col']
323
+ lambda{ @sheet.cellrangevals(2) }.should_not raise_error
324
+ end
325
+ it 'should properly identify data cells for :row' do
326
+ @sheet = @book['SingleCell.row']
327
+ @sheet.datacell?(1,2).should == true
328
+ end
329
+ it 'should get data from cell for :row' do
330
+ @sheet = @book['SingleCell.row']
331
+ @sheet.headers.should == ['number']
332
+ end
333
+ it 'should be able to get a range for a :row style' do
334
+ @sheet = @book['SingleCell.row']
335
+ lambda{ @sheet.cellrangevals(2) }.should_not raise_error
336
+ end
337
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rasta
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.8
5
+ platform: x86-mswin32-60
6
+ authors:
7
+ - Hugh McGowan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-01-18 00:00:00 -06:00
13
+ default_executable: rasta
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.1.11
24
+ version:
25
+ description: Rasta is a keyword-driven test framework using spreadsheets to drive test automation. It is loosely based on FIT - tables define test parameters which call your test fixture. As the test runs, the spreadsheet is updated with test results.
26
+ email: rasta@rubyforge.org
27
+ executables:
28
+ - rasta
29
+ extensions: []
30
+
31
+ extra_rdoc_files: []
32
+
33
+ files:
34
+ - README.txt
35
+ - LICENSE.txt
36
+ - lib/rasta
37
+ - lib/rasta/extensions
38
+ - lib/rasta/extensions/rspec_extensions.rb
39
+ - lib/rasta/fixture
40
+ - lib/rasta/fixture/base_fixture.rb
41
+ - lib/rasta/fixture/rasta_fixture.rb
42
+ - lib/rasta/fixture_runner.rb
43
+ - lib/rasta/formatter
44
+ - lib/rasta/formatter/spreadsheet_formatter.rb
45
+ - lib/rasta/spreadsheet.rb
46
+ - lib/rasta/version.rb
47
+ - lib/rasta.rb
48
+ - examples/crud_worksheet.xls
49
+ - examples/fixtures
50
+ - examples/fixtures/ColumnLayout.rb
51
+ - examples/fixtures/crud
52
+ - examples/fixtures/crud/CrudClass.rb
53
+ - examples/fixtures/crud/CrudFixture.rb
54
+ - examples/fixtures/HtmlRegistration.rb
55
+ - examples/fixtures/MathFunctions.rb
56
+ - examples/fixtures/StringFunctions.rb
57
+ - examples/html
58
+ - examples/html/registration.html
59
+ - examples/rasta_fixture.xls
60
+ - examples/tests_in_column_layout.xls
61
+ - examples/watir_example.xls
62
+ - test/fixtures
63
+ - test/fixtures/RastaTestFixture.rb
64
+ - test/spreadsheets
65
+ - test/spreadsheets/rasta_fixture.xls
66
+ - test/spreadsheets/spreadsheet_parsing.xls
67
+ - test/test_bookmarks.rb
68
+ - test/test_fixtures.rb
69
+ - test/test_spreadsheet.rb
70
+ - bin/rasta
71
+ has_rdoc: false
72
+ homepage: http://rasta.rubyforge.org/
73
+ post_install_message:
74
+ rdoc_options: []
75
+
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: "0"
83
+ version:
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: "0"
89
+ version:
90
+ requirements: []
91
+
92
+ rubyforge_project: rasta
93
+ rubygems_version: 1.3.1
94
+ signing_key:
95
+ specification_version: 2
96
+ summary: "rasta-0.1.8: Ruby Spreadsheet Test Automation http://rasta.rubyforge.org/"
97
+ test_files: []
98
+