cucumber_steps 0.0.3 → 0.0.4

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
  SHA1:
3
- metadata.gz: 91c8254682300dbc569f5ec56fe437f9990203f1
4
- data.tar.gz: 309a57de69540aff5c7ced5ac02b4e5276b3f2c0
3
+ metadata.gz: 10cb4c2203d3df16dd2a65008dc5693125cc9f4d
4
+ data.tar.gz: e413e8198aee140cf3a40a2ce0bd67698eb06d16
5
5
  SHA512:
6
- metadata.gz: 3590d7b26eede5a6094d7eb4498734e7403c9820ab604f3ecc065bd956862755e9841f275a5e09607772ee4b0b7131d985ccc91e42030e63f967fda16504a02c
7
- data.tar.gz: 599c4e9bcdd4e371e5a5546177ee792a30ae1a6bade6be9dfe1d02263e526270d49d880b71c50762bae308300cfea91e268ee98415325abca52524947cd73237
6
+ metadata.gz: 3c015ae1dd4c2154aed89cca87fee41800908f0186fc5d7f9b8250a6adfb870c6df0720b30528db1c1d79af8cb5ceaf34e23bd4d38826d222ce6eacb06925956
7
+ data.tar.gz: 5b006f1961491378dfb06bdbffbb9eda3b4596410db0d68bffd4a2260e1bc3206e547774ac10db9e3e60315b387d725a3df1f98d2a970f351382108a44c17662
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -1,4 +1,4 @@
1
- module CucumberSteps::Browser::Instance::Defaults
1
+ module CucumberSteps::Browser::Defaults
2
2
 
3
3
  BROWSER_ARGUMENTS = {
4
4
  'phantomjs' => {
@@ -22,7 +22,7 @@ module CucumberSteps::Browser::Instance::Defaults
22
22
 
23
23
  options = args.find { |e| e.is_a?(Hash) }
24
24
 
25
- pare_defined_options = ::CucumberSteps::Browser::Instance::Defaults::BROWSER_ARGUMENTS[browser_name.to_s] || {}
25
+ pare_defined_options = ::CucumberSteps::Browser::Defaults::BROWSER_ARGUMENTS[browser_name.to_s] || {}
26
26
  options.merge!(pare_defined_options) if pare_defined_options.is_a?(Hash)
27
27
 
28
28
  return args
@@ -1,4 +1,4 @@
1
- module CucumberSteps::Browser::Instance::ScopeHandler
1
+ module CucumberSteps::Browser::ScopeHandler
2
2
 
3
3
  def current_scope
4
4
  target_scope = self
@@ -1,47 +1,17 @@
1
- require 'cucumber_steps/browser/browser_steps'
2
- require 'cucumber_steps/browser/click_steps'
3
- require 'cucumber_steps/browser/expect_steps'
4
- require 'cucumber_steps/browser/hover_steps'
5
- require 'cucumber_steps/browser/sketch_steps'
6
- require 'cucumber_steps/browser/typing_steps'
7
- require 'cucumber_steps/browser/visit_steps'
1
+ require 'watir'
2
+ class CucumberSteps::Browser < Watir::Browser
8
3
 
9
- module CucumberSteps::Browser
4
+ require 'cucumber_steps/browser/defaults'
5
+ extend CucumberSteps::Browser::Defaults
10
6
 
11
- require 'cucumber_steps/browser/instance'
7
+ require 'cucumber_steps/browser/scope_handler'
8
+ include CucumberSteps::Browser::ScopeHandler
12
9
 
13
- def browser
14
- @browser || reopen_browser!
15
- end
16
-
17
- def reopen_browser!
18
-
19
- if @browser.is_a?(::CucumberSteps::Browser::Instance)
20
- @browser.close
21
- end
22
-
23
- browser = ::CucumberSteps::Browser::Instance.new(browser_name)
24
- @browser = browser
10
+ protected
25
11
 
12
+ def initialize(browser_name, *args)
13
+ super(browser_name, *self.class.args_with_default_options(browser_name, *args))
14
+ Kernel.at_exit { self.close rescue nil } if CucumberSteps::ENVFetcher.close_browser_at_exit?
26
15
  end
27
16
 
28
- def browser_name=(new_browser_name)
29
- @browser_name = new_browser_name.to_s.strip
30
- end
31
-
32
- def browser_name
33
- CucumberSteps::ENVFetcher.browser_name || @browser_name || 'phantomjs'
34
- end
35
-
36
- def parse_html_attributes(raw_attributes)
37
- raw_attributes.scan(/(\w+)="([^"]+)"/).reduce({}) do |all_matcher, (attr_name, value)|
38
- all_matcher[attr_name.downcase.to_sym]=value
39
- all_matcher
40
- end
41
- end
42
-
43
- end
44
-
45
- World(CucumberSteps::Browser)
46
-
47
-
17
+ end
@@ -0,0 +1,10 @@
1
+ require 'cucumber_steps/declarations/browser_steps/configure_steps'
2
+ require 'cucumber_steps/declarations/browser_steps/click_steps'
3
+ require 'cucumber_steps/declarations/browser_steps/expect_steps'
4
+ require 'cucumber_steps/declarations/browser_steps/hover_steps'
5
+ require 'cucumber_steps/declarations/browser_steps/sketch_steps'
6
+ require 'cucumber_steps/declarations/browser_steps/typing_steps'
7
+ require 'cucumber_steps/declarations/browser_steps/visit_steps'
8
+
9
+ require 'cucumber_steps/world_extensions/browser_methods'
10
+ World(CucumberSteps::WorldExtensions::BrowserMethods)
@@ -0,0 +1,4 @@
1
+ require 'cucumber_steps'
2
+
3
+ require 'cucumber_steps/declarations/debug_steps' if CucumberSteps::ENVFetcher.development?
4
+ require 'cucumber_steps/declarations/browser_steps'
@@ -1,39 +1,41 @@
1
1
  module CucumberSteps::ENVFetcher
2
2
  extend self
3
3
 
4
- CLI_ALIASES_FOR_TRUE = %W[yes true]
5
- CLI_ALIASES_FOR_FALSE = %W[no false]
4
+ TRANSLATE_TABLE = {
5
+ 'yes' => true,
6
+ 'true' => true,
7
+ 'no' => false,
8
+ 'false' => false
9
+ }
6
10
 
7
11
  def development?
8
- lookup_for_true_case('DEVELOPER_ENV')
12
+ lookup_for true, 'DEVELOPER_ENV'
9
13
  end
10
14
 
11
15
  def close_browser_at_exit?
12
- lookup_for_true_case('CLOSE_BROWSER_AT_EXIT') or
13
- not lookup_for_false_case('BROWSER_NOT_EXIT_AFTER_TEST', 'BROWSER_NOT_EXIT_AT_EXIT')
16
+ not lookup_for(false, 'CLOSE_BROWSER_AT_EXIT', 'BROWSER_CLOSE_AT_EXIT', 'CLOSE_BROWSER')
14
17
  end
15
18
 
16
19
  def browser_name
17
- lookup_value_by('BROWSER','BROWSER_NAME')
20
+ lookup_value_by('BROWSER', 'BROWSER_NAME')
18
21
  end
19
22
 
20
23
  protected
21
24
 
22
- def lookup_for_true_case(*env_keys)
23
- filtered_env(env_keys).any? { |k, v| CLI_ALIASES_FOR_TRUE.include?(v.to_s.downcase) }
24
- end
25
-
26
- def lookup_for_false_case(*env_keys)
27
- filtered_env(env_keys).any? { |k, v| CLI_ALIASES_FOR_FALSE.include?(v.to_s.downcase) }
25
+ def lookup_for(boolean, *env_keys)
26
+ formatted_env(env_keys).any? { |k, v| v == boolean }
28
27
  end
29
28
 
30
29
  def lookup_value_by(*env_keys)
31
30
  filtered_env(env_keys).values.first
32
31
  end
33
32
 
33
+ def formatted_env(filtered_env)
34
+ filtered_env.reduce({}) { |m, (k, v)| m.merge!({k => TRANSLATE_TABLE[v]}); m }
35
+ end
36
+
34
37
  def filtered_env(env_keys)
35
38
  lookup_env_keys = env_keys.map(&:to_s).map(&:upcase)
36
-
37
39
  ENV.select { |env_key, value| lookup_env_keys.include?(env_key) }
38
40
  end
39
41
 
@@ -0,0 +1,35 @@
1
+ module CucumberSteps::WorldExtensions::BrowserMethods
2
+
3
+ require 'cucumber_steps/browser'
4
+
5
+ def browser
6
+ @browser || reopen_browser!
7
+ end
8
+
9
+ def reopen_browser!
10
+
11
+ if @browser.is_a?(::CucumberSteps::Browser)
12
+ @browser.close
13
+ end
14
+
15
+ browser = ::CucumberSteps::Browser.new(browser_name)
16
+ @browser = browser
17
+
18
+ end
19
+
20
+ def browser_name=(new_browser_name)
21
+ @browser_name = new_browser_name.to_s.strip
22
+ end
23
+
24
+ def browser_name
25
+ CucumberSteps::ENVFetcher.browser_name || @browser_name || 'phantomjs'
26
+ end
27
+
28
+ def parse_html_attributes(raw_attributes)
29
+ raw_attributes.scan(/(\w+)="([^"]+)"/).reduce({}) do |all_matcher, (attr_name, value)|
30
+ all_matcher[attr_name.downcase.to_sym]=value
31
+ all_matcher
32
+ end
33
+ end
34
+
35
+ end
@@ -0,0 +1,3 @@
1
+ module CucumberSteps::WorldExtensions
2
+ require 'cucumber_steps/world_extensions/browser_methods'
3
+ end
@@ -1,12 +1,10 @@
1
1
  module CucumberSteps
2
2
 
3
- require 'cucumber_steps/env_fetcher'
4
-
5
- require 'cucumber_steps/debug' if CucumberSteps::ENVFetcher.development?
6
-
7
3
  require 'cucumber'
8
- require 'cucumber/rb_support/rb_dsl'
4
+ # require 'cucumber/rb_support/rb_dsl'
9
5
 
10
6
  require 'cucumber_steps/browser'
7
+ require 'cucumber_steps/env_fetcher'
8
+ require 'cucumber_steps/world_extensions'
11
9
 
12
- end
10
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber_steps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Luzsi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-20 00:00:00.000000000 Z
11
+ date: 2015-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -111,19 +111,22 @@ files:
111
111
  - cucumber_steps.gemspec
112
112
  - lib/cucumber_steps.rb
113
113
  - lib/cucumber_steps/browser.rb
114
- - lib/cucumber_steps/browser/browser_steps.rb
115
- - lib/cucumber_steps/browser/click_steps.rb
116
- - lib/cucumber_steps/browser/expect_steps.rb
117
- - lib/cucumber_steps/browser/hover_steps.rb
118
- - lib/cucumber_steps/browser/instance.rb
119
- - lib/cucumber_steps/browser/instance/defaults.rb
120
- - lib/cucumber_steps/browser/instance/scope_handler.rb
121
- - lib/cucumber_steps/browser/locating_scope_steps.rb
122
- - lib/cucumber_steps/browser/sketch_steps.rb
123
- - lib/cucumber_steps/browser/typing_steps.rb
124
- - lib/cucumber_steps/browser/visit_steps.rb
125
- - lib/cucumber_steps/debug.rb
114
+ - lib/cucumber_steps/browser/defaults.rb
115
+ - lib/cucumber_steps/browser/scope_handler.rb
116
+ - lib/cucumber_steps/declarations.rb
117
+ - lib/cucumber_steps/declarations/browser_steps.rb
118
+ - lib/cucumber_steps/declarations/browser_steps/click_steps.rb
119
+ - lib/cucumber_steps/declarations/browser_steps/configure_steps.rb
120
+ - lib/cucumber_steps/declarations/browser_steps/expect_steps.rb
121
+ - lib/cucumber_steps/declarations/browser_steps/hover_steps.rb
122
+ - lib/cucumber_steps/declarations/browser_steps/locating_scope_steps.rb
123
+ - lib/cucumber_steps/declarations/browser_steps/sketch_steps.rb
124
+ - lib/cucumber_steps/declarations/browser_steps/typing_steps.rb
125
+ - lib/cucumber_steps/declarations/browser_steps/visit_steps.rb
126
+ - lib/cucumber_steps/declarations/debug_steps.rb
126
127
  - lib/cucumber_steps/env_fetcher.rb
128
+ - lib/cucumber_steps/world_extensions.rb
129
+ - lib/cucumber_steps/world_extensions/browser_methods.rb
127
130
  homepage: ''
128
131
  licenses:
129
132
  - MIT
@@ -1,17 +0,0 @@
1
- require 'watir'
2
- class CucumberSteps::Browser::Instance < Watir::Browser
3
-
4
- require 'cucumber_steps/browser/instance/defaults'
5
- extend CucumberSteps::Browser::Instance::Defaults
6
-
7
- require 'cucumber_steps/browser/instance/scope_handler'
8
- include CucumberSteps::Browser::Instance::ScopeHandler
9
-
10
- protected
11
-
12
- def initialize(browser_name, *args)
13
- super(browser_name, *self.class.args_with_default_options(browser_name, *args))
14
- Kernel.at_exit { self.close rescue nil } if CucumberSteps::ENVFetcher.close_browser_at_exit?
15
- end
16
-
17
- end