acceptance_test 1.5.4 → 1.5.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MGRkNjZjNDQ4MDEyOGU2YTc3MGU0MzQ3OWI4M2ZhYmVkZGQyNjBiOQ==
4
+ MzIxZjhmY2Y3ODZhODMyOWYwNGJmOTVmMWVkZjI0MjkxN2UyMTU0Mw==
5
5
  data.tar.gz: !binary |-
6
- OTdkOTFiMzJkOTc3YTMwMjQ4YTY4MWU5YWUwNzNlNDMzODc0ODk4MQ==
6
+ OTQ3YmY0MGU2Y2IyNTViNTMxNWNlZGJlZTJiYTEyODcxNWI4MjNmNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- N2EyMTZlM2U0MmY4NTU3Y2ZjNWQ1OGVjYWM0ZjFjMDMyZDJhYTAwNjMzOWFm
10
- MzdmM2EzZGU2MTE4OTMxZDUyYTNjZjlkMjQ4Mzk1NWZhMzQ1ZGZiNWVkNzk2
11
- N2U2NWRhNTM1Nzk5MTQ2NTEyMmUzMDAwNmEyYTNmZWVlMzdlMGE=
9
+ OWE3ZGNkMTA2YTVhYzc0NDc0Y2YyODEzODQ0ZmQ2NmI5NzUwYTMyNjI1NGE4
10
+ YmJjMTBmNTcwNjNkMjMyYTY3N2Y0OTQ5MjU5ZTU4NmFlMmExODIzMzQ2YzBi
11
+ M2Q5NmJhYjE4NzhiMmU1OTJhZDBmZjc4NTk5YTFjYTEwOWI2NGY=
12
12
  data.tar.gz: !binary |-
13
- ZTA5NTUzNmViMTYyMzc4ZmEyZjIwYzhhYTM4YjQ3MGEyMjY5MmY2Y2ZmYWU0
14
- YTE0OWZiMTczMWQzNzJmMTM2NDhhYzk4N2QwMzJkNTVlMzVmYjM0MWNjZDdl
15
- MDRlMGQ5YmQyMGNkNmRjOGUzMzU2Y2YzZjI5ODU4N2E3YWMwOWU=
13
+ Yzc0ZWI0ZWVmNjRkOTkyZTAwN2E2MWU5ZTRlYmFhNDJkMWY4MjE2MGQ2YzJh
14
+ MWQ0NWU2ODQzOGUxNTA1NjBiYjc5YTA3OWFhYjUyZTljZDI5OWY0ZTM4OTli
15
+ NWIyN2FhNDc5ZjVhODZjOWE0NzkzNWRjZjRjMTkzN2U1NzVkM2E=
data/CHANGES CHANGED
@@ -131,4 +131,8 @@
131
131
 
132
132
  == Version 1.5.4
133
133
 
134
+ * Bug fixes
135
+
136
+ == Version 1.5.5
137
+
134
138
  * Bug fixes
@@ -6,6 +6,9 @@ require 'capybara'
6
6
  require "capybara/dsl"
7
7
  require 'active_support/core_ext/hash'
8
8
 
9
+ require 'acceptance_test/gherkin_helper'
10
+ require 'acceptance_test/turnip_helper'
11
+
9
12
  class AcceptanceTest
10
13
  include Singleton
11
14
 
@@ -20,6 +23,8 @@ class AcceptanceTest
20
23
  config[:screenshot_dir] = File.expand_path('tmp')
21
24
  end
22
25
 
26
+ set_app_host
27
+
23
28
  Capybara.configure do |conf|
24
29
  conf.default_wait_time = timeout_in_seconds
25
30
  conf.match = :first
@@ -47,7 +52,19 @@ class AcceptanceTest
47
52
  ;
48
53
  end
49
54
 
50
- Capybara.app_host = config[:webapp_url]
55
+ Capybara.default_driver = :selenium
56
+ end
57
+
58
+ def set_app_host
59
+ Capybara.app_host = AcceptanceTest.instance.config[:webapp_url]
60
+ end
61
+
62
+ def enable_external_source data_reader
63
+ GherkinHelper.instance.enable_external_source data_reader
64
+ end
65
+
66
+ def extend_turnip
67
+ TurnipHelper.instance.extend_turnip
51
68
  end
52
69
 
53
70
  def before metadata={}
@@ -134,10 +151,18 @@ class AcceptanceTest
134
151
  [:webkit, :selenium, :poltergeist, :selenium_remote]
135
152
  end
136
153
 
137
- def configure_rspec rspec_conf=nil
154
+ def configure_rspec object=nil
138
155
  acceptance_test = self
139
156
 
140
- rspec_conf = RSpec.configuration unless rspec_conf
157
+ if object
158
+ if object.kind_of? RSpec::Core::Example
159
+ rspec_conf = object.example_group.parent_groups.last
160
+ else
161
+ rspec_conf = object
162
+ end
163
+ else
164
+ rspec_conf = RSpec.configuration
165
+ end
141
166
 
142
167
  rspec_conf.around(:each) do |example|
143
168
  acceptance_test.before(example.metadata)
@@ -0,0 +1,76 @@
1
+ require 'singleton'
2
+
3
+ require 'turnip/define'
4
+
5
+ class TurnipHelper
6
+ include Singleton
7
+
8
+ def extend_turnip
9
+ turnip_define = Turnip::Define
10
+
11
+ turnip_define.class_eval do
12
+ def before &block
13
+ send(:define_method, "before", &block) if block
14
+ end
15
+
16
+ def after &block
17
+ send(:define_method, "after", &block) if block
18
+ end
19
+ end
20
+
21
+ turnip_rspec_execute = Turnip::RSpec::Execute
22
+
23
+ turnip_rspec_execute.class_eval do
24
+ def run_before rspec_root
25
+ self.class.send(:define_method, :rspec_root, lambda { rspec_root })
26
+
27
+ before
28
+ end
29
+
30
+ def run_after rspec_root
31
+ self.class.send(:define_method, :rspec_root, lambda { rspec_root })
32
+
33
+ after
34
+ end
35
+ end
36
+
37
+ turnip_rspec = Turnip::RSpec
38
+
39
+ turnip_rspec.class_eval do
40
+ class << self
41
+ def run(feature_file)
42
+ Turnip::Builder.build(feature_file).features.each do |feature|
43
+ ::RSpec.describe feature.name, feature.metadata_hash do
44
+ rspec_root = self
45
+
46
+ before do
47
+ run_before rspec_root
48
+ example = Turnip::RSpec.fetch_current_example(self)
49
+ # This is kind of a hack, but it will make RSpec throw way nicer exceptions
50
+ example.metadata[:file_path] ||= feature_file
51
+
52
+ feature.backgrounds.map(&:steps).flatten.each do |step|
53
+ run_step(feature_file, step)
54
+ end
55
+ end
56
+ feature.scenarios.each do |scenario|
57
+ instance_eval <<-EOS, feature_file, scenario.line
58
+ describe scenario.name, scenario.metadata_hash do it(scenario.steps.map(&:to_s).join(' -> ')) do
59
+ scenario.steps.each do |step|
60
+ run_step(feature_file, step)
61
+ end
62
+ end
63
+ end
64
+ EOS
65
+ end
66
+ after do
67
+ run_after rspec_root
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+
76
+ end
@@ -1,3 +1,3 @@
1
1
  class AcceptanceTest
2
- VERSION = "1.5.4"
2
+ VERSION = "1.5.5"
3
3
  end
@@ -1,3 +1,3 @@
1
- Capybara
2
- Wombat
3
- Echidna
1
+ Capybara, Hydrochoerus hydrochaeris
2
+ Wombat, quadrupedal marsupials
3
+ Echidna, Tachyglossidae
@@ -4,28 +4,28 @@ Feature: Using Wikipedia
4
4
  Given I am within wikipedia.com
5
5
 
6
6
  @selenium
7
- @wikipedia
7
+ @search_with_drivers
8
8
  Scenario: Searching with selenium for a term with submit
9
9
 
10
10
  Given I am on wikipedia.com
11
11
  When I enter word "Capybara"
12
12
  And I click submit button
13
- Then I should see results: "Capybara"
13
+ Then I should see "Capybara"
14
14
 
15
15
  @webkit
16
- @wikipedia
16
+ @search_with_drivers
17
17
  Scenario: Searching with selenium for a term with submit
18
18
 
19
19
  Given I am on wikipedia.com
20
20
  When I enter word "Capybara"
21
21
  And I click submit button
22
- Then I should see results: "Capybara"
22
+ Then I should see "Capybara"
23
23
 
24
24
  @poltergeist
25
- @wikipedia
25
+ @search_with_drivers
26
26
  Scenario: Searching with selenium for a term with submit
27
27
 
28
28
  Given I am on wikipedia.com
29
29
  When I enter word "Capybara"
30
30
  And I click submit button
31
- Then I should see results: "Capybara"
31
+ Then I should see "Capybara"
@@ -0,0 +1,32 @@
1
+ Feature: Using Wikipedia
2
+
3
+ Background: within wikipedia.com context
4
+ Given I am within wikipedia.com
5
+
6
+ @selenium
7
+ @search_with_examples_from_csv
8
+ Scenario Outline: Searching with selenium for a term with submit (embedded data)
9
+
10
+ Given I am on wikipedia.com
11
+ When I enter word <keyword>
12
+ And I click submit button
13
+ Then I should see "<result>"
14
+
15
+ Examples:
16
+ | keyword | result |
17
+ | Capybara | Hydrochoerus hydrochaeris |
18
+ | Wombat | quadrupedal marsupials |
19
+ | Echidna | Tachyglossidae |
20
+
21
+ @selenium
22
+ @search_with_examples_from_csv
23
+ Scenario Outline: Searching with selenium for a term with submit (external data)
24
+
25
+ Given I am on wikipedia.com
26
+ When I enter word <keyword>
27
+ And I click submit button
28
+ Then I should see "<result>"
29
+
30
+ Examples:
31
+ | keyword | result |
32
+ | file:spec/features/data.csv ||
@@ -0,0 +1,20 @@
1
+ Feature: Using Wikipedia
2
+
3
+ Background: within wikipedia.com context
4
+ Given I am within wikipedia.com
5
+
6
+ @selenium
7
+ @search_with_table
8
+ Scenario: Searching with selenium for a term with submit (embedded data)
9
+
10
+ Given I am on wikipedia.com
11
+ And I have the following data:
12
+ | key | value |
13
+ | keyword | Capybara |
14
+ | result | Hydrochoerus hydrochaeris |
15
+ Then "keyword" should be "Capybara"
16
+ And "result" should be "Hydrochoerus hydrochaeris"
17
+
18
+ When I enter word <keyword>
19
+ And I click submit button
20
+ Then I should see <result>
@@ -0,0 +1,5 @@
1
+ module CommonSteps
2
+ step "I should see :text" do |text|
3
+ expect(page).to have_content text
4
+ end
5
+ end
@@ -0,0 +1,39 @@
1
+ require 'features/steps/common_steps'
2
+
3
+ RSpec.configure do |config|
4
+ config.before(:search_with_drivers => true) do |example|
5
+ AcceptanceTest.instance.configure_rspec example
6
+ end
7
+ end
8
+
9
+ steps_for :search_with_drivers do
10
+ include CommonSteps
11
+
12
+ # before do
13
+ # AcceptanceTest.instance.configure_rspec rspec_root
14
+ #
15
+ # end
16
+ #
17
+ # after do
18
+ # puts "after"
19
+ # end
20
+
21
+ step "I am within wikipedia.com" do
22
+ puts Capybara.current_driver
23
+
24
+ AcceptanceTest.instance.set_app_host
25
+ end
26
+
27
+ step "I am on wikipedia.com" do
28
+ visit('/')
29
+ end
30
+
31
+ step "I enter word :word" do |word|
32
+ fill_in "searchInput", :with => word
33
+ end
34
+
35
+ step "I click submit button" do
36
+ find(".formBtn", match: :first).click
37
+ end
38
+
39
+ end
@@ -1,7 +1,7 @@
1
- module WikipediaSteps
1
+ steps_for :search_with_examples_from_csv do
2
2
 
3
3
  step "I am within wikipedia.com" do
4
- self.class.include_context "WikipediaAcceptanceTest"
4
+ self.class.include_context "SearchWithExamplesFromCsvAcceptanceTest"
5
5
  end
6
6
 
7
7
  step "I am on wikipedia.com" do
@@ -16,7 +16,7 @@ module WikipediaSteps
16
16
  find(".formBtn", match: :first).click
17
17
  end
18
18
 
19
- step "I should see results: :content" do |text|
19
+ step "I should see :text" do |text|
20
20
  expect(page).to have_content text
21
21
  end
22
22
  end
@@ -0,0 +1,38 @@
1
+ steps_for :search_with_table do
2
+ step "I am within wikipedia.com" do
3
+ self.class.include_context "SearchWithTableAcceptanceTest"
4
+ end
5
+
6
+ step "I am on wikipedia.com" do
7
+ visit('/')
8
+ end
9
+
10
+ step "I have the following data:" do |table|
11
+ @test_data = {}
12
+
13
+ table.hashes.each do |hash|
14
+ @test_data[hash['key']] = hash['value']
15
+ end
16
+ end
17
+
18
+ step ":key should be :value" do |key, value|
19
+ expect(@test_data[key]).to eq value
20
+ end
21
+
22
+ step "I should see <:key>" do |key|
23
+ expect(page).to have_content @test_data[key]
24
+ end
25
+
26
+ step "I enter word <:key>" do |key|
27
+ fill_in "searchInput", :with => @test_data[key]
28
+ end
29
+
30
+ step "I click submit button" do
31
+ find(".formBtn", match: :first).click
32
+ end
33
+
34
+ step "I should see :text" do |text|
35
+ expect(page).to have_content text
36
+ end
37
+
38
+ end
@@ -2,18 +2,27 @@ require 'yaml'
2
2
  require 'csv'
3
3
  require 'active_support/core_ext/hash'
4
4
 
5
- require 'acceptance_test/acceptance_test_helper'
5
+ require 'acceptance_test'
6
6
 
7
- helper = AcceptanceTestHelper.instance
7
+ acceptance_test = AcceptanceTest.instance
8
+
9
+ # enable external source for gherkin
8
10
 
9
11
  data_reader = lambda {|source_path| CSV.read(File.expand_path(source_path)) }
10
- helper.enable_external_source data_reader # enable external source for gherkin
11
12
 
12
- helper.register_turnip_steps 'features/steps/wikipedia_steps',
13
- 'WikipediaSteps', :wikipedia, "WikipediaAcceptanceTest"
13
+ acceptance_test.enable_external_source data_reader
14
+
15
+ # acceptance_test.extend_turnip
16
+
17
+ require 'features/steps/search_with_drivers_steps'
18
+ require 'features/steps/search_with_examples_from_csv_steps'
19
+ require 'features/steps/search_with_table_steps'
20
+
21
+ AcceptanceTest.instance.create_shared_context "SearchWithDriversAcceptanceTest"
22
+ AcceptanceTest.instance.create_shared_context "SearchWithExamplesFromCsvAcceptanceTest"
23
+ AcceptanceTest.instance.create_shared_context "SearchWithTableAcceptanceTest"
14
24
 
15
25
  config_name = File.expand_path("spec/acceptance_config.yml")
16
26
  config = HashWithIndifferentAccess.new(YAML.load_file(config_name))
17
27
 
18
- helper.configure config
19
-
28
+ acceptance_test.configure config
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acceptance_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.4
4
+ version: 1.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Shvets
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-07 00:00:00.000000000 Z
11
+ date: 2014-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gemspec_deps_gen
@@ -71,18 +71,21 @@ files:
71
71
  - features/wikipedia/wikipedia_search_from_csv.feature
72
72
  - lib/acceptance_test.rb
73
73
  - lib/acceptance_test/acceptance_test.rb
74
- - lib/acceptance_test/acceptance_test_helper.rb
75
74
  - lib/acceptance_test/gherkin_helper.rb
76
75
  - lib/acceptance_test/page.rb
77
76
  - lib/acceptance_test/page_set.rb
78
77
  - lib/acceptance_test/screenshot_maker.rb
78
+ - lib/acceptance_test/turnip_helper.rb
79
79
  - lib/acceptance_test/version.rb
80
80
  - spec/acceptance_config.yml
81
81
  - spec/features/data.csv
82
- - spec/features/steps/hook.rb
83
- - spec/features/steps/wikipedia_steps.rb
84
- - spec/features/wikipedia_search.feature
85
- - spec/features/wikipedia_search_from_csv.feature
82
+ - spec/features/search_with_drivers.feature
83
+ - spec/features/search_with_examples_from_csv.feature
84
+ - spec/features/search_with_table.feature
85
+ - spec/features/steps/common_steps.rb
86
+ - spec/features/steps/search_with_drivers_steps.rb
87
+ - spec/features/steps/search_with_examples_from_csv_steps.rb
88
+ - spec/features/steps/search_with_table_steps.rb
86
89
  - spec/support/wikipedia/main_page.rb
87
90
  - spec/support/wikipedia/wikipedia_page_set.rb
88
91
  - spec/turnip_helper.rb
@@ -122,10 +125,13 @@ test_files:
122
125
  - features/wikipedia/wikipedia_search_from_csv.feature
123
126
  - spec/acceptance_config.yml
124
127
  - spec/features/data.csv
125
- - spec/features/steps/hook.rb
126
- - spec/features/steps/wikipedia_steps.rb
127
- - spec/features/wikipedia_search.feature
128
- - spec/features/wikipedia_search_from_csv.feature
128
+ - spec/features/search_with_drivers.feature
129
+ - spec/features/search_with_examples_from_csv.feature
130
+ - spec/features/search_with_table.feature
131
+ - spec/features/steps/common_steps.rb
132
+ - spec/features/steps/search_with_drivers_steps.rb
133
+ - spec/features/steps/search_with_examples_from_csv_steps.rb
134
+ - spec/features/steps/search_with_table_steps.rb
129
135
  - spec/support/wikipedia/main_page.rb
130
136
  - spec/support/wikipedia/wikipedia_page_set.rb
131
137
  - spec/turnip_helper.rb
@@ -1,35 +0,0 @@
1
- require 'singleton'
2
- require 'turnip/capybara'
3
- require 'turnip/rspec'
4
-
5
- require 'acceptance_test'
6
- require 'acceptance_test/gherkin_helper'
7
-
8
- class AcceptanceTestHelper
9
- include Singleton
10
-
11
- def initialize
12
- RSpec.configure do |config|
13
- config.include Capybara::DSL
14
- end
15
- end
16
-
17
- def configure config
18
- AcceptanceTest.instance.configure config
19
- end
20
-
21
- def enable_external_source data_reader
22
- GherkinHelper.instance.enable_external_source data_reader
23
- end
24
-
25
- def register_turnip_steps path, class_name, tag, shared_group
26
- require path
27
-
28
- RSpec.configure do |config|
29
- config.include class_name.constantize, tag => true
30
- end
31
-
32
- AcceptanceTest.instance.create_shared_context shared_group
33
- end
34
-
35
- end
@@ -1,89 +0,0 @@
1
- require 'turnip/define'
2
-
3
- # @acceptance_test = AcceptanceTest.new
4
- #
5
- # singleton_class.send :attr_reader, :acceptance_test
6
- #
7
- # step "I am within wikipedia.com" do
8
- # config_name = File.expand_path("spec/acceptance_config.yml")
9
- # config = HashWithIndifferentAccess.new(YAML.load_file(config_name))
10
- #
11
- # WikipediaSteps.acceptance_test.configure config
12
- # end
13
- # attr_reader :acceptance_test
14
-
15
- # before do
16
- # p "before"
17
- # acceptance_test = AcceptanceTest.new true, rspec_scope
18
- #
19
- # config_name = File.expand_path("spec/acceptance_config.yml")
20
- # config = HashWithIndifferentAccess.new(YAML.load_file(config_name))
21
- #
22
- # acceptance_test.configure config
23
- # end
24
- #
25
- # after do
26
- # p "after"
27
- # end
28
-
29
- module Turnip
30
- module Define
31
- def before &block
32
- send(:define_method, "before", &block) if block
33
- end
34
-
35
- def after &block
36
- send(:define_method, "after", &block) if block
37
- end
38
- end
39
- end
40
-
41
- module Turnip
42
- module RSpec
43
- module Execute
44
- def run_before rspec_scope
45
- self.class.send(:define_method, :rspec_scope, lambda { rspec_scope })
46
-
47
- before
48
- end
49
-
50
- def run_after
51
- after
52
- end
53
- end
54
-
55
- class << self
56
- def run(feature_file)
57
- Turnip::Builder.build(feature_file).features.each do |feature|
58
- ::RSpec.describe feature.name, feature.metadata_hash do
59
- rspec_scope = self
60
- before do
61
- run_before rspec_scope
62
- example = Turnip::RSpec.fetch_current_example(self)
63
- # This is kind of a hack, but it will make RSpec throw way nicer exceptions
64
- example.metadata[:file_path] ||= feature_file
65
-
66
- feature.backgrounds.map(&:steps).flatten.each do |step|
67
- run_step(feature_file, step)
68
- end
69
- end
70
- feature.scenarios.each do |scenario|
71
- instance_eval <<-EOS, feature_file, scenario.line
72
- describe scenario.name, scenario.metadata_hash do it(scenario.steps.map(&:to_s).join(' -> ')) do
73
- scenario.steps.each do |step|
74
- run_step(feature_file, step)
75
- end
76
- end
77
- end
78
- EOS
79
- end
80
- after do
81
- run_after
82
- end
83
- end
84
- end
85
- end
86
- end
87
-
88
- end
89
- end
@@ -1,17 +0,0 @@
1
- Feature: Using Wikipedia
2
-
3
- Background: within wikipedia.com context
4
- Given I am within wikipedia.com
5
-
6
- @selenium
7
- @wikipedia
8
- Scenario Outline: Searching with selenium for a term with submit
9
-
10
- Given I am on wikipedia.com
11
- When I enter word <keyword>
12
- And I click submit button
13
- Then I should see results: <keyword>
14
-
15
- Examples:
16
- | keyword |
17
- | file:spec/features/data.csv |