tune_spec 0.3.1 → 0.4.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: 4ec581153a60aed89bdd7c2eb4e464f14bea33a4
4
- data.tar.gz: acda8460fdccfda7b8ff09ee392315f26060ad12
3
+ metadata.gz: ede0c2da431134e6f70d95c3e368940435d49606
4
+ data.tar.gz: be6caeaf927340c184599e6ca16f92b617880a35
5
5
  SHA512:
6
- metadata.gz: 98904e6624bd0e93f6be77b01173414565d195c6c581e74af148b87cc95d3e9171e9fe96a88e969b1bbc3cc5162ad47e620354088c4fabe9ebbd4fc00d173552
7
- data.tar.gz: e7ef8d74dd3e0fdd931d059bd409a2c2bd31b88b67c90d5db1ba6f0eca38b3863a02699ef1f6ea9ef8b067d393d5bfe036dd6dfe6daa0a1b195e8a8298029526
6
+ metadata.gz: 6bed736d874f0c5aa00c6c38e2039686b1f97db38c657124174d91a127883f9c10da98ebfb7930c035ef004ceb96e4f02cd733591bf2ab56a38aa1195e885085
7
+ data.tar.gz: 37e120a2035cff4b9f0065473dd1281c0580840f1220137916aac220c7c66390c786d5da3b0b236e347748e702d4a4ca6b0b703f561e87cc93907c5cfadef4fe
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tune_spec (0.3.1)
4
+ tune_spec (0.4.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -78,6 +78,16 @@ TuneSpec.configure do |config|
78
78
  end
79
79
  ```
80
80
 
81
+ ### Calabash
82
+
83
+ In order to use the gem with calabash page instantiation features you need to set `TuneSpec.calabash_enabled = true`. Or configure the gem:
84
+ ```ruby
85
+ TuneSpec.configure do |config|
86
+ config.calabash_enabled = true
87
+ config.calabash_wait_opts = { timeout: 10 } # set by default
88
+ end
89
+ ```
90
+
81
91
  ## Development
82
92
 
83
93
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -4,7 +4,8 @@ module TuneSpec
4
4
  # Defines all configurable attributes of TuneSpec
5
5
  module Configuration
6
6
  VALID_CONFIG_KEYS = %i[directory steps_page_arg
7
- page_opts steps_opts groups_opts].freeze
7
+ page_opts steps_opts groups_opts
8
+ calabash_enabled calabash_wait_opts].freeze
8
9
 
9
10
  DEFAULT_DIRECTORY = 'lib'
10
11
 
@@ -16,6 +17,10 @@ module TuneSpec
16
17
 
17
18
  DEFAULT_GROUPS_OPTS = {}.freeze
18
19
 
20
+ DEFAULT_CALABASH_ENABLED = false
21
+
22
+ DEFAULT_CALABASH_WAIT_OPTS = { timeout: 10 }.freeze
23
+
19
24
  VALID_CONFIG_KEYS.each { |key| attr_accessor key }
20
25
 
21
26
  # Make sure the default values are set when the module is 'extended'
@@ -12,6 +12,11 @@ module TuneSpec
12
12
  instance
13
13
  end
14
14
 
15
+ def object_type
16
+ return super unless TuneSpec.calabash_enabled
17
+ :calabash_page
18
+ end
19
+
15
20
  private
16
21
 
17
22
  def file_directory
@@ -29,6 +29,10 @@ module TuneSpec
29
29
  const_get(const_name)
30
30
  end
31
31
 
32
+ def object_type
33
+ :common
34
+ end
35
+
32
36
  private
33
37
 
34
38
  def type
@@ -50,23 +50,30 @@ module TuneSpec
50
50
  # @private
51
51
  def instance_handler(name, klass, *args, block)
52
52
  method_name = klass.instance_method_name(name)
53
- create_instance_method(method_name, klass)
54
53
  instance_klass = klass.call_object(method_name)
54
+ create_instance_method(method_name, klass, instance_klass)
55
55
  formatted_args = klass.format_args(args, instance_klass)
56
56
  call_instance_method(method_name, *formatted_args, block)
57
57
  end
58
58
 
59
59
  # @private
60
- def create_instance_method(method_name, klass)
60
+ def create_instance_method(method_name, klass, instance_klass)
61
61
  return if respond_to?(method_name)
62
62
  define_singleton_method(method_name) do |*args|
63
63
  instance_var = instance_variable_get("@#{method_name}")
64
64
  return instance_var if klass.rules_passed?(instance_var, args)
65
- new_instance = klass.call_object(method_name).new(*args)
65
+ new_instance = create_instance(klass, instance_klass, args)
66
66
  instance_variable_set("@#{method_name}", new_instance)
67
67
  end
68
68
  end
69
69
 
70
+ # @private
71
+ def create_instance(klass, instance_klass, args)
72
+ return instance_klass.new(*args) if klass.object_type == :common
73
+ wait_opts = TuneSpec.calabash_wait_opts
74
+ page(instance_klass, *args).await(wait_opts)
75
+ end
76
+
70
77
  # @private
71
78
  def call_instance_method(method_name, *args, block)
72
79
  return __send__(method_name, *args) unless block
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TuneSpec
4
- VERSION = '0.3.1'
4
+ VERSION = '0.4.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tune_spec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Starostenko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-18 00:00:00.000000000 Z
11
+ date: 2017-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -119,5 +119,5 @@ rubyforge_project:
119
119
  rubygems_version: 2.6.12
120
120
  signing_key:
121
121
  specification_version: 4
122
- summary: tune_spec_0.3.1
122
+ summary: tune_spec_0.4.0
123
123
  test_files: []