howitzer 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -1
  3. data/LICENSE +1 -1
  4. data/README.md +16 -16
  5. data/generators/base_generator.rb +1 -1
  6. data/generators/config/config_generator.rb +1 -4
  7. data/generators/config/templates/boot.rb +1 -1
  8. data/generators/config/templates/capybara.rb +1 -3
  9. data/generators/config/templates/default.yml +5 -19
  10. data/generators/config/templates/drivers/browserstack.rb +1 -1
  11. data/generators/config/templates/drivers/crossbrowsertesting.rb +1 -1
  12. data/generators/config/templates/drivers/headless_chrome.rb +1 -1
  13. data/generators/config/templates/drivers/headless_firefox.rb +1 -1
  14. data/generators/config/templates/drivers/sauce.rb +1 -1
  15. data/generators/config/templates/drivers/selenium.rb +1 -1
  16. data/generators/config/templates/drivers/selenium_grid.rb +2 -2
  17. data/generators/config/templates/drivers/testingbot.rb +1 -1
  18. data/generators/cucumber/templates/env.rb +1 -1
  19. data/generators/cucumber/templates/hooks.rb +8 -2
  20. data/generators/cucumber/templates/transformers.rb +1 -1
  21. data/generators/prerequisites/templates/factory_bot.rb +1 -1
  22. data/generators/root/templates/Gemfile.erb +4 -10
  23. data/generators/rspec/templates/spec_helper.rb +4 -4
  24. data/generators/turnip/templates/spec_helper.rb +4 -4
  25. data/generators/web/templates/example_page.rb +1 -1
  26. data/lib/howitzer/cache.rb +1 -1
  27. data/lib/howitzer/capybara_helpers.rb +27 -7
  28. data/lib/howitzer/email.rb +2 -2
  29. data/lib/howitzer/exceptions.rb +21 -21
  30. data/lib/howitzer/gmail_api/client.rb +13 -4
  31. data/lib/howitzer/log.rb +6 -6
  32. data/lib/howitzer/mailgun_api/client.rb +3 -2
  33. data/lib/howitzer/mailgun_api/response.rb +1 -2
  34. data/lib/howitzer/mailtrap_api/client.rb +1 -1
  35. data/lib/howitzer/meta/actions.rb +13 -16
  36. data/lib/howitzer/meta/element.rb +12 -10
  37. data/lib/howitzer/utils/string_extensions.rb +6 -2
  38. data/lib/howitzer/version.rb +1 -1
  39. data/lib/howitzer/web/base_section.rb +1 -1
  40. data/lib/howitzer/web/capybara_methods_proxy.rb +11 -5
  41. data/lib/howitzer/web/element_dsl.rb +104 -45
  42. data/lib/howitzer/web/iframe_dsl.rb +2 -2
  43. data/lib/howitzer/web/page.rb +4 -14
  44. data/lib/howitzer/web/page_dsl.rb +15 -6
  45. data/lib/howitzer/web/page_validator.rb +25 -26
  46. data/lib/howitzer/web/section.rb +5 -2
  47. data/lib/howitzer/web/section_dsl.rb +64 -30
  48. data/lib/howitzer.rb +2 -2
  49. metadata +24 -161
  50. data/.coveralls.yml +0 -1
  51. data/.gitignore +0 -14
  52. data/.rspec +0 -3
  53. data/.rubocop.yml +0 -60
  54. data/.ruby-gemset +0 -1
  55. data/.travis.yml +0 -8
  56. data/Gemfile +0 -14
  57. data/ISSUE_TEMPLATE.md +0 -16
  58. data/MAINTENANCE.md +0 -32
  59. data/Rakefile +0 -38
  60. data/features/cli_help.feature +0 -31
  61. data/features/cli_new.feature +0 -393
  62. data/features/cli_unknown.feature +0 -17
  63. data/features/cli_update.feature +0 -223
  64. data/features/cli_version.feature +0 -14
  65. data/features/step_definitions/common_steps.rb +0 -34
  66. data/features/support/env.rb +0 -1
  67. data/generators/config/templates/drivers/poltergeist.rb +0 -11
  68. data/generators/config/templates/drivers/webkit.rb +0 -6
  69. data/generators/root/templates/.gitignore +0 -21
  70. data/generators/root/templates/.rubocop.yml.erb +0 -56
  71. data/generators/turnip/templates/.rspec +0 -1
  72. data/howitzer.gemspec +0 -39
  73. data/lib/howitzer/mail_adapters/debugmail.rb +0 -0
  74. data/spec/config/custom.yml +0 -9
  75. data/spec/spec_helper.rb +0 -73
  76. data/spec/support/generator_helper.rb +0 -21
  77. data/spec/support/logger_helper.rb +0 -13
  78. data/spec/support/shared_examples/capybara_context_holder.rb +0 -33
  79. data/spec/support/shared_examples/capybara_methods_proxy.rb +0 -94
  80. data/spec/support/shared_examples/dynamic_section_methods.rb +0 -35
  81. data/spec/support/shared_examples/element_dsl.rb +0 -242
  82. data/spec/support/shared_examples/meta_highlight_xpath.rb +0 -41
  83. data/spec/unit/generators/base_generator_spec.rb +0 -283
  84. data/spec/unit/generators/config_generator_spec.rb +0 -61
  85. data/spec/unit/generators/cucumber_generator_spec.rb +0 -62
  86. data/spec/unit/generators/emails_generator_spec.rb +0 -35
  87. data/spec/unit/generators/prerequisites_generator_spec.rb +0 -53
  88. data/spec/unit/generators/root_generator_spec.rb +0 -86
  89. data/spec/unit/generators/rspec_generator_spec.rb +0 -36
  90. data/spec/unit/generators/tasks_generator_spec.rb +0 -31
  91. data/spec/unit/generators/templates/cucumber_spec.rb +0 -97
  92. data/spec/unit/generators/templates/rspec_spec.rb +0 -88
  93. data/spec/unit/generators/templates/turnip_spec.rb +0 -98
  94. data/spec/unit/generators/turnip_generator_spec.rb +0 -52
  95. data/spec/unit/generators/web_generator_spec.rb +0 -52
  96. data/spec/unit/lib/cache_spec.rb +0 -85
  97. data/spec/unit/lib/capybara_helpers_spec.rb +0 -730
  98. data/spec/unit/lib/email_spec.rb +0 -186
  99. data/spec/unit/lib/gmail_api/client_spec.rb +0 -26
  100. data/spec/unit/lib/howitzer_spec.rb +0 -92
  101. data/spec/unit/lib/init_spec.rb +0 -2
  102. data/spec/unit/lib/log_spec.rb +0 -122
  103. data/spec/unit/lib/mail_adapters/abstract_spec.rb +0 -62
  104. data/spec/unit/lib/mail_adapters/gmail_spec.rb +0 -128
  105. data/spec/unit/lib/mail_adapters/mailgun_spec.rb +0 -158
  106. data/spec/unit/lib/mail_adapters/mailtrap_spec.rb +0 -130
  107. data/spec/unit/lib/mailgun_api/client_spec.rb +0 -80
  108. data/spec/unit/lib/mailgun_api/connector_spec.rb +0 -54
  109. data/spec/unit/lib/mailgun_api/response_spec.rb +0 -28
  110. data/spec/unit/lib/mailtrap_api/client_spec.rb +0 -67
  111. data/spec/unit/lib/meta/element_spec.rb +0 -59
  112. data/spec/unit/lib/meta/entry_spec.rb +0 -77
  113. data/spec/unit/lib/meta/iframe_spec.rb +0 -66
  114. data/spec/unit/lib/meta/section_spec.rb +0 -43
  115. data/spec/unit/lib/utils/string_extensions_spec.rb +0 -77
  116. data/spec/unit/lib/web/base_section_spec.rb +0 -43
  117. data/spec/unit/lib/web/element_dsl_spec.rb +0 -31
  118. data/spec/unit/lib/web/iframe_dsl_spec.rb +0 -203
  119. data/spec/unit/lib/web/page_dsl_spec.rb +0 -74
  120. data/spec/unit/lib/web/page_spec.rb +0 -385
  121. data/spec/unit/lib/web/page_validator_spec.rb +0 -276
  122. data/spec/unit/lib/web/section_dsl_spec.rb +0 -165
  123. data/spec/unit/lib/web/section_spec.rb +0 -70
  124. data/spec/unit/version_spec.rb +0 -8
@@ -1,66 +0,0 @@
1
- require 'spec_helper'
2
- require 'howitzer/meta/iframe'
3
-
4
- RSpec.describe Howitzer::Meta::Iframe do
5
- let(:context) { double }
6
- let(:name) { 'foo' }
7
- let(:iframe) { described_class.new(name, context) }
8
-
9
- describe '.new' do
10
- it { expect(iframe.context).to eq(context) }
11
- it { expect(iframe.name).to eq('foo') }
12
- end
13
-
14
- describe '#capybara_elements' do
15
- subject { iframe.capybara_elements }
16
- it do
17
- expect(iframe).to receive(:site_value)
18
- expect(context).to receive_message_chain(:capybara_context, :all)
19
- subject
20
- end
21
- end
22
-
23
- describe '#capybara_element' do
24
- subject { iframe.capybara_element }
25
- context 'when element is present' do
26
- context 'with default arguments' do
27
- it do
28
- expect(iframe).to receive(:site_value)
29
- expect(context).to receive_message_chain(:capybara_context, :find)
30
- subject
31
- end
32
- end
33
- context 'with custom arguments' do
34
- subject { iframe.capybara_element(wait: 5) }
35
- it do
36
- expect(iframe).to receive(:site_value)
37
- expect(context).to receive_message_chain(:capybara_context, :find)
38
- subject
39
- end
40
- end
41
- end
42
- context 'when element is not found' do
43
- before do
44
- allow(iframe).to receive(:site_value)
45
- allow(context).to receive_message_chain(:capybara_context, :find) { raise Capybara::ElementNotFound }
46
- end
47
- it { is_expected.to be_nil }
48
- end
49
- end
50
-
51
- describe '#site_value' do
52
- subject { iframe.site_value }
53
- context 'when site value is present' do
54
- before { iframe.instance_variable_set(:@site_value, 'test') }
55
- it { is_expected.to eq('test') }
56
- end
57
- context 'when site value is blank' do
58
- it do
59
- expect(context).to receive(:send).with("#{name}_iframe")
60
- subject
61
- end
62
- end
63
- end
64
-
65
- include_examples :meta_highlight_xpath
66
- end
@@ -1,43 +0,0 @@
1
- require 'spec_helper'
2
- require 'howitzer/meta/section'
3
-
4
- RSpec.describe Howitzer::Meta::Section do
5
- let(:context) { double }
6
- let(:name) { 'foo' }
7
- let(:section) { described_class.new(name, context) }
8
-
9
- describe '.new' do
10
- it { expect(section.context).to eq(context) }
11
- it { expect(section.name).to eq('foo') }
12
- end
13
-
14
- describe '#capybara_elements' do
15
- subject { section.capybara_elements }
16
- let(:capybara_element) { double }
17
- it do
18
- expect(context).to receive(:send).with("#{name}_sections") { [capybara_element] }
19
- expect(capybara_element).to receive(:capybara_context)
20
- subject
21
- end
22
- end
23
-
24
- describe '#capybara_element' do
25
- let(:capybara_element) { double }
26
- subject { section.capybara_element }
27
- context 'when element is present' do
28
- it do
29
- expect(context).to receive(:send).with("#{name}_sections") { [capybara_element] }
30
- expect(capybara_element).to receive(:capybara_context)
31
- subject
32
- end
33
- end
34
- context 'when element is not found' do
35
- it do
36
- expect(context).to receive(:send).with("#{name}_sections") { [] }
37
- is_expected.to be_nil
38
- end
39
- end
40
- end
41
-
42
- include_examples :meta_highlight_xpath
43
- end
@@ -1,77 +0,0 @@
1
- require 'spec_helper'
2
- require 'howitzer/utils/string_extensions'
3
-
4
- RSpec.describe Howitzer::Utils::StringExtensions do
5
- String.include Howitzer::Utils::StringExtensions
6
-
7
- let(:page_name) { 'my' }
8
- let(:page_object) { double }
9
- before { stub_const('MyPage', page_object) }
10
- describe '#open' do
11
- subject { page_name.open(:exit) }
12
- before do
13
- expect(page_object).to receive(:open).with(:exit).once
14
- end
15
- it { is_expected.to be_nil }
16
- end
17
- describe '#given' do
18
- subject { page_name.given }
19
- before do
20
- allow(page_name).to receive(:as_page_class) { page_object }
21
- expect(page_object).to receive(:given).once
22
- end
23
- it { is_expected.to be_nil }
24
- end
25
- describe '#displayed?' do
26
- subject { page_name.displayed? }
27
- before do
28
- allow(page_name).to receive(:as_page_class) { page_object }
29
- expect(page_object).to receive(:displayed?).once
30
- end
31
- it { is_expected.to be_nil }
32
- end
33
- describe '#as_page_class' do
34
- subject { page_name.as_page_class }
35
- context 'when 1 word' do
36
- it { is_expected.to eql(page_object) }
37
- end
38
- context 'when more 1 word' do
39
- let(:page_name) { 'my super mega' }
40
- before { stub_const('MySuperMegaPage', page_object) }
41
- it { is_expected.to eql(page_object) }
42
- end
43
- context 'when plural word' do
44
- let(:page_name) { 'user notifications' }
45
- before { stub_const('UserNotificationsPage', page_object) }
46
- it { is_expected.to eql(page_object) }
47
- end
48
- end
49
- describe '#as_email_class' do
50
- subject { email_name.as_email_class }
51
- let(:my_email) { double }
52
- context 'when 1 word' do
53
- let(:email_name) { 'my' }
54
- before { stub_const('MyEmail', my_email) }
55
- it { is_expected.to eql(my_email) }
56
- end
57
- context 'when more 1 word' do
58
- let(:email_name) { 'my super mega' }
59
- before { stub_const('MySuperMegaEmail', my_email) }
60
- it { is_expected.to eql(my_email) }
61
- end
62
- context 'when plural word' do
63
- let(:email_name) { 'email notifications' }
64
- before { stub_const('EmailNotificationsEmail', my_email) }
65
- it { is_expected.to eql(my_email) }
66
- end
67
- end
68
- describe '#on' do
69
- let(:block) { -> {} }
70
- subject { page_name.on(&block) }
71
- before do
72
- allow(page_name).to receive(:as_page_class) { page_object }
73
- expect(page_object).to receive(:on).once
74
- end
75
- it { is_expected.to be_nil }
76
- end
77
- end
@@ -1,43 +0,0 @@
1
- require 'spec_helper'
2
- require 'howitzer/web/section_dsl'
3
- require 'howitzer/web/base_section'
4
-
5
- RSpec.describe Howitzer::Web::BaseSection do
6
- describe 'element dsl methods' do
7
- let(:parent) { double }
8
- let(:capybara_context) { double }
9
-
10
- let(:klass) { Class.new(described_class) }
11
- let(:klass_object) { klass.new(parent, capybara_context) }
12
- it 'returns correct capybara context' do
13
- expect(klass_object.capybara_context).to eq(capybara_context)
14
- end
15
-
16
- include_examples :element_dsl
17
- end
18
- describe 'DSL' do
19
- describe '.me' do
20
- it { expect { described_class.send(:me, '.foo') }.to raise_error(NoMethodError) }
21
- end
22
- end
23
-
24
- describe '.default_finder_args' do
25
- subject { described_class.default_finder_args }
26
- it { is_expected.to be_nil }
27
- end
28
-
29
- describe '#parent' do
30
- subject { described_class.new(:test, 1).parent }
31
- it { is_expected.to eq(:test) }
32
- end
33
-
34
- describe '#capybara_context' do
35
- subject { described_class.new(1, :test).capybara_context }
36
- it { is_expected.to eq(:test) }
37
- end
38
-
39
- describe 'includes proxied capybara methods' do
40
- let(:reciever) { Class.new(described_class).new(:test, 1) }
41
- include_examples :capybara_methods_proxy
42
- end
43
- end
@@ -1,31 +0,0 @@
1
- require 'spec_helper'
2
- require 'howitzer/web/element_dsl'
3
-
4
- RSpec.describe Howitzer::Web::ElementDsl do
5
- let(:klass) do
6
- Class.new do
7
- include Howitzer::Web::ElementDsl
8
- def capybara_scopes
9
- @capybara_scopes ||= Hash.new { |hash, key| hash[key] = [Capybara.current_session] }
10
- @capybara_scopes[Howitzer.session_name]
11
- end
12
- end
13
- end
14
- let(:klass_object) { klass.new }
15
-
16
- it 'returns correct capybara context' do
17
- allow(Capybara).to receive(:current_session) { 'session' }
18
- expect(klass_object.capybara_context).to eq('session')
19
- end
20
-
21
- it 'returns another capybara context' do
22
- allow(Capybara).to receive(:current_session) { 'session' }
23
- expect(klass_object.capybara_context).to eq('session')
24
- Howitzer.session_name = 'session2'
25
- allow(Capybara).to receive(:current_session) { 'session2' }
26
- expect(klass_object.capybara_context).to eq('session2')
27
- end
28
-
29
- include_examples :element_dsl
30
- include_examples :capybara_context_holder
31
- end
@@ -1,203 +0,0 @@
1
- require 'spec_helper'
2
- require 'howitzer/web/page'
3
-
4
- RSpec.describe Howitzer::Web::IframeDsl do
5
- let(:fb_page_class) do
6
- Class.new(Howitzer::Web::Page) do
7
- section :navbar, :xpath, './body' do
8
- element :like_button, '#foo_id'
9
- end
10
- end
11
- end
12
- let(:nested_class) do
13
- module Foo
14
- Class.new(Howitzer::Web::Page) do
15
- section :navbar, :xpath, './body' do
16
- element :like_button, '#foo_id'
17
- end
18
- end
19
- end
20
- end
21
- let(:double_nested_class) do
22
- module Foo
23
- module Bar
24
- Class.new(Howitzer::Web::Page) do
25
- section :navbar, :xpath, './body' do
26
- element :like_button, '#foo_id'
27
- end
28
- end
29
- end
30
- end
31
- end
32
-
33
- let(:web_page_class) do
34
- Class.new(Howitzer::Web::Page)
35
- end
36
-
37
- before do
38
- allow_any_instance_of(fb_page_class).to receive(:check_validations_are_defined!)
39
- allow_any_instance_of(web_page_class).to receive(:check_validations_are_defined!)
40
- stub_const('FbPage', fb_page_class)
41
- stub_const('Foo::FbPage', nested_class)
42
- stub_const('Foo::Bar::FbHomePage', double_nested_class)
43
- allow(Howitzer::Web::Page).to receive(:descendants) { [FbPage, Foo::FbPage, Foo::Bar::FbHomePage] }
44
- end
45
-
46
- describe '.iframe' do
47
- context 'when selector is integer' do
48
- subject do
49
- web_page_class.class_eval do
50
- iframe :fb, 1
51
- end
52
- web_page_class
53
- end
54
-
55
- it 'should create public :fb_iframe instance method' do
56
- expect(subject.instance.public_methods(false)).to include(:fb_iframe)
57
- end
58
- it 'should create public :has_fb_iframe? instance method' do
59
- expect(subject.instance.public_methods(false)).to include(:has_fb_iframe?)
60
- end
61
- it 'should create public :has_no_fb_iframe? instance method' do
62
- expect(subject.instance.public_methods(false)).to include(:has_no_fb_iframe?)
63
- end
64
- it 'should be protected class method' do
65
- expect { subject.iframe :bar }.to raise_error(NoMethodError)
66
- expect(subject.protected_methods(true)).to include(:iframe)
67
- end
68
- end
69
-
70
- context 'when selector is not specified' do
71
- subject do
72
- web_page_class.class_eval do
73
- iframe :fb
74
- end
75
- web_page_class
76
- end
77
-
78
- it 'should raise error' do
79
- expect { subject }.to raise_error(ArgumentError, 'iframe selector arguments must be specified')
80
- end
81
- end
82
-
83
- context 'when class defined explicity' do
84
- subject do
85
- web_page_class.class_eval do
86
- iframe :fb, FbPage, 1
87
- end
88
- web_page_class
89
- end
90
- it 'should find page class specified' do
91
- expect(subject).to eql(web_page_class)
92
- end
93
- end
94
-
95
- context 'when frame nested in module' do
96
- subject do
97
- web_page_class.class_eval do
98
- iframe :foo_fb, 1
99
- end
100
- web_page_class
101
- end
102
- it 'should find page class nested in module' do
103
- expect(subject).to eql(web_page_class)
104
- end
105
- end
106
-
107
- context 'when frame nested in module nested in module' do
108
- subject do
109
- web_page_class.class_eval do
110
- iframe :foo_bar_fb_home, 1
111
- end
112
- web_page_class
113
- end
114
- it 'should find class nested in modules' do
115
- expect(subject).to eql(web_page_class)
116
- end
117
- end
118
- end
119
-
120
- include_examples :capybara_context_holder
121
-
122
- describe 'dynamic_methods' do
123
- let(:web_page_object) { web_page_class.instance }
124
- let(:kontext) { double(:kontext) }
125
- before do
126
- allow(Capybara).to receive(:current_session) { kontext }
127
- end
128
- after { subject }
129
-
130
- describe '#name_iframe' do
131
- let(:block) { proc {} }
132
- context 'when no options' do
133
- subject { web_page_object.fb_iframe(&block) }
134
- before { web_page_class.class_eval { iframe :fb, 'foo' } }
135
- it do
136
- expect(kontext).to receive(:within_frame)
137
- .with('foo') { |&block| block.call }
138
- expect(block).to receive(:call).with(fb_page_class.instance)
139
- expect(fb_page_class).to receive(:displayed?).with(no_args)
140
- end
141
- end
142
- context 'when all possible options' do
143
- subject { web_page_object.fb_iframe(wait: 10, text: 'new', &block) }
144
- before { web_page_class.class_eval { iframe :fb, :xpath, './/foo', match: :first, text: 'origin' } }
145
- it do
146
- expect(kontext).to receive(:within_frame)
147
- .with(:xpath, './/foo', match: :first, wait: 10, text: 'new') { |&block| block.call }
148
- expect(block).to receive(:call).with(fb_page_class.instance)
149
- expect(fb_page_class).to receive(:displayed?).with(no_args)
150
- end
151
- end
152
- end
153
- describe '#has_name_iframe?' do
154
- subject { web_page_object.has_fb_iframe?(wait: 1, text: 'new') }
155
- context 'when first argument is integer' do
156
- before { web_page_class.class_eval { iframe :fb, 1, match: :first, text: 'origin' } }
157
- it do
158
- expect(kontext).to receive(:has_selector?)
159
- .with('iframe:nth-of-type(2)', match: :first, wait: 1, text: 'new')
160
- end
161
- end
162
- context 'when first argument is string' do
163
- before { web_page_class.class_eval { iframe :fb, 'loko', match: :first, text: 'origin' } }
164
- it { expect(kontext).to receive(:has_selector?).with(:frame, 'loko', match: :first, wait: 1, text: 'new') }
165
- end
166
- context 'when first argument is hash' do
167
- before { web_page_class.class_eval { iframe :fb, name: 'loko', match: :first, text: 'origin' } }
168
- it do
169
- expect(kontext).to receive(:has_selector?)
170
- .with(:frame, name: 'loko', match: :first, wait: 1, text: 'new')
171
- end
172
- end
173
- context 'when first argument is symbol' do
174
- before { web_page_class.class_eval { iframe :fb, :xpath, './/foo', match: :first, text: 'origin' } }
175
- it { expect(kontext).to receive(:has_selector?).with(:xpath, './/foo', match: :first, wait: 1, text: 'new') }
176
- end
177
- end
178
- describe '#has_no_name_iframe?' do
179
- subject { web_page_object.has_no_fb_iframe?(wait: 1, text: 'new') }
180
- context 'when first argument is integer' do
181
- before { web_page_class.class_eval { iframe :fb, 1, match: :first, text: 'origin' } }
182
- it do
183
- expect(kontext).to receive(:has_no_selector?)
184
- .with('iframe:nth-of-type(2)', match: :first, wait: 1, text: 'new')
185
- end
186
- end
187
- context 'when first argument is string' do
188
- before { web_page_class.class_eval { iframe :fb, 'loko', match: :first, text: 'origin' } }
189
- it { expect(kontext).to receive(:has_no_selector?).with(:frame, 'loko', match: :first, wait: 1, text: 'new') }
190
- end
191
- context 'when first argument is hash' do
192
- before { web_page_class.class_eval { iframe :fb, name: 'loko', match: :first, text: 'origin' } }
193
- it do
194
- expect(kontext).to receive(:has_no_selector?).with(:frame, name: 'loko', match: :first, wait: 1, text: 'new')
195
- end
196
- end
197
- context 'when first argument is symbol' do
198
- before { web_page_class.class_eval { iframe :fb, :xpath, './/foo', match: :first, text: 'origin' } }
199
- it { expect(kontext).to receive(:has_no_selector?).with(:xpath, './/foo', match: :first, wait: 1, text: 'new') }
200
- end
201
- end
202
- end
203
- end
@@ -1,74 +0,0 @@
1
- require 'spec_helper'
2
- require 'howitzer/web/page_dsl'
3
-
4
- RSpec.describe Howitzer::Web::PageDsl do
5
- let(:page) { Class.new { include Howitzer::Web::PageDsl } }
6
-
7
- describe '.on' do
8
- subject { page.on { 1 } }
9
- before { expect(Howitzer::Web::PageDsl::PageScope).to receive(:new).with(page) }
10
- it { is_expected.to be_nil }
11
- end
12
- end
13
-
14
- RSpec.describe Howitzer::Web::PageDsl::PageScope do
15
- let(:fake_page) { double }
16
- let(:page) { Class.new }
17
- before { allow(page).to receive(:given) { fake_page } }
18
-
19
- describe '.new' do
20
- subject { described_class.new(page) { bar } }
21
- before { expect_any_instance_of(described_class).to receive(:bar).with(no_args) { true } }
22
- it { is_expected.to be_a(described_class) }
23
- end
24
-
25
- describe '#is_expected' do
26
- let(:scope) { described_class.new(page) { 1 } }
27
- subject { scope.is_expected }
28
- before { expect(scope).to receive(:expect).with(fake_page) { true } }
29
- it { is_expected.to eq(true) }
30
- end
31
-
32
- describe '#method_missing' do
33
- context 'when starts with be_' do
34
- let(:scope) { described_class.new(page) { 1 } }
35
- subject { scope.be_a(described_class) }
36
- it { expect(subject.class).to eq(RSpec::Matchers::BuiltIn::BeAKindOf) }
37
- end
38
-
39
- context 'when starts with have_' do
40
- let(:scope) { described_class.new(page) { 1 } }
41
- subject { scope.have_content(described_class) }
42
- it { expect(subject.class).to eq(RSpec::Matchers::BuiltIn::Has) }
43
- end
44
-
45
- context 'when out' do
46
- let(:outer_context) do
47
- Class.new do
48
- def initialize(klass)
49
- @klass = klass
50
- @a = 5
51
- end
52
-
53
- def scope
54
- @klass.new(nil) { 1 }
55
- end
56
-
57
- def secret
58
- '***'
59
- end
60
- end
61
- end
62
- let(:scope) { outer_context.new(described_class).scope }
63
- it { expect(scope.out(:@a)).to eq(5) }
64
- it { expect(scope.out(:secret)).to eq('***') }
65
- end
66
-
67
- context 'when starts other prefix' do
68
- let(:scope) { described_class.new(page) { 1 } }
69
- subject { scope.foo(1, 2, 3) }
70
- before { expect(fake_page).to receive(:foo).with(1, 2, 3) { true } }
71
- it { is_expected.to eq(true) }
72
- end
73
- end
74
- end