page_object_stubs 0.0.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5539524aebc21c73f8646618784864432644092
4
- data.tar.gz: f09fbc4ee8ef7bad40407e10908e10409cf2053b
3
+ metadata.gz: 955a66396ea7ac62b092d815d36bd9e9d15ffe7b
4
+ data.tar.gz: 01ab88000db1ac9eee71e9bf916bbfffe6a32d30
5
5
  SHA512:
6
- metadata.gz: 9c1a140433db21e3259f1bc2a755f47d2751c6201514576bc6f2b89eb07fcb3c99b333af83e53d069f626f607007a33722577e266346af31bcd996fe83090625
7
- data.tar.gz: 696669b89acd0fda6a6ddd44b27b5c898d9cad8bf3ea0e70b0eb71e92116cae512a6dbe67626df8eb865c0d5a924020b776d188e349e74b12a4ee4b7b659f267
6
+ metadata.gz: 8b59b9a8c6128d056c7e2cc85306a603019e7dbe11f5b7b17080791495f4c451b8d9debe6aa48df160fbcd640367362685b2cd2c0d2a71cda439616d900f0cb7
7
+ data.tar.gz: a2b0bc729f623920abc71cd3b4b64bc3c899528b4b49387a6703fd2c4783d601dfbb63d8e03e43978568b262c7f5997e58b0bd18a967c3059ebd0225fd512ea5
@@ -12,11 +12,9 @@ module PageObjectStubs
12
12
  # @param [Hash] opts
13
13
  # @option opts [Array<File>] :targets Array of target files to create stubs from (required)
14
14
  # @option opts [Dir] :output_folder Folder to create stubs in (required)
15
- # @option opts [Boolean] :angularjs Enable angularjs support (optional, default false)
16
15
  def generate opts={}
17
- angularjs = !!opts.fetch(:angularjs, false)
18
- targets = opts.fetch(:targets)
19
- targets = targets.select do |target|
16
+ targets = opts.fetch(:targets)
17
+ targets = targets.select do |target|
20
18
  File.file?(target) && File.readable?(target)
21
19
  end
22
20
 
@@ -45,10 +43,10 @@ R
45
43
 
46
44
  page_objects.name_type_pairs.each do |pair|
47
45
  element_type = pair.first
46
+ # if 'page_url' exists, then we need `def goto`
47
+ # for all others, we need the name of the element to generate the remaining methods.
48
48
  if element_type == 'page_url'
49
49
  output += wrap 'goto'
50
- # visit loads goto then runs the Protractor waitForAngular JavaScript
51
- output += wrap 'visit' if angularjs
52
50
  next
53
51
  end
54
52
 
@@ -62,29 +60,31 @@ R
62
60
  end
63
61
 
64
62
 
65
- stub_file = File.join(output_folder, file_name + '_stub.rb')
63
+ stub_file = File.join(output_folder, file_name + '_stub.rb')
64
+
65
+ # Note that the page method is defined as a singleton method on the
66
+ # top level 'main' object. This ensures we're not polluting the global
67
+ # object space by defining methods on every object which would happen
68
+ # if Kernel was used instead.
66
69
 
67
70
  output_postfix = <<R
68
71
  end
69
72
  end
70
73
  end
71
74
 
72
- module Kernel
73
- def #{file_method_name}
74
- Stub::#{file_module_name}
75
- end
76
- end unless Kernel.respond_to? :#{file_method_name}
75
+ public
76
+
77
+ def #{file_method_name}
78
+ Stub::#{file_module_name}
79
+ end
77
80
  R
78
81
 
79
82
  output = output_prefix + output + output_postfix
80
83
 
81
84
  File.open(stub_file, 'w') do |file|
82
- file.write output.strip
85
+ file.write output
83
86
  end
84
87
  end
85
-
86
- # if 'page_url' exists, then we need `def goto`
87
- # for all others, we need the name of the element to generate the remaining methods.
88
88
  end
89
89
  end
90
90
  end
@@ -8,7 +8,6 @@ module PageObjectStubs
8
8
  # @option opts [String] :task_desc the description of the stubs task (optional)
9
9
  # @option opts [lambda] :targets lambda that will return an array of targets (optional)
10
10
  # @option opts [lambda] :output_folder lambda that will return the output folder (optional)
11
- # @option opts [Boolean] :angularjs generate angularjs stubs. default true (optional)
12
11
  def add_stubs_task opts={}
13
12
  task_name = opts.fetch(:task_name, 'stubs')
14
13
  task_desc = opts.fetch(:task_desc, 'Generate stubs')
@@ -16,7 +15,6 @@ module PageObjectStubs
16
15
  # Get the dir that contains the Rakefile via Rake (__dir__ will not work)
17
16
  targets = opts.fetch(:targets, lambda { Dir.glob(File.join(Rake.application.original_dir, 'page', '*_page.rb')) })
18
17
  output_folder = opts.fetch(:output_folder, lambda { File.join(Rake.application.original_dir, 'helper', 'stub') })
19
- angularjs = opts.fetch(:angularjs, true)
20
18
 
21
19
  raise 'targets must be a lambda' unless targets.lambda?
22
20
  raise 'output_folder must be a lambda' unless output_folder.lambda?
@@ -24,8 +22,7 @@ module PageObjectStubs
24
22
  Rake.application.last_description = task_desc
25
23
  Rake::Task.define_task task_name do
26
24
  PageObjectStubs.generate targets: targets.call,
27
- output_folder: output_folder.call,
28
- angularjs: angularjs
25
+ output_folder: output_folder.call
29
26
  end
30
27
  end
31
28
  end
@@ -1,4 +1,4 @@
1
1
  module PageObjectStubs
2
- VERSION = '0.0.3' unless defined? ::PageObjectStubs::VERSION
3
- DATE = '2015-05-10' unless defined? ::PageObjectStubs::DATE
2
+ VERSION = '1.0.0' unless defined? ::PageObjectStubs::VERSION
3
+ DATE = '2015-06-06' unless defined? ::PageObjectStubs::DATE
4
4
  end
data/release_notes.md CHANGED
@@ -1,3 +1,9 @@
1
+ #### v1.0.0 2015-06-06
2
+
3
+ - [df4833e](https://github.com/bootstraponline/page_object_stubs/commit/df4833e0856873e581498d4a024b6d832a84bc66) Release 1.0.0
4
+ - [bcd8c46](https://github.com/bootstraponline/page_object_stubs/commit/bcd8c46a5025956e9bddc7d5655e29177826a50b) Use top level singleton instead of Kernel method
5
+
6
+
1
7
  #### v0.0.3 2015-05-10
2
8
 
3
9
  - [fb08c84](https://github.com/bootstraponline/page_object_stubs/commit/fb08c84b55849da5fdd8d0e517d02addd9aebd6d) Release 0.0.3
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: page_object_stubs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - code@bootstraponline.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-10 00:00:00.000000000 Z
11
+ date: 2015-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser