auto_test 0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module AutoTest
2
- VERSION = "0.1"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/auto_test.rb CHANGED
@@ -28,7 +28,13 @@ module AutoTest
28
28
  DatabaseCleaner.clean
29
29
  end
30
30
 
31
+ def use_fixtures(bool)
32
+ Test.use_fixtures(bool)
33
+ end
31
34
 
35
+ def fixture_symbols(*symbols)
36
+ Test.fixture_symbols(symbols)
37
+ end
32
38
 
33
39
  def links_to_exclude(*links)
34
40
  Dsl.links_to_exclude(*links)
data/lib/page.rb CHANGED
@@ -191,7 +191,7 @@ module AutoTest
191
191
  # choose a random checkbox
192
192
  def choose_checkbox(name, input_texts, session)
193
193
  checkboxes = session.all('input').find_all{ |i| i[:type] == "checkbox" && i[:name] == name }
194
- choices = checkboxes.collect{ |r| r[:value] }
194
+ choices = checkboxes.collect{ |r| r[:name] }
195
195
  i = rand(choices.length)
196
196
  input_texts << "checkbox___" + name
197
197
  input_texts << choices[i].to_s
@@ -200,7 +200,7 @@ module AutoTest
200
200
 
201
201
  # select a random option from a select list
202
202
  def select_option(id, input_texts, session)
203
- options = session.find_by_id(id).all('option').collect{ |o| o.value }
203
+ options = session.find_by_id(id).all('option').collect{ |o| o.text }
204
204
  i = rand(options.size)
205
205
  input_texts << "select___"+id
206
206
  input_texts << options[i].to_s
@@ -10,8 +10,14 @@ require 'spec_helper'
10
10
  describe "Application" do
11
11
 
12
12
  describe "auto_test" do
13
+ if Test.use_fixtures? then
14
+ Test.fixture_symbols?.each do |fs|
15
+ fixtures fs
16
+ end
17
+ end
13
18
  it "does test the application automatically" do
14
19
  load "#{Rails.root}/db/test_seeds.rb"
20
+
15
21
  t = AutoTest::TestStarter.new
16
22
  t.test
17
23
  end
data/lib/test.rb CHANGED
@@ -11,6 +11,7 @@ module AutoTest
11
11
  Authentication.init_users
12
12
  Authentication.init_login_data
13
13
  init_action_path
14
+ init_links
14
15
  init_depth
15
16
  init_inputs
16
17
  init_always_present
@@ -21,10 +22,30 @@ module AutoTest
21
22
  init_number_of_test_runs
22
23
  end
23
24
 
25
+ def fixture_symbols(*symbols)
26
+ @@fixture_symbols = symbols
27
+ end
28
+
29
+ def fixture_symbols?
30
+ @@fixture_symbols
31
+ end
32
+
33
+ def use_fixtures?
34
+ @@use_fixtures
35
+ end
36
+
37
+ def use_fixtures(bool)
38
+ @@use_fixtures = bool
39
+ end
40
+
24
41
  def init_number_of_test_runs
25
42
  @@runs = 1
26
43
  end
27
44
 
45
+ def init_links
46
+ @@links = []
47
+ end
48
+
28
49
  def init_stop_at_first_error
29
50
  @@stop_at_first_error = false
30
51
  end
@@ -368,12 +389,10 @@ module AutoTest
368
389
  f.close
369
390
  puts
370
391
  Error.print_errors
371
- if Error.get_error > 0 then
372
- f = File.new("#{Rails.root}/log/errors.log", "w")
373
- f.puts(Error.get_error)
374
- f.puts(Error.get_error_messages)
375
- f.close
376
- end
392
+ f = File.new("#{Rails.root}/log/errors.log", "w")
393
+ f.puts(Error.get_error)
394
+ f.puts(Error.get_error_messages)
395
+ f.close
377
396
  end
378
397
  end
379
398
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: auto_test
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: "0.1"
5
+ version: 0.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Maike Hargens
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-10-03 00:00:00 Z
13
+ date: 2012-10-04 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faker
@@ -136,3 +136,4 @@ specification_version: 3
136
136
  summary: Tests applications automatically and randomly
137
137
  test_files: []
138
138
 
139
+ has_rdoc: