chemistrykit 2.1.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,8 @@
1
+ # Encoding: utf-8
2
+
1
3
  module ChemistryKit
2
4
  module Formula
5
+ # Base functionality for the Formula class
3
6
  class Base
4
7
 
5
8
  attr_accessor :catalyst
@@ -12,6 +15,6 @@ module ChemistryKit
12
15
  self.catalyst = ChemistryKit::Catalyst.new(path_to_file)
13
16
  end
14
17
 
15
- end #Base
16
- end #Formula
17
- end #ChemistryKit
18
+ end # Base
19
+ end # Formula
20
+ end # ChemistryKit
@@ -0,0 +1,55 @@
1
+ # Encoding: utf-8
2
+
3
+ require 'parallel_tests/rspec/runner'
4
+ require 'parallel_tests/test/runner'
5
+
6
+ module ParallelTests
7
+ module RSpec
8
+ # Monkey Patching the ParallelTest RSpec Runner class to work with CKit's config and binary
9
+ class Runner < ParallelTests::Test::Runner
10
+
11
+ class << self
12
+
13
+ def run_tests(test_files, process_number, num_processes, options)
14
+ exe = executable # expensive, so we cache
15
+ version = (exe =~ /\brspec\b/ ? 2 : 1)
16
+
17
+ # // Beginning of method modifications //
18
+ # cmd = [exe, options[:test_options], (rspec_2_color if version == 2), spec_opts, *test_files].compact.join(" ")
19
+ # NOTE: The above line was modified to conform to ckit's command line constraints
20
+
21
+ cmd = [exe, options[:test_options]].compact.join(' ')
22
+ cmd << test_files.join(' ')
23
+ puts cmd
24
+
25
+ # This concatenates the command into `bundle exec ckit brew --beakers=beaker1 beaker2 beaker3 etc`
26
+ # Which enables each test group to be run in its own command
27
+ # --beakers= is set in lib/chemkistrykit/cli/cli.rb when parallel_tests is executed using its -o option flag
28
+
29
+ # // End of method modifications //
30
+
31
+ options = options.merge(env: rspec_1_color) if version == 1
32
+ execute_command(cmd, process_number, num_processes, options)
33
+ end
34
+
35
+ def determine_executable
36
+ 'bundle exec ckit brew --parallel'
37
+ end
38
+
39
+ def test_file_name
40
+ 'beaker'
41
+ end
42
+
43
+ def test_suffix
44
+ '_beaker.rb'
45
+ end
46
+
47
+ def runtime_log
48
+ # TODO This needs to do something.
49
+ File.join(Dir.getwd, 'evidence', 'parallel_runtime_rspec.log')
50
+ end
51
+
52
+ end # self
53
+ end # Runner
54
+ end # RSpec
55
+ end # ParallelTests
@@ -1,16 +1,25 @@
1
- require 'selenium-connect'
1
+ # Encoding: utf-8
2
+
2
3
  require 'rspec/core/shared_context'
4
+ require 'selenium-connect'
5
+ require 'chemistrykit/configuration'
6
+ require 'yaml'
3
7
 
4
8
  module ChemistryKit
9
+ # Extends the Rspec Shared Context to include hooks for Selenium Connect
5
10
  module SharedContext
6
11
  extend RSpec::Core::SharedContext
7
12
 
13
+ config_file = File.join(Dir.getwd, ENV['CONFIG_FILE'])
14
+ config = ChemistryKit::Configuration.initialize_with_yaml config_file
15
+
8
16
  SeleniumConnect.configure do |c|
9
- c.config_file = File.join(Dir.getwd, ENV['CONFIG_FILE'])
17
+ c.populate_with_hash config.selenium_connect
10
18
  end
11
19
 
12
20
  before(:each) do
13
21
  @driver = SeleniumConnect.start
22
+ @config = config
14
23
  end
15
24
 
16
25
  after(:each) do
@@ -21,5 +30,5 @@ module ChemistryKit
21
30
  SeleniumConnect.finish
22
31
  end
23
32
 
24
- end #SharedContext
25
- end #ChemistryKit
33
+ end # SharedContext
34
+ end # ChemistryKit
@@ -1,23 +1,28 @@
1
- #Setup & Debugging
2
- jar:
3
- log:
1
+ # Default Chemisty Kit Configuration File
4
2
 
3
+ base_url: http://google.com
4
+ concurrency: 2
5
+ selenium_connect:
6
+ #Setup & Debugging
7
+ jar:
8
+ log:
5
9
 
6
- #Where to run your tests
7
- host: 'localhost'
8
- port: #set to 4444 by default
9
10
 
11
+ #Where to run your tests
12
+ host: 'localhost'
13
+ port: #set to 4444 by default
10
14
 
11
- #Browser & Host
12
- browser: 'firefox'
13
- browser_path:
14
- profile_path:
15
- profile_name:
16
15
 
16
+ #Browser & Host
17
+ browser: 'firefox'
18
+ browser_path:
19
+ profile_path:
20
+ profile_name:
17
21
 
18
- #Saucelabs
19
- os:
20
- sauce_username:
21
- sauce_api_key:
22
- browser_version:
23
- description:
22
+
23
+ #Saucelabs
24
+ os:
25
+ sauce_username:
26
+ sauce_api_key:
27
+ browser_version:
28
+ description:
@@ -1,4 +1,7 @@
1
+ # Encoding: utf-8
2
+
3
+ # this is where you can define generic helper functions that are inhereted by
4
+ # the rest of your formulas
1
5
  class Formula < ChemistryKit::Formula::Base
2
- #this is where you can define generic helper functions that are inhereted by
3
- #the rest of your formulas
6
+
4
7
  end
@@ -1,3 +1,5 @@
1
+ # Encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe ChemistryKit::Catalyst do
@@ -6,7 +8,7 @@ describe ChemistryKit::Catalyst do
6
8
 
7
9
  Dir.mkdir(File.join(TEST_TMP_PATH, 'catalyst'))
8
10
  @data_file = File.join(TEST_TMP_PATH, 'catalyst', 'catalyst_data.csv')
9
- File.open(@data_file, 'w') {|f| f.write("first_key,first_value\nsecond_key,second_value") }
11
+ File.open(@data_file, 'w') { |f| f.write("first_key,first_value\nsecond_key,second_value") }
10
12
  @catalyst = ChemistryKit::Catalyst.new(@data_file)
11
13
  end
12
14
 
@@ -25,14 +27,8 @@ describe ChemistryKit::Catalyst do
25
27
  end
26
28
 
27
29
  it 'Should throw an exception for a non existant key.' do
28
- expect {
29
- @catalyst.get_value_for('third_key')
30
- }.to raise_error("Unknown \"third_key\"")
31
-
32
- expect {
33
- @catalyst.third_key
34
- }.to raise_error("Unknown \"third_key\"")
35
-
30
+ expect { @catalyst.get_value_for('third_key') }.to raise_error("Unknown \"third_key\"")
31
+ expect { @catalyst.third_key }.to raise_error("Unknown \"third_key\"")
36
32
  end
37
33
 
38
34
  after(:each) do
@@ -1,5 +1,7 @@
1
+ # Encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
- #might be able to use something like this: https://github.com/alexeypetrushin/class_loader
4
+ # might be able to use something like this: https://github.com/alexeypetrushin/class_loader
3
5
 
4
6
  describe ChemistryKit::CLI::Helpers::FormulaLoader do
5
7
 
@@ -13,7 +15,7 @@ describe ChemistryKit::CLI::Helpers::FormulaLoader do
13
15
  end
14
16
 
15
17
  it 'should return ruby files in alphabetical order' do
16
- #create some test files
18
+ # create some test files
17
19
  d = File.join(TEST_TMP_PATH, 'formula', 'd.rb')
18
20
  a = File.join(TEST_TMP_PATH, 'formula', 'a.rb')
19
21
  b = File.join(TEST_TMP_PATH, 'formula', 'b.rb')
@@ -21,15 +23,15 @@ describe ChemistryKit::CLI::Helpers::FormulaLoader do
21
23
  FileUtils.touch(a)
22
24
  FileUtils.touch(b)
23
25
 
24
- #ensure the result
26
+ # ensure the result
25
27
  @loader.get_formulas(File.join(TEST_TMP_PATH, 'formula')).should eq [a, b, d]
26
28
 
27
29
  end
28
30
 
29
31
  it 'should order files in child directories before parent directories' do
30
32
  Dir.mkdir(File.join(TEST_TMP_PATH, 'formula', 'child'))
31
- d = File.join(TEST_TMP_PATH, 'formula', 'child' ,'d.rb')
32
- b = File.join(TEST_TMP_PATH, 'formula', 'child' ,'b.rb')
33
+ d = File.join(TEST_TMP_PATH, 'formula', 'child', 'd.rb')
34
+ b = File.join(TEST_TMP_PATH, 'formula', 'child', 'b.rb')
33
35
  a = File.join(TEST_TMP_PATH, 'formula', 'a.rb')
34
36
  c = File.join(TEST_TMP_PATH, 'formula', 'c.rb')
35
37
  FileUtils.touch(d)
@@ -43,8 +45,8 @@ describe ChemistryKit::CLI::Helpers::FormulaLoader do
43
45
  it 'should load directories in alphabetical order' do
44
46
  Dir.mkdir(File.join(TEST_TMP_PATH, 'formula', 'abby'))
45
47
  Dir.mkdir(File.join(TEST_TMP_PATH, 'formula', 'road'))
46
- d = File.join(TEST_TMP_PATH, 'formula', 'abby' ,'d.rb')
47
- b = File.join(TEST_TMP_PATH, 'formula', 'road' ,'b.rb')
48
+ d = File.join(TEST_TMP_PATH, 'formula', 'abby', 'd.rb')
49
+ b = File.join(TEST_TMP_PATH, 'formula', 'road', 'b.rb')
48
50
  FileUtils.touch(d)
49
51
  FileUtils.touch(b)
50
52
  @loader.get_formulas(File.join(TEST_TMP_PATH, 'formula')).should eq [d, b]
@@ -53,8 +55,8 @@ describe ChemistryKit::CLI::Helpers::FormulaLoader do
53
55
  it 'should load any lib directory before any other' do
54
56
  Dir.mkdir(File.join(TEST_TMP_PATH, 'formula', 'lib'))
55
57
  Dir.mkdir(File.join(TEST_TMP_PATH, 'formula', 'abby'))
56
- d = File.join(TEST_TMP_PATH, 'formula', 'lib' ,'d.rb')
57
- b = File.join(TEST_TMP_PATH, 'formula', 'abby' ,'b.rb')
58
+ d = File.join(TEST_TMP_PATH, 'formula', 'lib', 'd.rb')
59
+ b = File.join(TEST_TMP_PATH, 'formula', 'abby', 'b.rb')
58
60
  FileUtils.touch(d)
59
61
  FileUtils.touch(b)
60
62
  @loader.get_formulas(File.join(TEST_TMP_PATH, 'formula')).should eq [d, b]
@@ -66,11 +68,11 @@ describe ChemistryKit::CLI::Helpers::FormulaLoader do
66
68
  Dir.mkdir(File.join(TEST_TMP_PATH, 'formula', 'abby', 'lib'))
67
69
  Dir.mkdir(File.join(TEST_TMP_PATH, 'formula', 'abby', 'road'))
68
70
 
69
- a = File.join(TEST_TMP_PATH, 'formula', 'lib' ,'a.rb')
70
- c = File.join(TEST_TMP_PATH, 'formula', 'abby' ,'c.rb')
71
+ a = File.join(TEST_TMP_PATH, 'formula', 'lib', 'a.rb')
72
+ c = File.join(TEST_TMP_PATH, 'formula', 'abby', 'c.rb')
71
73
  b = File.join(TEST_TMP_PATH, 'formula', 'b.rb')
72
- d = File.join(TEST_TMP_PATH, 'formula', 'abby' , 'lib', 'd.rb')
73
- e = File.join(TEST_TMP_PATH, 'formula', 'abby' , 'road', 'e.rb')
74
+ d = File.join(TEST_TMP_PATH, 'formula', 'abby', 'lib', 'd.rb')
75
+ e = File.join(TEST_TMP_PATH, 'formula', 'abby', 'road', 'e.rb')
74
76
 
75
77
  FileUtils.touch(a)
76
78
  FileUtils.touch(b)
@@ -0,0 +1,56 @@
1
+ # Encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe ChemistryKit::Configuration do
6
+
7
+ VALID_BASE_URL = 'http://google.com'
8
+ VALID_CONCURRENCY = 1
9
+ VALID_CONFIG_FILE = 'config.yaml'
10
+
11
+ before(:each) do
12
+ @valid_selenium_connect_hash = { log: 'evidence', host: 'localhost' }
13
+ @valid_config_hash = {
14
+ base_url: VALID_BASE_URL,
15
+ concurrency: VALID_CONCURRENCY,
16
+ selenium_connect: @valid_selenium_connect_hash
17
+ }
18
+ end
19
+
20
+ def validate_config(config)
21
+ config.concurrency.should eq VALID_CONCURRENCY
22
+ config.base_url.should eq VALID_BASE_URL
23
+ config.selenium_connect.should eq @valid_selenium_connect_hash
24
+ end
25
+
26
+ it 'should initialize with sane defaults' do
27
+ config = ChemistryKit::Configuration.new({})
28
+ config.concurrency.should eq 1
29
+ end
30
+
31
+ it 'should initialize with a hash of configurations' do
32
+ validate_config ChemistryKit::Configuration.new(@valid_config_hash)
33
+ end
34
+
35
+ it 'can be initialized staticlly with a yaml file' do
36
+ yaml_file = File.join(Dir.pwd, 'spec', 'support', VALID_CONFIG_FILE)
37
+ validate_config ChemistryKit::Configuration.initialize_with_yaml yaml_file
38
+ end
39
+
40
+ it 'should throw an exception for unsupported config variable' do
41
+ expect do
42
+ ChemistryKit::Configuration.new bad: 'config-value'
43
+ end.to raise_error ArgumentError, 'The config key: "bad" is unknown!'
44
+ end
45
+
46
+ it 'should throw an error if concurrency is configured and the host is not saucelabs' do
47
+ expect do
48
+ config_hash = {
49
+ base_url: VALID_BASE_URL,
50
+ concurrency: 2,
51
+ selenium_connect: @valid_selenium_connect_hash
52
+ }
53
+ ChemistryKit::Configuration.new(config_hash)
54
+ end.to raise_error ArgumentError, 'Concurrency is only supported for the host: "saucelabs"!'
55
+ end
56
+ end
@@ -1,15 +1,17 @@
1
+ # Encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe ChemistryKit::Formula::Base do
4
6
 
5
7
  before(:each) do
6
- #ideally we should mock the driver and not pass in nil
8
+ # ideally we should mock the driver and not pass in nil
7
9
  driver = nil
8
10
  @formula_base = ChemistryKit::Formula::Base.new(driver)
9
11
 
10
12
  Dir.mkdir(File.join(TEST_TMP_PATH, 'catalyst'))
11
13
  @data_file = File.join(TEST_TMP_PATH, 'catalyst', 'catalyst_data.csv')
12
- File.open(@data_file, 'w') {|f| f.write("first_key,first_value\nsecond_key,second_value") }
14
+ File.open(@data_file, 'w') { |f| f.write("first_key,first_value\nsecond_key,second_value") }
13
15
  @catalyst = ChemistryKit::Catalyst.new(@data_file)
14
16
  end
15
17
 
@@ -1,3 +1,5 @@
1
+ # Encoding: utf-8
2
+
1
3
  # This file was generated by the `rspec --init` command. Conventionally, all
2
4
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
5
  # Require this file using `require "spec_helper"` to ensure that it is only
@@ -8,10 +10,11 @@
8
10
  require 'rubygems'
9
11
  require 'bundler/setup'
10
12
  require 'fileutils'
11
- #not sure it this is the right way to include all the files under test.
13
+ # not sure it this is the right way to include all the files under test.
12
14
  require_relative '../lib/chemistrykit/cli/helpers/formula_loader'
13
15
  require_relative '../lib/chemistrykit/formula/base'
14
16
  require_relative '../lib/chemistrykit/catalyst'
17
+ require_relative '../lib/chemistrykit/configuration'
15
18
 
16
19
  TEST_TMP_PATH = File.join(Dir.pwd, 'build', 'tmp')
17
20
 
@@ -0,0 +1,7 @@
1
+ # Default Chemisty Kit Configuration File
2
+
3
+ base_url: http://google.com
4
+ concurrency: 1
5
+ selenium_connect:
6
+ log: 'evidence'
7
+ host: 'localhost'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chemistrykit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 3.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-06-28 00:00:00.000000000 Z
13
+ date: 2013-07-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thor
@@ -99,7 +99,7 @@ dependencies:
99
99
  requirements:
100
100
  - - ~>
101
101
  - !ruby/object:Gem::Version
102
- version: 2.0.0
102
+ version: 2.1.1
103
103
  type: :runtime
104
104
  prerelease: false
105
105
  version_requirements: !ruby/object:Gem::Requirement
@@ -107,7 +107,39 @@ dependencies:
107
107
  requirements:
108
108
  - - ~>
109
109
  - !ruby/object:Gem::Version
110
- version: 2.0.0
110
+ version: 2.1.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: parallel_tests
113
+ requirement: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ~>
117
+ - !ruby/object:Gem::Version
118
+ version: 0.15.0
119
+ type: :runtime
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ~>
125
+ - !ruby/object:Gem::Version
126
+ version: 0.15.0
127
+ - !ruby/object:Gem::Dependency
128
+ name: parallel
129
+ requirement: !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ~>
133
+ - !ruby/object:Gem::Version
134
+ version: 0.7.0
135
+ type: :runtime
136
+ prerelease: false
137
+ version_requirements: !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ~>
141
+ - !ruby/object:Gem::Version
142
+ version: 0.7.0
111
143
  - !ruby/object:Gem::Dependency
112
144
  name: rspec
113
145
  requirement: !ruby/object:Gem::Requirement
@@ -172,7 +204,23 @@ dependencies:
172
204
  - - ~>
173
205
  - !ruby/object:Gem::Version
174
206
  version: 10.0.3
175
- description: Automated build process
207
+ - !ruby/object:Gem::Dependency
208
+ name: rubocop
209
+ requirement: !ruby/object:Gem::Requirement
210
+ none: false
211
+ requirements:
212
+ - - ~>
213
+ - !ruby/object:Gem::Version
214
+ version: 0.9.0
215
+ type: :development
216
+ prerelease: false
217
+ version_requirements: !ruby/object:Gem::Requirement
218
+ none: false
219
+ requirements:
220
+ - - ~>
221
+ - !ruby/object:Gem::Version
222
+ version: 0.9.0
223
+ description: Now with concurrent tests
176
224
  email:
177
225
  - dave@arrgyle.com
178
226
  - jason@arrgyle.com
@@ -183,6 +231,7 @@ extra_rdoc_files: []
183
231
  files:
184
232
  - .gitignore
185
233
  - .rspec
234
+ - .rubocop.yml
186
235
  - .ruby-gemset
187
236
  - .ruby-version
188
237
  - .travis.yml
@@ -197,7 +246,9 @@ files:
197
246
  - chemistrykit.gemspec
198
247
  - features/brew.feature
199
248
  - features/catalyst.feature
249
+ - features/concurrency.feature
200
250
  - features/exit_status.feature
251
+ - features/global-config.feature
201
252
  - features/load_page_objects.feature
202
253
  - features/multi-config.feature
203
254
  - features/new.feature
@@ -210,7 +261,9 @@ files:
210
261
  - lib/chemistrykit/cli/formula.rb
211
262
  - lib/chemistrykit/cli/helpers/formula_loader.rb
212
263
  - lib/chemistrykit/cli/new.rb
264
+ - lib/chemistrykit/configuration.rb
213
265
  - lib/chemistrykit/formula/base.rb
266
+ - lib/chemistrykit/parallel_tests_mods.rb
214
267
  - lib/chemistrykit/shared_context.rb
215
268
  - lib/templates/beaker.tt
216
269
  - lib/templates/beaker_with_formula.tt
@@ -224,8 +277,10 @@ files:
224
277
  - lib/templates/formula.tt
225
278
  - spec/chemistrykit/catalyst_spec.rb
226
279
  - spec/chemistrykit/cli/helpers/formula_loader_spec.rb
280
+ - spec/chemistrykit/configuration_spec.rb
227
281
  - spec/chemistrykit/formula/base_spec.rb
228
282
  - spec/spec_helper.rb
283
+ - spec/support/config.yaml
229
284
  homepage: https://github.com/arrgyle/chemistrykit
230
285
  licenses:
231
286
  - MIT
@@ -247,7 +302,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
247
302
  version: '0'
248
303
  segments:
249
304
  - 0
250
- hash: 3509311149288293585
305
+ hash: -488486412254778435
251
306
  requirements: []
252
307
  rubyforge_project:
253
308
  rubygems_version: 1.8.25
@@ -258,7 +313,9 @@ summary: A simple and opinionated web testing framework for Selenium that follow
258
313
  test_files:
259
314
  - features/brew.feature
260
315
  - features/catalyst.feature
316
+ - features/concurrency.feature
261
317
  - features/exit_status.feature
318
+ - features/global-config.feature
262
319
  - features/load_page_objects.feature
263
320
  - features/multi-config.feature
264
321
  - features/new.feature
@@ -266,5 +323,7 @@ test_files:
266
323
  - features/support/env.rb
267
324
  - spec/chemistrykit/catalyst_spec.rb
268
325
  - spec/chemistrykit/cli/helpers/formula_loader_spec.rb
326
+ - spec/chemistrykit/configuration_spec.rb
269
327
  - spec/chemistrykit/formula/base_spec.rb
270
328
  - spec/spec_helper.rb
329
+ - spec/support/config.yaml