acceptance_test2 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d56f22549436449880aaf128ab8e5e4bfbdf2a65
4
+ data.tar.gz: f9521bc9149ce7d9092dd23dd02b6711ccd01048
5
+ SHA512:
6
+ metadata.gz: 07ea431d1e6bcca3839d2d2510e0a2ec92c32df620cc191ee4b84b6fa598cec0999e58a6be489ca929e8fadedbc4e373415898013920165ac8b832949534f9ce
7
+ data.tar.gz: 37f1788539ae3f578f8ae2cd5f6979c592d62670158f16949dd687b9715a1510a3d70aa0e629307169682eb3030d34be673f70447f729dbae9132008191aadfe
data/.gitignore ADDED
@@ -0,0 +1,40 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /vendor/bundle
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ # Gemfile.lock
31
+ # .ruby-version
32
+ # .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
36
+
37
+ Gemfile.lock
38
+ .vagrant
39
+ output
40
+ .idea
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ acceptance_test2
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2.3
data/CHANGES ADDED
@@ -0,0 +1,5 @@
1
+ = AcceptanceTest 2 Changelog
2
+
3
+ == Version 0.9.0
4
+
5
+ * Initial release.
data/Gemfile ADDED
@@ -0,0 +1,31 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :development do
4
+ gem "gemspec_deps_gen"
5
+ gem "gemcutter"
6
+ end
7
+
8
+ group :minitest, :default do
9
+ gem "minitest", "~> 5.8.1"
10
+ gem "minitest-capybara", "~> 0.7.2"
11
+ gem "minitest-metadata", "~> 0.6.0"
12
+ gem "minitest-reporters", "~> 1.1.2"
13
+ end
14
+
15
+ group :capybara, :default do
16
+ gem "capybara", "~> 2.5.0"
17
+ gem "capybara-extensions", "~> 0.4.1"
18
+ gem "selenium-webdriver", "~> 2.47.1"
19
+ gem "capybara-webkit", "~> 1.7.1"
20
+ end
21
+
22
+ group :rspec, :default do
23
+ gem "rspec", "~> 3.3.0"
24
+ end
25
+
26
+ group :turnip, :default do
27
+ gem "turnip", "~> 1.3.1"
28
+ gem "turnip_formatter", "~> 0.3.4"
29
+ gem "gnawrnip", "~> 0.3.2"
30
+ #gem "turnip", :git => 'https://github.com/jnicklas/turnip.git', :branch => '2_0_0_rc1'
31
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Alexander Shvets
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,280 @@
1
+ # AcceptanceTest 2 - Gem that simplifies configuration and running of acceptance tests
2
+
3
+ ## Installation
4
+
5
+ Add this line to to your Gemfile:
6
+
7
+ ```ruby
8
+ gem "acceptance_test"
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ ```bash
14
+ $ bundle
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ # With minitest
20
+
21
+ ```ruby
22
+ require 'minitest/autorun'
23
+ require 'minitest/capybara'
24
+ require 'minitest-metadata'
25
+
26
+ require 'acceptance_test/minitest/acceptance_test'
27
+ require 'acceptance_test/capybara/capybara_helper'
28
+
29
+ class GoogleSearchTest < AcceptanceSpec
30
+
31
+ before do
32
+ config = {app_host: "http://www.google.com"}
33
+
34
+ CapybaraHelper.instance.before_test config
35
+ end
36
+
37
+ after do
38
+ CapybaraHelper.instance.after_test
39
+ end
40
+
41
+ it "finding the answer to the question of life" do
42
+ visit "/"
43
+
44
+ fill_in "q", :with => "the answer to the question of life"
45
+
46
+ find(:xpath, "//button[@name='btnG']").click # submit
47
+
48
+ page.must_have_content('42')
49
+ end
50
+ end
51
+ ```
52
+
53
+ # With rspec
54
+
55
+ ```ruby
56
+ require 'acceptance_test/rspec/rspec_helper'
57
+
58
+ config = {app_host: "http://wikipedia.org"}
59
+
60
+ RspecHelper.instance.create_shared_context "WikipediaSearch"
61
+
62
+ RSpec.describe 'Wikipedia Search' do
63
+ include_context "WikipediaSearch", config
64
+
65
+ it "searches on wikipedia web site" do
66
+ visit('/')
67
+
68
+ fill_in "searchInput", :with => "Capybara"
69
+
70
+ find(".formBtn", match: :first).click
71
+
72
+ expect(page).to have_content "Hydrochoerus hydrochaeris"
73
+ end
74
+ end
75
+ ```
76
+
77
+ # With turnip
78
+
79
+ ```ruby
80
+ # turnip_helper.rb
81
+
82
+ require 'acceptance_test/rspec/rspec_helper'
83
+ require 'acceptance_test/turnip/turnip_helper'
84
+
85
+ $LOAD_PATH.unshift File.expand_path("../spec/support/features", File.dirname(__FILE__))
86
+
87
+ RspecHelper.instance.configure app_host: "http://wikipedia.org"
88
+
89
+ TurnipHelper.instance.configure report_file: 'output/wikipedia-turnip-report.html', steps_dir: "spec/support/features"
90
+
91
+ cmd = 'open -a "/Applications/Google Chrome.app" output/wikipedia-turnip-report.html'
92
+
93
+ RspecHelper.instance.run_on_specs_finished(cmd)
94
+ ```
95
+
96
+ ```ruby
97
+ module CommonSteps
98
+ step "I should see :text" do |text|
99
+ expect(page).to have_content text
100
+ end
101
+ end
102
+ ```
103
+
104
+ ```ruby
105
+ require 'steps/common_steps'
106
+
107
+ steps_for :search_with_drivers do
108
+ include CommonSteps
109
+
110
+ step "I am on wikipedia.com" do
111
+ visit('/')
112
+ end
113
+
114
+ step "I enter word :word" do |word|
115
+ fill_in "searchInput", :with => word
116
+ end
117
+
118
+ step "I submit request" do
119
+ find(".formBtn", match: :first).click
120
+ end
121
+
122
+ end
123
+ ```
124
+
125
+ ```ruby
126
+ module MainPageSteps
127
+ step :visit_home_page, "I am on wikipedia.com"
128
+ def visit_home_page
129
+ visit('/')
130
+ end
131
+
132
+ step :enter_word, "I enter word :word"
133
+ def enter_word word
134
+ fill_in "searchInput", :with => word
135
+ end
136
+
137
+ step :submit_request, "I submit request"
138
+ def submit_request
139
+ find(".formBtn", match: :first).click
140
+ end
141
+ end
142
+ ```
143
+
144
+ ```ruby
145
+ require 'steps/common_steps'
146
+ require 'steps/main_page_steps'
147
+
148
+ steps_for :search_with_pages do
149
+ include CommonSteps
150
+ include MainPageSteps
151
+ end
152
+ ```
153
+
154
+ ```feature
155
+ Feature: Using Wikipedia
156
+
157
+ @selenium
158
+ @search_with_drivers
159
+ Scenario: Searching with selenium for a term with submit
160
+
161
+ Given I am on wikipedia.com
162
+ When I enter word "Capybara"
163
+ And I submit request
164
+ Then I should see "Hydrochoerus hydrochaeris"
165
+
166
+ @webkit
167
+ @search_with_drivers
168
+ Scenario: Searching with selenium for a term with submit
169
+
170
+ Given I am on wikipedia.com
171
+ When I enter word "Capybara"
172
+ And I submit request
173
+ Then I should see "Hydrochoerus hydrochaeris"
174
+ ```
175
+
176
+ ```feature
177
+ Feature: Using Wikipedia
178
+
179
+ @search_with_pages
180
+ Scenario: Searching with selenium for a term with submit
181
+
182
+ Given I am on wikipedia.com
183
+ When I enter word "Capybara"
184
+ And I submit request
185
+ Then I should see "Capybara"
186
+ ```
187
+
188
+
189
+
190
+
191
+ # Without selenium configuration
192
+
193
+ Your spec class:
194
+
195
+ ```ruby
196
+ require 'acceptance_test'
197
+
198
+ describe 'Google Search' do
199
+
200
+ include_context "AcceptanceTest"
201
+
202
+ before :all do
203
+ acceptance_test.app_host = "http://www.google.com"
204
+ end
205
+
206
+ it "uses selenium driver", driver: :selenium, exclude: false do
207
+ visit('/')
208
+
209
+ fill_in "q", :with => "Capybara"
210
+
211
+ #save_and_open_page
212
+
213
+ find("#gbqfbw button").click
214
+
215
+ all(:xpath, "//li[@class='g']/h3/a").each { |a| puts a[:href] }
216
+ end
217
+ end
218
+ ```
219
+
220
+ # With selenium configuration
221
+
222
+ Your spec class:
223
+
224
+ ```ruby
225
+ require 'acceptance_test'
226
+
227
+ describe 'Google Search' do
228
+
229
+ include_context "AcceptanceTest"
230
+
231
+ before :all do
232
+ selenium_config_file = "spec/features/selenium.yml"
233
+ selenium_config_name = "test"
234
+
235
+ acceptance_test.load_selenium_config selenium_config_file, selenium_config_name
236
+ end
237
+
238
+ it "do something" do
239
+ # ...
240
+ end
241
+ end
242
+ ```
243
+
244
+ # Using Vagrant
245
+
246
+ 1. Install Virtual Box & Vagrant
247
+
248
+ brew install caskroom/cask/brew-cask
249
+
250
+ brew cask install virtualbox
251
+ brew cask install vagrant
252
+
253
+ 2. Start Vagrant
254
+
255
+ vagrant up
256
+
257
+ 3. Run docker container:
258
+
259
+ vagrant docker-run default -- echo hi
260
+
261
+
262
+ app -- rake db:migrate
263
+
264
+
265
+ Capybara resources:
266
+
267
+ https://github.com/wojtekmach/minitest-capybara
268
+ https://dockyard.com/blog/2013/11/11/capybara-extensions
269
+ http://www.elabs.se/blog/51-simple-tricks-to-clean-up-your-capybara-tests
270
+ https://robots.thoughtbot.com/write-reliable-asynchronous-integration-tests-with-capybara
271
+
272
+ https://gist.github.com/MicahElliott/2407918
273
+
274
+ ## Contributing
275
+
276
+ 1. Fork it
277
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
278
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
279
+ 4. Push to the branch (`git push origin my-new-feature`)
280
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env rake
2
+
3
+ $LOAD_PATH.unshift File.expand_path("lib", File.dirname(__FILE__))
4
+
5
+ require "rspec/core/rake_task"
6
+ require "acceptance_test/version"
7
+ require "gemspec_deps_gen/gemspec_deps_gen"
8
+
9
+ version = AcceptanceTest::VERSION
10
+ project_name = File.basename(Dir.pwd)
11
+
12
+ task :gen do
13
+ generator = GemspecDepsGen.new
14
+
15
+ generator.generate_dependencies "spec", "#{project_name}.gemspec.erb", "#{project_name}.gemspec"
16
+ end
17
+
18
+ task :build => :gen do
19
+ system "gem build #{project_name}.gemspec"
20
+ end
21
+
22
+ task :install => :build do
23
+ system "gem install #{project_name}-#{version}.gem"
24
+ end
25
+
26
+ task :uninstall do
27
+ system "gem uninstall #{project_name}"
28
+ end
29
+
30
+ task :release => :build do
31
+ system "gem push #{project_name}-#{version}.gem"
32
+ end
33
+
34
+ require 'rake/testtask'
35
+
36
+ task :default => :test
37
+
38
+ desc 'Run minitest tests'
39
+ Rake::TestTask.new do |t|
40
+ t.libs.push %w(spec lib)
41
+ t.test_files = FileList[
42
+ #'spec/unit/wikipedia_search_test.rb',
43
+ 'spec/unit/google_search_test.rb'
44
+ ]
45
+ t.verbose = true
46
+ end
47
+
48
+ desc 'Run rspec tests'
49
+ RSpec::Core::RakeTask.new('rspec') do |t|
50
+ t.pattern = "spec/unit/wikipedia_search_spec.rb"
51
+ t.rspec_opts = "--color"
52
+ end
53
+
54
+ desc 'Run turnip tests'
55
+ RSpec::Core::RakeTask.new('turnip') do |t|
56
+ t.pattern = "spec/features/**/*.feature"
57
+ t.rspec_opts = "--color -Ispec/support/features -r turnip/rspec"
58
+ end
59
+