smokes 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57c5ae0ef4450c8b357d622442a8f6f00fb24b1e9a28df3520d0fd71597deb4a
4
- data.tar.gz: 6f939e628421decd104f1cb32ce78e0941e793fa73c513edffe02d4cb19fb8f0
3
+ metadata.gz: a00a8fba3ef5752b9660e01097422a8e757ce49dc5502b3d742b4be774a4ce43
4
+ data.tar.gz: b50f3e0e85d82f2152a09a9ca7ef6c2f5a1e8023d115902cefc5d8ba0107373d
5
5
  SHA512:
6
- metadata.gz: 2b27e60b1f421dd294ac4b8e7956f63405a632dbcc8436cb26df7b63d57b0560f3b894ec325922d7713dc02319a7d578caabdfaa267f2c966f7341777bed971f
7
- data.tar.gz: d130e14021a55d07e7108f728fd1af034d32fe4cdc4f7cfc473b9ac186a4e23a8b2ac68940185ac2ef44449c3f1cf295183b23d29603e7fcdaca4358de2be3e7
6
+ metadata.gz: fab328c240b3232369c09a5efb7927609e6cd14d655305aa4c27e83aee36c72b35edd07eda3110e19f8443ef4f15468fd954423c6b63148cb00bc480b18107fb
7
+ data.tar.gz: ed34aadc94f6bf59f9f7526f2dc9694b4d3397b67c74dc3e6f6056564a34a3ae18bb7bcb83484df948fb02459e70a61873c74d025178ec02c0655dd8c52fe3ed
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smokes (0.1.1)
4
+ smokes (0.1.2)
5
5
  colorize
6
6
  nokogiri
7
7
  os
@@ -9,6 +9,7 @@ PATH
9
9
  thor
10
10
  toml-rb
11
11
  tty-prompt
12
+ yaml-lint
12
13
 
13
14
  GEM
14
15
  remote: https://rubygems.org/
@@ -66,6 +67,7 @@ GEM
66
67
  wisper (~> 2.0.0)
67
68
  tty-screen (0.6.5)
68
69
  wisper (2.0.0)
70
+ yaml-lint (0.0.10)
69
71
 
70
72
  PLATFORMS
71
73
  ruby
data/README.md CHANGED
@@ -1,43 +1,12 @@
1
- # Elysium
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/elysium`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'elysium'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install elysium
22
-
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
-
33
- ## Contributing
34
-
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/elysium. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
-
37
- ## License
38
-
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
-
41
- ## Code of Conduct
42
-
43
- Everyone interacting in the Elysium project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/elysium/blob/master/CODE_OF_CONDUCT.md).
1
+ {
2
+ :class => 'ClassName',
3
+ :class_name => 'ClassName',
4
+ :css => 'CssSelector',
5
+ :id => 'Id',
6
+ :link => 'LinkText',
7
+ :link_text => 'LinkText',
8
+ :name => 'Name',
9
+ :partial_link_text => 'PartialLinkText',
10
+ :tag_name => 'TagName',
11
+ :xpath => 'Xpath',
12
+ }
@@ -6,6 +6,8 @@ require 'tty-prompt'
6
6
  require 'yaml'
7
7
  require 'thor'
8
8
  require 'colorize'
9
+ require 'smokes/test_parser'
10
+ require 'smokes/tests_loader'
9
11
  require 'smokes/cli'
10
12
 
11
13
  module Smokes
@@ -1,4 +1,6 @@
1
1
  module Smokes
2
+ # Main Class that runs the cli
3
+ # The Main cli methods are 'new' and 'start'
2
4
  class Cli < Thor
3
5
  include Thor::Actions
4
6
 
@@ -23,7 +25,8 @@ module Smokes
23
25
  def start
24
26
  check_cfg_file
25
27
  check_main_file
26
- get_test_selection
28
+ test_selections
29
+ Smokes::TestsLoader.new(@url, @selected_tests, @config_variables).run
27
30
  end
28
31
 
29
32
  private
@@ -37,8 +40,8 @@ module Smokes
37
40
 
38
41
  def check_cfg_file
39
42
  unless File.file?('smokes.cfg')
40
- say('smokes.cfg was not found. Generating...'.colorize(:blue))
41
- template 'templates/smokes.tt', "smokes.cfg"
43
+ say('Generating "smokes.cfg" because it was not found'.colorize(:blue))
44
+ template 'templates/smokes.tt', 'smokes.cfg'
42
45
  say('smokes.cfg was successfully generated'.colorize(:grey))
43
46
  end
44
47
  begin
@@ -63,15 +66,11 @@ module Smokes
63
66
  abort
64
67
  end
65
68
 
66
- def get_test_selection
69
+ def test_selections
67
70
  prompt = TTY::Prompt.new active_color: :green
68
- puts "\n"
69
- options = prompt.multi_select("Select tests to run: \n".colorize(:blue), (@all_tests << 'All'))
70
- if options.include?('All')
71
- @selected_tests = @all_tests
72
- else
73
- @selected_tests = options
74
- end
71
+ tests = @all_tests.dup << 'All'
72
+ options = prompt.multi_select "Select tests to run: \n".colorize(:blue), tests
73
+ @selected_tests = options.include?('All') ? @all_tests : options
75
74
  end
76
75
  end
77
76
  end
@@ -1 +1,3 @@
1
1
  [defaults]
2
+ browser = "chrome"
3
+ wait_time_out = 15
@@ -0,0 +1,54 @@
1
+ module Smokes
2
+ # Parses individual test and runs it using selenium
3
+ class TestParser
4
+ def initialize(filename, selenium_browser, selenium_wait)
5
+ @filename = filename
6
+ @test = YAML.load_file(filename)
7
+ @selenium_browser = selenium_browser
8
+ @selenium_wait = selenium_wait
9
+ end
10
+
11
+ def run
12
+ @test.each do |test|
13
+ if test.key?('test')
14
+ document_test(test) if test['test']['document']
15
+ else
16
+ say("your test is missing the test attribute: #{filename}")
17
+ abort
18
+ end
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def document_test(test)
25
+ if test['name'] && test['test']['document']['title'] && test['test']['document']['title']['should_be']
26
+ assertion = @selenium_browser.title == test['test']['document']['title']['should_be']
27
+ if assertion
28
+ puts("#{test['name']}. PASSED".colorize(:green))
29
+ else
30
+ puts("#{test['name']}. FAILED".colorize(:red))
31
+ puts("=====> Expected: #{test['test']['document']['title']['should_be']}".colorize(:yellow))
32
+ puts("=====> Found: #{@selenium_browser.title}".colorize(:yellow))
33
+ end
34
+ else
35
+ puts('Your test is missing value'.colorize(:red))
36
+ puts test
37
+ abort
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ # {
44
+ # :class => 'ClassName',
45
+ # :class_name => 'ClassName',
46
+ # :css => 'CssSelector',
47
+ # :id => 'Id',
48
+ # :link => 'LinkText',
49
+ # :link_text => 'LinkText',
50
+ # :name => 'Name',
51
+ # :partial_link_text => 'PartialLinkText',
52
+ # :tag_name => 'TagName',
53
+ # :xpath => 'Xpath',
54
+ # }
@@ -0,0 +1,32 @@
1
+ require 'selenium-webdriver'
2
+
3
+ module Smokes
4
+ # This class loads all the tests
5
+ class TestsLoader
6
+ def initialize(url, selected_tests, config_variables)
7
+ @url = url
8
+ @selected_tests = selected_tests
9
+ @config_variables = config_variables
10
+ start_browser
11
+ end
12
+
13
+ def run
14
+ @browser.get @url
15
+ itirate_tests
16
+ end
17
+
18
+ private
19
+
20
+ def start_browser
21
+ @browser = Selenium::WebDriver.for @config_variables[:browser].to_sym
22
+ @wait = Selenium::WebDriver::Wait.new(timeout: @config_variables[:wait_time_out])
23
+ end
24
+
25
+ def itirate_tests
26
+ @selected_tests.each do |selected_test|
27
+ filename = "smokes/#{selected_test}.smoke"
28
+ Smokes::TestParser.new(filename, @browser, @wait).run
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,3 +1,3 @@
1
1
  module Smokes
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
@@ -38,6 +38,7 @@ Gem::Specification.new do |spec|
38
38
  spec.add_dependency 'os'
39
39
  spec.add_dependency 'tty-prompt'
40
40
  spec.add_dependency 'toml-rb'
41
+ spec.add_dependency 'yaml-lint'
41
42
  spec.add_development_dependency 'bundler', '~> 1.16'
42
43
  spec.add_development_dependency 'rake', '~> 10.0'
43
44
  spec.add_development_dependency 'rspec', '~> 3.0'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smokes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Suyesh Bhandari
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: yaml-lint
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: bundler
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -177,6 +191,8 @@ files:
177
191
  - lib/smokes/templates/initial_load.tt
178
192
  - lib/smokes/templates/main.tt
179
193
  - lib/smokes/templates/smokes.tt
194
+ - lib/smokes/test_parser.rb
195
+ - lib/smokes/tests_loader.rb
180
196
  - lib/smokes/version.rb
181
197
  - smokes.gemspec
182
198
  homepage: https://github.com