browser_shooter 0.3.11 → 0.3.13

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -154,6 +154,29 @@ Then you will be able to use this new command into the _test section_ like this:
154
154
 
155
155
  You can check the [custom extensions](https://github.com/fguillen/BrowserShooter/tree/master/lib/browser_shooter/commands) that are already integrated in BrowserShooter.
156
156
 
157
+ ###### External test files
158
+
159
+ Instead of defining all the tests in this file you can create a folder and create **a File for each Tests**.
160
+
161
+ These files have to have the **_.test_ extension**.
162
+
163
+ Then you use the _tests_ key on the _config.yml_ file to indicate the **path to the external test files folder**.
164
+
165
+ For example, if you have this file tree:
166
+
167
+ /config.yml
168
+ /external_tests/test1.test
169
+ /external_tests/test2.test
170
+
171
+ Then you have to use this configuration:
172
+
173
+ tests: "./external_tests"
174
+
175
+ The path is **relative to the _config.yml_ file path**.
176
+
177
+ The name of the Test will be **the name of the File**. Use it in your _suite_ definition.
178
+
179
+ Check the [config with external test](https://github.com/fguillen/BrowserShooter/blob/master/examples/config_with_external_tests.yml) example.
157
180
 
158
181
  ##### Browsers section
159
182
 
@@ -0,0 +1,24 @@
1
+ output_path: "~/browser_shoots"
2
+ timeout: 5
3
+
4
+ tests: "./external_tests"
5
+
6
+ browsers:
7
+ ios-firefox:
8
+ url: "http://127.0.0.1:4444/wd/hub"
9
+ type: "firefox"
10
+ vm: "myVM"
11
+
12
+ ios-chrome:
13
+ url: "http://127.0.0.1:4444/wd/hub"
14
+ type: "chrome"
15
+ vm: "myVM"
16
+
17
+ suites:
18
+ suite1:
19
+ tests:
20
+ - google
21
+ - miniclip
22
+ browsers:
23
+ - ios-firefox
24
+ - ios-chrome
@@ -0,0 +1,5 @@
1
+ navigate.to "http://www.google.de"
2
+ shot "before"
3
+ type "input[name='q']", "beautiful houses"
4
+ pause 3
5
+ shot "after"
@@ -0,0 +1,2 @@
1
+ navigate.to "http://www.miniclip.com/games/de/"
2
+ shot
@@ -25,11 +25,37 @@ module BrowserShooter
25
25
 
26
26
  config.merge! YAML.load_file( config_file_path )
27
27
 
28
- config["output_path"] = setup_output_path( config["output_path"] )
28
+ config["output_path"] = setup_output_path( config["output_path"] )
29
+ config["config_root_path"] = File.dirname( config_file_path )
30
+
31
+ # _tests_ key is a folder path for external test files
32
+ if( config["tests"].is_a?( String ) )
33
+ config["tests"] = BrowserShooter::Configurator.load_external_tests( config )
34
+ end
29
35
 
30
36
  config
31
37
  end
32
38
 
39
+ # If the _tests_ key in the _config.yml_ is an string
40
+ # we load of the files in this path as _tests_ and add
41
+ # them to the original config.
42
+ def self.load_external_tests( config )
43
+ tests_path = File.join( config["config_root_path"], config["tests"] )
44
+
45
+ BrowserShooter::Logger.log( "Loading external tests: #{tests_path}" )
46
+
47
+ raise ArgumentError, "External tests dir path doesn't exist: 'tests_path'" if !File.exists?( tests_path )
48
+
49
+ tests = {}
50
+
51
+ Dir.glob( "#{tests_path}/*.test" ).each do |test_path|
52
+ test_name = File.basename( test_path, ".test" )
53
+ tests[ test_name ] = File.read( test_path )
54
+ end
55
+
56
+ return tests
57
+ end
58
+
33
59
  # Creates the _tests_, _browsers_ and _suites_ arrays.
34
60
  def self.build_models( config )
35
61
  tests =
@@ -1,3 +1,3 @@
1
1
  module BrowserShooter
2
- VERSION = "0.3.11"
2
+ VERSION = "0.3.13"
3
3
  end
@@ -46,6 +46,45 @@ class ConfiguratorTest < Test::Unit::TestCase
46
46
  assert_equal( models[:browsers].first, models[:suites].first.browsers.first )
47
47
  end
48
48
 
49
+ def test_build_models_from_external_tests
50
+ BrowserShooter::Configurator.stubs( :setup_output_path )
51
+ config = BrowserShooter::Configurator.load_config( "#{FIXTURES}/config_with_external_tests.yml" )
52
+ models = BrowserShooter::Configurator.build_models( config )
53
+
54
+ assert_equal( 2, models[:tests].size )
55
+ assert_equal( "google", models[:tests].first.name )
56
+ assert_equal( 2, models[:tests].first.commands.size )
57
+ assert_equal( "google command1", models[:tests].first.commands.first )
58
+ end
59
+
60
+ def test_load_external_tests
61
+ BrowserShooter::Configurator.stubs( :setup_output_path )
62
+ config = {
63
+ "tests" => "./external_tests",
64
+ "config_root_path" => "#{File.dirname(__FILE__)}/fixtures/"
65
+ }
66
+
67
+ tests = BrowserShooter::Configurator.load_external_tests( config )
68
+
69
+ assert_equal( 2, tests.size )
70
+ assert_equal( "google", tests.keys.first )
71
+ assert_equal( "google command1\ngoogle command2", tests.values.first )
72
+ assert_equal( "miniclip", tests.keys.last )
73
+ assert_equal( "miniclip command1\nminiclip command2", tests.values.last )
74
+ end
75
+
76
+ def test_load_external_tests_error_if_path_doesnot_exist
77
+ BrowserShooter::Configurator.stubs( :setup_output_path )
78
+ config = {
79
+ "tests" => "./no/exists",
80
+ "config_root_path" => "#{File.dirname(__FILE__)}/fixtures/"
81
+ }
82
+
83
+ assert_raise( ArgumentError ) do
84
+ BrowserShooter::Configurator.load_external_tests( config )
85
+ end
86
+ end
87
+
49
88
  def test_filter_suites
50
89
  BrowserShooter::Configurator.stubs( :setup_output_path )
51
90
  config = BrowserShooter::Configurator.load_config( "#{FIXTURES}/config.yml" )
@@ -0,0 +1,14 @@
1
+ tests: "./external_tests"
2
+
3
+ browsers:
4
+ windows-firefox:
5
+ url: "http://10.211.55.4:4444/wd/hub"
6
+ type: "firefox"
7
+
8
+ suites:
9
+ suite1:
10
+ tests:
11
+ - google
12
+ - miniclip
13
+ browsers:
14
+ - windows-firefox
@@ -0,0 +1,2 @@
1
+ google command1
2
+ google command2
@@ -0,0 +1,2 @@
1
+ miniclip command1
2
+ miniclip command2
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: browser_shooter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.11
4
+ version: 0.3.13
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-12 00:00:00.000000000Z
12
+ date: 2012-04-13 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
- requirement: &70295546959160 !ruby/object:Gem::Requirement
16
+ requirement: &70244954707340 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.0.0.rc.6
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70295546959160
24
+ version_requirements: *70244954707340
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70295546958660 !ruby/object:Gem::Requirement
27
+ requirement: &70244954706840 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - =
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.9.2.2
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70295546958660
35
+ version_requirements: *70244954706840
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: mocha
38
- requirement: &70295546958280 !ruby/object:Gem::Requirement
38
+ requirement: &70244954706460 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70295546958280
46
+ version_requirements: *70244954706460
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: selenium-webdriver
49
- requirement: &70295546957820 !ruby/object:Gem::Requirement
49
+ requirement: &70244954706000 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70295546957820
57
+ version_requirements: *70244954706000
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: mixlib-cli
60
- requirement: &70295546957400 !ruby/object:Gem::Requirement
60
+ requirement: &70244954705580 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70295546957400
68
+ version_requirements: *70244954705580
69
69
  description: Selenium RC wraper to create browser screenshots
70
70
  email:
71
71
  - fguillen.mail@gmail.com
@@ -86,7 +86,10 @@ files:
86
86
  - examples/config1.yml
87
87
  - examples/config2.yml
88
88
  - examples/config3_debug.yml
89
+ - examples/config_with_external_tests.yml
89
90
  - examples/extension0.rb
91
+ - examples/external_tests/google.test
92
+ - examples/external_tests/miniclip.test
90
93
  - lib/browser_shooter.rb
91
94
  - lib/browser_shooter/argv_parser.rb
92
95
  - lib/browser_shooter/base.rb
@@ -113,6 +116,9 @@ files:
113
116
  - test/fixtures/config_empty.yml
114
117
  - test/fixtures/config_in_order.yml
115
118
  - test/fixtures/config_simple.yml
119
+ - test/fixtures/config_with_external_tests.yml
120
+ - test/fixtures/external_tests/google.test
121
+ - test/fixtures/external_tests/miniclip.test
116
122
  - test/fixtures/logs/log.csv
117
123
  - test/fixtures/screenshot.base64
118
124
  - test/log_exporter_test.rb
@@ -156,6 +162,9 @@ test_files:
156
162
  - test/fixtures/config_empty.yml
157
163
  - test/fixtures/config_in_order.yml
158
164
  - test/fixtures/config_simple.yml
165
+ - test/fixtures/config_with_external_tests.yml
166
+ - test/fixtures/external_tests/google.test
167
+ - test/fixtures/external_tests/miniclip.test
159
168
  - test/fixtures/logs/log.csv
160
169
  - test/fixtures/screenshot.base64
161
170
  - test/log_exporter_test.rb