chemistrykit 0.1.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,7 +3,7 @@
3
3
  .bundle
4
4
  pkg/*
5
5
  tags
6
- test/tmp/
6
+ tmp/
7
7
  Gemfile.lock
8
8
 
9
9
  # Installed gems
@@ -11,3 +11,9 @@ vendor/bundle
11
11
 
12
12
  # Temp Files
13
13
  *.swp
14
+
15
+ # Testing files
16
+ tmp/
17
+
18
+ # Dave's junk
19
+ .rvmrc
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- v0.0.1
1
+ v0.1.1
2
2
  ======
3
3
 
4
4
  * `ckit new` generates a chemistrykit project
data/README.md CHANGED
@@ -1,119 +1,32 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/chemistrykit.png)](http://badge.fury.io/rb/chemistrykit)
2
- [![Dependency Status](https://gemnasium.com/arrgyle/chemistrykit.png)](https://gemnasium.com/arrgyle/chemistrykit)
2
+ [![Code Climate](https://codeclimate.com/github/arrgyle/chemistrykit.png)](https://codeclimate.com/github/arrgyle/chemistrykit)
3
3
 
4
4
  ChemistryKit
5
5
  ============================================================
6
6
 
7
- ### A simple and opinionated web testing framework for Selenium built in Ruby
7
+ ### A simple and opinionated web testing framework for Selenium WebDriver
8
8
 
9
- This framework was designed to help you get started acceptance testing quickly and to help keep your momentum going by following convention over configuration.
9
+ This framework was designed to help you get started with Selenium WebDriver quickly, to grow as needed, and to avoid common pitfalls by following convention over configuration.
10
10
 
11
- This product is the result of years of experience and real world trial and error.
11
+ ChemistryKit's inspiration comes from the Saunter Selenium framework which is available in Python and PHP. You can find more about it [here](http://element34.ca/products/saunter).
12
12
 
13
- For a Python and PHP version, check out [py.saunter and saunter.php](https://github.com/Element-34/). ChemistryKit's inspiration comes from Saunter.
14
-
15
- ## Installation
16
-
17
- Add this line to your application's Gemfile:
18
-
19
- gem 'chemistrykit'
20
-
21
- And then execute:
22
-
23
- $ bundle
24
-
25
- Or install it yourself as:
13
+ ## Getting Started
26
14
 
27
15
  $ gem install chemistrykit
16
+ $ ckit new framework_name
28
17
 
29
- ## Contributing
30
-
31
- 1. Fork it
32
- 2. Create your feature branch (`git checkout -b my-new-feature`)
33
- 3. Commit your changes (`git commit -am 'Add some feature'`)
34
- 4. Push to the branch (`git push origin my-new-feature`)
35
- 5. Create new Pull Request
36
-
37
- Staying in Character
38
- --------------
39
- These things => Are called these things
40
- Specs/Test scripts => Beakers
41
- Page Objects => Formulas
42
- Log Output => Evidence
43
-
44
- Spec Discovery
45
- --------------
46
-
47
- ChemistryKit is built on top of RSpec. All specs are in the _beaker_ directory and end in _beaker.rb. Rather than being discovered via class or file name as some systems they are by identified by tag.
48
-
49
- ```ruby
50
- it 'with invalid credentials', :depth => 'shallow' do
51
-
52
- end
53
-
54
- it 'with invalid credentials', :depth => 'deep' do
55
-
56
- end
57
- ````
58
- All specs should have at least a :depth tag. The depth should either be 'shallow' or 'deep'. Shallow specs are the ones that are the absolute-must-pass ones. And there will only be a few of them typically. Deep ones are everything else.
59
-
60
- You can add multiple tags as well.
61
-
62
- ```ruby
63
- it 'with invalid credentials', :depth => 'shallow', :authentication => true do
18
+ This will create a new folder with the name you provide and it will contain all of the bits you'll need to get started.
64
19
 
65
- end
66
- ````
20
+ $ cd framework_name
21
+ $ ckit generate beaker beaker_name
67
22
 
68
- By default ChemistryKit will discover and run the _:depth => 'shallow'_ scripts. To run different ones you use the --tag option.
23
+ This will generate a beaker file (a.k.a. test script) with the name you provide (e.g. hello_world). Add your Selenium actions and assertions to it.
69
24
 
70
- ckit --tag authentication
25
+ $ ckit brew
71
26
 
72
- ckit --tag depth:shallow --tag authentication
27
+ This will run ckit and execute your beakers. By default it will run the tests locally by default. But you can change where the tests run and all other relevant bits in \_config.yaml. You can find out more about this [here](https://github.com/arrgyle/chemistrykit/wiki/Configs).
73
28
 
74
- To exlude a tag, put a ~ in front of it.
75
29
 
76
- ckit --tag depth:shallow --tag ~authentication
77
-
78
- A useful trick when developing a script is to use a custom tag.
79
-
80
- ```ruby
81
- it 'with invalid credentials', :depth => 'shallow', :flyingmonkeybutt => true do
82
-
83
- end
84
- ````
85
-
86
- Execution Order
87
- ---------------
88
-
89
- Chemistry Kit executes specs in a random order. This is intentional. Knowing the order a spec will be executed in allows for dependencies between them to creep in. Sometimes unintentionally. By having them go in a random order parallelization becomes a much easier.
90
-
91
- Facade all the Things!
92
- ----------------------
93
-
94
- Chemistry Kit injects itself between you and WebDriver and various other future components. You should also inject something between your project and Chemistry Kit. Chemistry Kit has started this for you in the following ways:
95
-
96
- - _config/requires.rb: @driver inside your scripts comes from the first line in this file
97
-
98
- Configuration
99
- -------------
100
-
101
- Configuration should not be in your script. Nor should it be commit to version control.
102
-
103
- Before and After
104
- ----------------
105
-
106
- Chemistry Kit uses the 4-phase model for scripts with a chunk of code that gets run before and after each method. By default, it does nothing more than launch a browser instance that your configuration says you want. If you want to do something more than that, just add it to your spec.
107
-
108
- ```ruby
109
- before(:each) do
110
- # something here
111
- end
112
- ```
113
-
114
- You can even nest them inside different describe/context blocks and they will get executed from the outside-in.
115
-
116
- Logs and CI Integration
117
- -----------------------
30
+ ## Contributing
118
31
 
119
- Each run of Chemistry Kit creates a timestamped directory inside the evidence directory. And in there will be the full set of JUnit Ant XML files. You don't point your CI server at this timestamped directory. Instead you want to point at the _latest_ directory which is a symlink to the latest timestamp directory.
32
+ This project conforms to the [neverstopbuilding/craftsmanship](https://github.com/neverstopbuilding/craftsmanship) guidelines. Please see them for details.
data/bin/ckit CHANGED
@@ -1,8 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "rubygems" # Allows for Ruby versions older than 1.9.3
4
- require 'chemistrykit/cli/cli'
5
-
6
- exit_code = ChemistryKit::CLI::CKitCLI.start
7
- exit_code.kind_of?(Integer) ? exit(exit_code) : exit(0)
3
+ require 'chemistrykit'
8
4
 
5
+ ChemistryKit::CLI::CKitCLI.start
data/chemistrykit.gemspec CHANGED
@@ -1,16 +1,12 @@
1
- # -*- encoding: utf-8 -*-
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'chemistrykit/version'
5
-
6
1
  Gem::Specification.new do |s|
7
2
  s.name = "chemistrykit"
8
- s.version = ChemistryKit::VERSION
3
+ s.version = "1.0.0"
9
4
  s.platform = Gem::Platform::RUBY
10
5
  s.authors = ["Dave Haeffner", "Jason Wieringa"]
11
6
  s.email = ["dave@arrgyle.com", "jason@arrgyle.com"]
12
7
  s.homepage = "https://github.com/arrgyle/chemistrykit"
13
- s.summary = "Simple and opinionated web testing framework for Selenium that follows convention over configuration -- borrowed from Saunter, built in Ruby"
8
+ s.summary = "A simple and opinionated web testing framework for Selenium that follows convention over configuration."
9
+ s.description = "A major refactoring along with a revamping of the yaml config structure. See the github page for details."
14
10
  s.license = 'MIT'
15
11
 
16
12
  s.files = `git ls-files`.split($/)
@@ -25,8 +21,11 @@ Gem::Specification.new do |s|
25
21
  s.add_dependency "selenium-webdriver", "~> 2.29.0"
26
22
  s.add_dependency "ci_reporter", "~> 1.8.3"
27
23
  s.add_dependency "rest-client", "~> 1.6.7"
24
+ s.add_dependency "selenium-connect", "~> 1.8.0"
28
25
 
29
26
  s.add_development_dependency "rspec", "~> 2.12.0"
27
+ s.add_development_dependency "aruba", "~> 0.5.1"
28
+ s.add_development_dependency "cucumber", "~> 1.2.1"
30
29
  s.add_development_dependency "rake", "~> 10.0.3"
31
30
 
32
31
  s.extensions = 'ext/mkrf_conf.rb'
@@ -0,0 +1,50 @@
1
+ Feature: Brewing a ChemistryKit project
2
+
3
+ Running ckit brew runs the suite of tests.
4
+
5
+ ckit can run in a couple of different ways:
6
+ 1. Locally
7
+ 2. With Sauce Ondemand
8
+
9
+ Background: Setup the project
10
+ Given I run `ckit new booker`
11
+ And I cd to "booker"
12
+ And a file named "formulas/bookie.rb" with:
13
+ """
14
+ module Formulas
15
+ class Bookie
16
+ def initialize(driver)
17
+ @driver = driver
18
+ end
19
+
20
+ def open(url)
21
+ @driver.get url
22
+ end
23
+ end
24
+ end
25
+ """
26
+ And a file named "beaker/bookie_beaker.rb" with:
27
+ """
28
+ describe "Bookie", :depth => 'shallow' do
29
+ let(:book) { Formulas::Bookie.new(@driver) }
30
+
31
+ it "loads an external web page" do
32
+ book.open "http://www.google.com"
33
+ end
34
+ end
35
+ """
36
+
37
+ Scenario Outline: Run All Configurations
38
+ When I overwrite _config.yaml with:
39
+ """
40
+ host: '<%= <hostname> %>'
41
+ sauce_username: 'testing_arrgyle'
42
+ sauce_api_key: 'ab7a6e17-16df-42d2-9ef6-c8d2539cc38a'
43
+ """
44
+ When I run `ckit brew`
45
+ Then the stdout should contain "1 example, 0 failures"
46
+
47
+ Examples:
48
+ | hostname |
49
+ | "localhost" |
50
+ # | "saucelabs" |
@@ -0,0 +1,17 @@
1
+ Feature: ckit new
2
+
3
+ Run "ckit new <project_name>" to generate a new ChemistryKit project
4
+
5
+ Background: Running ckit new
6
+ When I run `bundle exec ckit new booker`
7
+ And I cd to "booker"
8
+
9
+ @announce
10
+ Scenario: Test Harness is created
11
+ Then the following directories should exist:
12
+ | beakers |
13
+ | formulas |
14
+ | evidence |
15
+ And the following files should exist:
16
+ | _config.yaml |
17
+ | .rspec |
@@ -0,0 +1,7 @@
1
+ require 'erb'
2
+
3
+ #Modified from https://github.com/cucumber/aruba/blob/master/lib/aruba/cucumber.rb
4
+ When /^I overwrite ([^"]*) with:$/ do |file_name, file_content|
5
+ data = ERB.new(file_content)
6
+ overwrite_file(file_name, data.result)
7
+ end
@@ -0,0 +1,6 @@
1
+ require 'aruba/cucumber'
2
+
3
+ Before do
4
+ @aruba_timeout_seconds = 90
5
+ @dirs = ["tmp"]
6
+ end
@@ -0,0 +1 @@
1
+ require 'chemistrykit/cli/cli'
@@ -1,31 +1,59 @@
1
- require "thor"
2
- require 'chemistrykit/cli/generators'
3
- require 'chemistrykit/cli/new'
1
+ require 'thor'
4
2
  require 'rspec'
3
+ require 'ci/reporter/rake/rspec_loader'
4
+ require 'chemistrykit/cli/new'
5
+ require 'chemistrykit/cli/formula'
6
+ require 'chemistrykit/cli/beaker'
5
7
 
6
8
  module ChemistryKit
7
9
  module CLI
10
+
11
+ class Generate < Thor
12
+ register(ChemistryKit::CLI::FormulaGenerator, 'formula', 'formula [NAME]', 'generates a page object')
13
+ register(ChemistryKit::CLI::BeakerGenerator, 'beaker', 'beaker [NAME]', 'generates a beaker')
14
+ end
15
+
8
16
  class CKitCLI < Thor
17
+ register(ChemistryKit::CLI::New, 'new', 'new [NAME]', 'Creates a new ChemistryKit project')
9
18
  check_unknown_options!
10
19
  default_task :help
11
20
 
12
- register(ChemistryKit::CLI::Generate, 'generate', 'generate <formula> or <beaker> [NAME]', 'generates a page object or script')
13
- register(ChemistryKit::CLI::New, 'new', 'new [NAME]', 'Creates a new ChemistryKit project')
21
+ desc "generate SUBCOMMAND", "generate <formula> or <beaker> [NAME]"
22
+ subcommand "generate", Generate
14
23
 
15
- desc "brew", "Run the Chemistry kit"
16
- long_desc <<-LONGDESC
17
- Runs the Chemistry kit
18
- LONGDESC
24
+ desc "brew", "Run ChemistryKit"
19
25
  method_option :tag, :default => ['depth:shallow'], :type => :array
20
26
  def brew
21
- require 'chemistrykit/config'
22
27
  require 'chemistrykit/shared_context'
23
- require 'ci/reporter/rake/rspec_loader'
28
+ load_page_objects
29
+ set_logs_dir
30
+ turn_stdout_stderr_on_off
31
+ setup_tags
32
+ rspec_config
33
+ symlink_latest_report
34
+ run_rspec
35
+ end
24
36
 
25
- # Wow... that feels like a hack...
37
+ protected
38
+
39
+ def load_page_objects
26
40
  Dir["#{Dir.getwd}/formulas/*.rb"].each {|file| require file }
41
+ end
42
+
43
+ def log_timestamp
44
+ @log_timestamp = Time.now.strftime("%Y-%m-%d-%H-%M-%S")
45
+ end
46
+
47
+ def set_logs_dir
48
+ ENV['CI_REPORTS'] = File.join(Dir.getwd, 'evidence', log_timestamp)
49
+ end
27
50
 
28
- tags = {}
51
+ def turn_stdout_stderr_on_off
52
+ ENV['CI_CAPTURE'] = 'on' #CHEMISTRY_CONFIG['chemistrykit']['capture_output'] ? 'on' : 'off'
53
+ end
54
+
55
+ def setup_tags
56
+ @tags = {}
29
57
  options['tag'].each do |tag|
30
58
  filter_type = tag.start_with?('~') ? :exclusion_filter : :filter
31
59
 
@@ -34,42 +62,40 @@ module ChemistryKit
34
62
 
35
63
  value = true if value.nil?
36
64
 
37
- tags[filter_type] ||= {}
38
- tags[filter_type][name] = value
65
+ @tags[filter_type] ||= {}
66
+ @tags[filter_type][name] = value
39
67
  end
68
+ end
40
69
 
41
- log_timestamp = Time.now.strftime("%Y-%m-%d-%H-%M-%S")
42
- FileUtils.makedirs(File.join(Dir.getwd, 'evidence', log_timestamp))
43
-
44
- ENV['CI_REPORTS'] = File.join(Dir.getwd, 'evidence', log_timestamp)
45
- ENV['CI_CAPTURE'] = CHEMISTRY_CONFIG['chemistrykit']['capture_output'] ? 'on' : 'off'
46
-
70
+ def rspec_config #These bits aren't working properly
47
71
  RSpec.configure do |c|
48
- c.filter_run tags[:filter] unless tags[:filter].nil?
49
- c.filter_run_excluding tags[:exclusion_filter] unless tags[:exclusion_filter].nil?
72
+ c.filter_run @tags[:filter] unless @tags[:filter].nil?
73
+ c.filter_run_excluding @tags[:exclusion_filter] unless @tags[:exclusion_filter].nil?
50
74
  c.include ChemistryKit::SharedContext
51
75
  c.order = 'random'
52
76
  c.default_path = 'beakers'
53
77
  c.pattern = '**/*_beaker.rb'
54
78
  end
79
+ end
55
80
 
56
- exit_code = RSpec::Core::Runner.run(Dir.glob(File.join(Dir.getwd)))
57
-
58
- if RUBY_PLATFORM.downcase.include?("mswin")
81
+ def symlink_latest_report
82
+ case # Depending on platform, symlinks are done differently
83
+ when RUBY_PLATFORM.downcase.include?("mswin")
59
84
  require 'win32/dir'
60
-
61
85
  if Dir.junction?(File.join(Dir.getwd, 'evidence', 'latest'))
62
86
  File.delete(File.join(Dir.getwd, 'evidence', 'latest'))
63
87
  end
64
- Dir.create_junction(File.join(Dir.getwd, 'evidence', 'latest'), File.join(Dir.getwd, 'evidence', log_timestamp))
88
+ Dir.create_junction(File.join(Dir.getwd, 'evidence', 'latest'), File.join(Dir.getwd, 'evidence', @log_timestamp))
65
89
  else
66
- if File.symlink?(File.join(Dir.getwd, 'evidence', 'latest'))
67
- File.delete(File.join(Dir.getwd, 'evidence', 'latest'))
68
- end
69
- File.symlink(File.join(Dir.getwd, 'evidence', log_timestamp), File.join(Dir.getwd, 'evidence', 'latest'))
90
+ # This will work on any unix like platform
91
+ FileUtils.ln_sf(File.join(Dir.getwd, 'evidence', @log_timestamp), File.join(Dir.getwd, 'evidence', 'latest'))
70
92
  end
71
- exit_code
72
93
  end
94
+
95
+ def run_rspec
96
+ RSpec::Core::Runner.run(Dir.glob(File.join(Dir.getwd)))
97
+ end
98
+
73
99
  end
74
100
  end
75
101
  end
@@ -2,7 +2,7 @@ require 'thor/group'
2
2
 
3
3
  module ChemistryKit
4
4
  module CLI
5
- class PageObjectGenerator < Thor::Group
5
+ class FormulaGenerator < Thor::Group
6
6
  include Thor::Actions
7
7
 
8
8
  argument :name
@@ -12,8 +12,8 @@ module ChemistryKit
12
12
  end
13
13
 
14
14
  def copy_file
15
- template "page_object.tt", "./formulas/#{name}.rb"
16
- template "beaker_with_page_object.tt", "./beakers/#{name}_beaker.rb"
15
+ template "formula.tt", "./formulas/#{name}.rb"
16
+ template "beaker_with_formula.tt", "./beakers/#{name}_beaker.rb"
17
17
  end
18
18
 
19
19
  end
@@ -1,5 +1,5 @@
1
1
  require 'thor'
2
- require 'chemistrykit/cli/page_object'
2
+ require 'chemistrykit/cli/formula'
3
3
  require 'chemistrykit/cli/beaker'
4
4
 
5
5
  module ChemistryKit
@@ -16,7 +16,7 @@ module ChemistryKit
16
16
  end
17
17
 
18
18
  def notify
19
- say "Your project name has been added to _config/chemistrykit.yaml"
19
+ say "Your test harness has been created."
20
20
  end
21
21
 
22
22
  end
@@ -1,94 +1,21 @@
1
+ require 'selenium-connect'
1
2
  require 'rspec/core/shared_context'
2
- require File.join(Dir.getwd, '_config', 'requires')
3
- require 'restclient'
4
3
 
5
4
  module ChemistryKit
6
5
  module SharedContext
7
6
  extend RSpec::Core::SharedContext
8
7
 
9
- def set_sauce_keys
10
- @magic_keys = [
11
- :caller,
12
- :description,
13
- :description_args,
14
- :example_group,
15
- :example_group_block,
16
- :execution_result,
17
- :file_path,
18
- :full_description,
19
- :line_number,
20
- :location
21
- ]
22
- end
23
-
24
- def capabilities
25
- capabilities = Selenium::WebDriver::Remote::Capabilities.send(CHEMISTRY_CONFIG['webdriver']['browser'])
26
- end
27
-
28
- def driver_for_server(executor, capabilities)
29
- @driver = ChemistryKit::WebDriver::Driver.new(:url => executor, :desired_capabilities => capabilities)
30
- end
31
-
32
- def driver_for_local
33
- @driver = Selenium::WebDriver.for(CHEMISTRY_CONFIG['webdriver']['browser'].to_sym)
34
- end
35
-
36
- def executor
37
- if CHEMISTRY_CONFIG['saucelabs']['ondemand']
38
- "http://#{SAUCE_CONFIG['username']}:#{SAUCE_CONFIG['key']}@ondemand.saucelabs.com:80/wd/hub"
39
- else
40
- 'http://' + CHEMISTRY_CONFIG['webdriver']['server_host'] + ":" + CHEMISTRY_CONFIG['webdriver']['server_port'].to_s + '/wd/hub'
8
+ SeleniumConnect.configure do |c|
9
+ c.config_file = File.join(Dir.getwd, '_config.yaml')
41
10
  end
42
- end
43
11
 
44
- before(:each) do
45
- case
46
- when CHEMISTRY_CONFIG['chemistrykit']['run_locally']
47
- driver_for_local
48
- when CHEMISTRY_CONFIG['saucelabs']['ondemand']
49
- if CHEMISTRY_CONFIG['webdriver']['browser'] != 'chrome'
50
- capabilities[:version] = CHEMISTRY_CONFIG['saucelabs']['version']
51
- else
52
- capabilities[:platform] = CHEMISTRY_CONFIG['saucelabs']['platform']
53
- end
54
- set_sauce_keys
55
- executor
56
- driver_for_server(executor, capabilities)
57
- else
58
- executor
59
- driver_for_server(executor, capabilities)
12
+ before(:each) do
13
+ @driver = SeleniumConnect.start
60
14
  end
61
- end
62
15
 
63
- after(:each) do
64
- if CHEMISTRY_CONFIG['saucelabs']['ondemand']
65
- session_id = @driver.session_id
16
+ after(:each) do
17
+ SeleniumConnect.finish
66
18
  end
67
19
 
68
- @driver.quit
69
-
70
- if CHEMISTRY_CONFIG['saucelabs']['ondemand']
71
- # puts self.example.metadata
72
- example_tags = self.example.metadata.collect{ |k, v|
73
- if not @magic_keys.include?(k)
74
- if v.to_s == 'true'
75
- k
76
- else
77
- "#{k}:#{v}"
78
- end
79
- end
80
- }
81
- example_tags.compact!
82
- # puts self.example.exception
83
- payload = {
84
- :tags => example_tags,
85
- :name => self.example.metadata[:full_description],
86
- :passed => self.example.exception ? false : true
87
- }
88
- api_url = "http://#{SAUCE_CONFIG['username']}:#{SAUCE_CONFIG['key']}@saucelabs.com:80/rest/v1/#{SAUCE_CONFIG['username']}/jobs/#{session_id}"
89
- RestClient.put api_url, payload.to_json, {:content_type => :json}
90
- # puts payload.to_json
91
- end
92
- end
93
- end
94
- end
20
+ end #SharedContext
21
+ end #ChemistryKit
@@ -0,0 +1,6 @@
1
+ describe "<%= name.capitalize %>", :depth => 'shallow' do
2
+
3
+ let(:<%= name %>) { Formulas::<%= name.capitalize %>.new(@driver) }
4
+
5
+
6
+ end
@@ -0,0 +1,23 @@
1
+ #Setup & Debugging
2
+ jar:
3
+ log:
4
+
5
+
6
+ #Where to run your tests
7
+ host: 'localhost'
8
+ port: #set to 4444 by default
9
+
10
+
11
+ #Browser & Host
12
+ browser: 'firefox'
13
+ browser_path:
14
+ profile_path:
15
+ profile_name:
16
+
17
+
18
+ #Saucelabs
19
+ os:
20
+ sauce_username:
21
+ sauce_api_key:
22
+ browser_version:
23
+ description:
@@ -1,4 +1,4 @@
1
- module PageObjects
1
+ module Formulas
2
2
  class <%= name.capitalize %>
3
3
 
4
4
  def initialize(driver)
data/readme2.md ADDED
@@ -0,0 +1,78 @@
1
+ Spec Discovery
2
+ --------------
3
+
4
+ ChemistryKit is built on top of RSpec. All specs are in the _beaker_ directory and end in _beaker.rb. Rather than being discovered via class or file name as some systems they are by identified by tag.
5
+
6
+ ```ruby
7
+ it 'with invalid credentials', :depth => 'shallow' do
8
+
9
+ end
10
+
11
+ it 'with invalid credentials', :depth => 'deep' do
12
+
13
+ end
14
+ ````
15
+ All specs should have at least a :depth tag. The depth should either be 'shallow' or 'deep'. Shallow specs are the ones that are the absolute-must-pass ones. And there will only be a few of them typically. Deep ones are everything else.
16
+
17
+ You can add multiple tags as well.
18
+
19
+ ```ruby
20
+ it 'with invalid credentials', :depth => 'shallow', :authentication => true do
21
+
22
+ end
23
+ ````
24
+
25
+ By default ChemistryKit will discover and run the _:depth => 'shallow'_ scripts. To run different ones you use the --tag option.
26
+
27
+ ckit brew --tag authentication
28
+
29
+ ckit brew --tag depth:shallow --tag authentication
30
+
31
+ To exlude a tag, put a ~ in front of it.
32
+
33
+ ckit brew --tag depth:shallow --tag ~authentication
34
+
35
+ A useful trick when developing a script is to use a custom tag.
36
+
37
+ ```ruby
38
+ it 'with invalid credentials', :depth => 'shallow', :flyingmonkeybutt => true do
39
+
40
+ end
41
+ ````
42
+
43
+ Execution Order
44
+ ---------------
45
+
46
+ Chemistry Kit executes specs in a random order. This is intentional. Knowing the order a spec will be executed in allows for dependencies between them to creep in. Sometimes unintentionally. By having them go in a random order parallelization becomes a much easier.
47
+
48
+ Facade all the Things!
49
+ ----------------------
50
+
51
+ Chemistry Kit injects itself between you and WebDriver and various other future components. You should also inject something between your project and Chemistry Kit. Chemistry Kit has started this for you in the following ways:
52
+
53
+ - _config/requires.rb: @driver inside your scripts comes from the first line in this file
54
+
55
+ Configuration
56
+ -------------
57
+
58
+ Configuration should not be in your script. Nor should it be commit to version control.
59
+
60
+ Before and After
61
+ ----------------
62
+
63
+ Chemistry Kit uses the 4-phase model for scripts with a chunk of code that gets run before and after each method. By default, it does nothing more than launch a browser instance that your configuration says you want. If you want to do something more than that, just add it to your spec.
64
+
65
+ ```ruby
66
+ before(:each) do
67
+ # something here
68
+ end
69
+ ```
70
+
71
+ You can even nest them inside different describe/context blocks and they will get executed from the outside-in.
72
+
73
+ Logs and CI Integration
74
+ -----------------------
75
+
76
+ Each run of Chemistry Kit creates a timestamped directory inside the _evidence_ directory. And in there will be the full set of JUnit Ant XML files. You don't point your CI server at this timestamped directory. Instead you want to point at the _latest_ directory which is a symlink to the latest timestamp directory.
77
+
78
+
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: 0.1.1
4
+ version: 1.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-02-02 00:00:00.000000000 Z
13
+ date: 2013-06-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thor
@@ -92,6 +92,22 @@ dependencies:
92
92
  - - ~>
93
93
  - !ruby/object:Gem::Version
94
94
  version: 1.6.7
95
+ - !ruby/object:Gem::Dependency
96
+ name: selenium-connect
97
+ requirement: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ~>
101
+ - !ruby/object:Gem::Version
102
+ version: 1.8.0
103
+ type: :runtime
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 1.8.0
95
111
  - !ruby/object:Gem::Dependency
96
112
  name: rspec
97
113
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +124,38 @@ dependencies:
108
124
  - - ~>
109
125
  - !ruby/object:Gem::Version
110
126
  version: 2.12.0
127
+ - !ruby/object:Gem::Dependency
128
+ name: aruba
129
+ requirement: !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ~>
133
+ - !ruby/object:Gem::Version
134
+ version: 0.5.1
135
+ type: :development
136
+ prerelease: false
137
+ version_requirements: !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ~>
141
+ - !ruby/object:Gem::Version
142
+ version: 0.5.1
143
+ - !ruby/object:Gem::Dependency
144
+ name: cucumber
145
+ requirement: !ruby/object:Gem::Requirement
146
+ none: false
147
+ requirements:
148
+ - - ~>
149
+ - !ruby/object:Gem::Version
150
+ version: 1.2.1
151
+ type: :development
152
+ prerelease: false
153
+ version_requirements: !ruby/object:Gem::Requirement
154
+ none: false
155
+ requirements:
156
+ - - ~>
157
+ - !ruby/object:Gem::Version
158
+ version: 1.2.1
111
159
  - !ruby/object:Gem::Dependency
112
160
  name: rake
113
161
  requirement: !ruby/object:Gem::Requirement
@@ -124,7 +172,8 @@ dependencies:
124
172
  - - ~>
125
173
  - !ruby/object:Gem::Version
126
174
  version: 10.0.3
127
- description:
175
+ description: A major refactoring along with a revamping of the yaml config structure.
176
+ See the github page for details.
128
177
  email:
129
178
  - dave@arrgyle.com
130
179
  - jason@arrgyle.com
@@ -145,26 +194,26 @@ files:
145
194
  - bin/ckit
146
195
  - chemistrykit.gemspec
147
196
  - ext/mkrf_conf.rb
148
- - lib/chemistry_kit.rb
197
+ - features/brew.feature
198
+ - features/new.feature
199
+ - features/step_definitions/modified_steps.rb
200
+ - features/support/env.rb
201
+ - lib/chemistrykit.rb
149
202
  - lib/chemistrykit/cli/beaker.rb
150
203
  - lib/chemistrykit/cli/cli.rb
204
+ - lib/chemistrykit/cli/formula.rb
151
205
  - lib/chemistrykit/cli/generators.rb
152
206
  - lib/chemistrykit/cli/new.rb
153
- - lib/chemistrykit/cli/page_object.rb
154
- - lib/chemistrykit/config.rb
155
207
  - lib/chemistrykit/shared_context.rb
156
- - lib/chemistrykit/version.rb
157
- - lib/chemistrykit/webdriver.rb
158
208
  - lib/templates/beaker.tt
159
- - lib/templates/beaker_with_page_object.tt
209
+ - lib/templates/beaker_with_formula.tt
160
210
  - lib/templates/chemistrykit/.rspec
161
- - lib/templates/chemistrykit/_config/chemistrykit.yaml.tt
162
- - lib/templates/chemistrykit/_config/requires.rb
163
- - lib/templates/chemistrykit/_config/saucelabs.yaml.example
164
- - lib/templates/chemistrykit/beakers/.empty_directory
165
- - lib/templates/chemistrykit/evidence/.empty_directory
166
- - lib/templates/chemistrykit/formulas/.empty_directory
167
- - lib/templates/page_object.tt
211
+ - lib/templates/chemistrykit/_config.yaml.tt
212
+ - lib/templates/chemistrykit/beakers/.gitkeep
213
+ - lib/templates/chemistrykit/evidence/.gitkeep
214
+ - lib/templates/chemistrykit/formulas/.gitkeep
215
+ - lib/templates/formula.tt
216
+ - readme2.md
168
217
  - spec/chemistrykit/cli_spec.rb
169
218
  homepage: https://github.com/arrgyle/chemistrykit
170
219
  licenses:
@@ -190,7 +239,11 @@ rubyforge_project:
190
239
  rubygems_version: 1.8.24
191
240
  signing_key:
192
241
  specification_version: 3
193
- summary: Simple and opinionated web testing framework for Selenium that follows convention
194
- over configuration -- borrowed from Saunter, built in Ruby
242
+ summary: A simple and opinionated web testing framework for Selenium that follows
243
+ convention over configuration.
195
244
  test_files:
245
+ - features/brew.feature
246
+ - features/new.feature
247
+ - features/step_definitions/modified_steps.rb
248
+ - features/support/env.rb
196
249
  - spec/chemistrykit/cli_spec.rb
data/lib/chemistry_kit.rb DELETED
@@ -1 +0,0 @@
1
- require 'chemistrykit/version'
@@ -1,17 +0,0 @@
1
- require 'yaml'
2
-
3
- module ChemistryKit
4
- CHEMISTRY_CONFIG = YAML.load(ERB.new(File.read(File.join(Dir.getwd, '_config', 'chemistrykit.yaml'))).result)
5
-
6
- case
7
- when CHEMISTRY_CONFIG['saucelabs']['ondemand'] && CHEMISTRY_CONFIG['chemistrykit']['run_locally']
8
- puts "When Sauce Labs OnDemand is enabled, run_locally should be set to false"
9
- exit
10
- when CHEMISTRY_CONFIG['saucelabs']['ondemand']
11
- begin
12
- SAUCE_CONFIG = YAML.load(File.read(File.join(Dir.getwd, '_config', 'saucelabs.yaml')))
13
- rescue Errno::ENOENT
14
- abort('To use Sauce Labs OnDemand you need a _config/saucelabs.yaml with your username and key')
15
- end
16
- end
17
- end
@@ -1,3 +0,0 @@
1
- module ChemistryKit
2
- VERSION = "0.1.1"
3
- end
@@ -1,9 +0,0 @@
1
- require 'selenium/webdriver'
2
-
3
- module ChemistryKit
4
- module WebDriver
5
- class Driver < Selenium::WebDriver::Remote::Bridge
6
-
7
- end
8
- end
9
- end
@@ -1,7 +0,0 @@
1
- describe "<%= name.capitalize %>", :depth => 'shallow' do
2
-
3
- before(:each) do
4
- @<%= name %> = PageObjects::<%= name.capitalize %>.new(@driver)
5
- end
6
-
7
- end
@@ -1,18 +0,0 @@
1
- ---
2
- chemistrykit: {
3
- project: <%= name.capitalize %>,
4
- capture_output: false,
5
- run_locally: true
6
- }
7
-
8
- webdriver: {
9
- browser: firefox,
10
- server_host: localhost,
11
- server_port: 4444
12
- }
13
-
14
- saucelabs: {
15
- ondemand: false,
16
- version: 18,
17
- platform: Windows 2008
18
- }
@@ -1 +0,0 @@
1
- require 'chemistrykit/webdriver'
@@ -1,3 +0,0 @@
1
- ---
2
- username: yourusername
3
- key: yourkey