sim 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/README.md +20 -0
- data/lib/sim/html_report.rb +1 -1
- data/lib/sim/local.rb +21 -5
- data/lib/sim/local_phantomjs.rb +22 -3
- data/lib/sim/remote.rb +2 -6
- data/lib/sim/support/config.rb +46 -7
- data/lib/sim/support/rspec_util.rb +1 -1
- data/lib/sim/support/sim_util.rb +7 -0
- data/lib/sim/support/web_testing.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MzQ0ZWE0MzM0ZDYwZDhiNjE0MGM0NGRhMzk2NjEzOTFlZmQzN2RjOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
N2VhMzAyMmQxY2UxYjBkNDZmNjlhZTVlZTllNGJiOGI2MDIwM2Q4ZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Nzc3OTBjODVkOTMzYTNmYjkwOGI4Yzk5ZmQzNzg0OGQ5OGU2N2QyNmQwZWYz
|
10
|
+
NDA0ZjU4N2M2MTg3YzJmNTcwMGEwZmYxM2Q0MGIxZGE3NDczYTc0MzlkMzAz
|
11
|
+
Y2ZjYTI1NmY0Y2QxNTFlZmFmZWRlMmI2ZmUzZmY4OWE0YTg2Mzk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Mzc3Mzg1ZGNkODFmYTA5N2MxNTJiMTg2ZWMyYTBlMzJmZGZlMDRiMWQ1OWVj
|
14
|
+
YTE2ZDQ4ZGEwM2Q1OGYzOTRmM2UzNzBmODVhMGU3YTg5NGYyNGQ4NzAzYzhk
|
15
|
+
NGE4YjdlMzAwODgyYzM2NWMyZGI2Mzc0M2M3MWFiMGY4MDRjMTI=
|
data/README.md
CHANGED
@@ -19,8 +19,28 @@ sim requires Ruby 1.9.3 or later. To install, type:
|
|
19
19
|
gem install sim
|
20
20
|
```
|
21
21
|
|
22
|
+
## Run rspec
|
22
23
|
|
24
|
+
Remotely:
|
25
|
+
```bash
|
26
|
+
bundle exec rspec -r 'sim/remote'
|
27
|
+
```
|
28
|
+
|
29
|
+
Locally:
|
30
|
+
```bash
|
31
|
+
bundle exec rspec -r 'sim/local'
|
32
|
+
```
|
23
33
|
|
34
|
+
Headlessly:
|
35
|
+
```bash
|
36
|
+
bundle exec rspec -r 'sim/local_phantomjs'
|
37
|
+
```
|
38
|
+
|
39
|
+
## Run cucumber with package locally
|
40
|
+
Add the following to root/features/support/env.rb
|
41
|
+
```bash
|
42
|
+
require 'sim/local'
|
43
|
+
```
|
24
44
|
|
25
45
|
|
26
46
|
|
data/lib/sim/html_report.rb
CHANGED
@@ -68,7 +68,7 @@ module HTMLReport
|
|
68
68
|
output_buffer.puts extra_content if extra_content
|
69
69
|
output_buffer.puts " </div>"
|
70
70
|
|
71
|
-
output_buffer.puts "<div class=\"rerun_command\">bundle exec rspec " + example.metadata[:file_path] + ":" + example.metadata[:line_number].to_s +
|
71
|
+
output_buffer.puts "<div class=\"rerun_command\">bundle exec rspec " + example.metadata[:file_path] + ":" + example.metadata[:line_number].to_s + Sim.local_run_args + "</div>"
|
72
72
|
output_buffer.puts "<div class=\"screenshots\">"
|
73
73
|
output_buffer.puts "</div>"
|
74
74
|
print_screenshot(example)
|
data/lib/sim/local.rb
CHANGED
@@ -5,9 +5,25 @@ require 'capybara/rails'
|
|
5
5
|
|
6
6
|
puts "loading local.rb"
|
7
7
|
|
8
|
-
|
9
|
-
Capybara
|
10
|
-
Capybara.
|
11
|
-
Capybara.
|
12
|
-
Capybara
|
8
|
+
def set_local_config()
|
9
|
+
# Capybara local run
|
10
|
+
Capybara.javascript_driver = :selenium
|
11
|
+
Capybara.default_driver = :selenium
|
12
|
+
Capybara.register_driver :selenium do |app|
|
13
|
+
Capybara::Selenium::Driver.new(app, :browser => :chrome)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
if is_rspec()
|
18
|
+
RSpec.configure do |config|
|
19
|
+
config.before(:all) do
|
20
|
+
set_local_config()
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
if is_cucumber()
|
26
|
+
AfterConfiguration do |config|
|
27
|
+
set_local_config()
|
28
|
+
end
|
13
29
|
end
|
data/lib/sim/local_phantomjs.rb
CHANGED
@@ -1,7 +1,26 @@
|
|
1
1
|
require_relative 'all_inc.rb'
|
2
2
|
|
3
|
+
require_relative 'support/config'
|
3
4
|
require 'capybara/rails'
|
4
|
-
|
5
5
|
require 'capybara/poltergeist'
|
6
|
-
|
7
|
-
|
6
|
+
|
7
|
+
|
8
|
+
def set_local_phantomjs_config()
|
9
|
+
# Capybara local phantomjs
|
10
|
+
# Capybara.default_driver = :poltergeist
|
11
|
+
Capybara.javascript_driver = :poltergeist
|
12
|
+
end
|
13
|
+
|
14
|
+
if is_rspec()
|
15
|
+
RSpec.configure do |config|
|
16
|
+
config.before(:all) do
|
17
|
+
set_local_phantomjs_config()
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
if is_cucumber()
|
23
|
+
AfterConfiguration do |config|
|
24
|
+
set_local_phantomjs_config()
|
25
|
+
end
|
26
|
+
end
|
data/lib/sim/remote.rb
CHANGED
@@ -27,7 +27,7 @@ Capybara.register_driver :selenium_chrome do |app|
|
|
27
27
|
Capybara::Selenium::Driver.new(
|
28
28
|
app,
|
29
29
|
:browser => :remote,
|
30
|
-
:url => "http://#{
|
30
|
+
:url => "http://#{Sim.grid_host}:#{Sim.grid_port}/wd/hub",
|
31
31
|
:desired_capabilities => caps
|
32
32
|
)
|
33
33
|
end
|
@@ -42,20 +42,18 @@ Capybara.register_driver :selenium_phantomjs do |app|
|
|
42
42
|
Capybara::Selenium::Driver.new(
|
43
43
|
app,
|
44
44
|
:browser => :remote,
|
45
|
-
:url => "http://#{
|
45
|
+
:url => "http://#{Sim.grid_host}:#{Sim.grid_port}/wd/hub",
|
46
46
|
:desired_capabilities => caps_phantomjs
|
47
47
|
)
|
48
48
|
end
|
49
49
|
|
50
50
|
if is_cucumber()
|
51
|
-
puts "yes"
|
52
51
|
Before do |scenario|
|
53
52
|
set_app_address()
|
54
53
|
end
|
55
54
|
end
|
56
55
|
|
57
56
|
if is_rspec()
|
58
|
-
puts "no"
|
59
57
|
RSpec.configure do |config|
|
60
58
|
config.include Capybara::DSL
|
61
59
|
|
@@ -68,5 +66,3 @@ if is_rspec()
|
|
68
66
|
end
|
69
67
|
end
|
70
68
|
end
|
71
|
-
|
72
|
-
|
data/lib/sim/support/config.rb
CHANGED
@@ -1,10 +1,49 @@
|
|
1
|
-
|
2
|
-
$base_screenshot_dir = 'spec/reports/HTML/screenshots'
|
3
|
-
$local_run_args = ' -r html_formatter.rb -f CapybaraHtmlFormatter -o spec/reports/HTML/index.html -r fail_fast.rb -r local.rb '
|
1
|
+
module Sim
|
4
2
|
|
5
|
-
|
6
|
-
|
3
|
+
class << self
|
4
|
+
attr_writer :cucumber_base_report_dir, :base_screenshot_dir, :local_run_args
|
5
|
+
attr_writer :grid_host,:grid_port
|
6
|
+
attr_writer :webserver_ip,:webserver_port
|
7
|
+
|
8
|
+
def cucumber_base_report_dir
|
9
|
+
@cucumber_base_report_dir
|
10
|
+
end
|
11
|
+
|
12
|
+
def base_screenshot_dir
|
13
|
+
@base_screenshot_dir
|
14
|
+
end
|
15
|
+
|
16
|
+
def local_run_args
|
17
|
+
@local_run_args
|
18
|
+
end
|
19
|
+
|
20
|
+
def grid_host
|
21
|
+
@grid_host
|
22
|
+
end
|
23
|
+
|
24
|
+
def grid_port
|
25
|
+
@grid_port
|
26
|
+
end
|
27
|
+
|
28
|
+
def webserver_ip
|
29
|
+
@webserver_ip
|
30
|
+
end
|
31
|
+
|
32
|
+
def webserver_port
|
33
|
+
@webserver_port
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# set defaults
|
40
|
+
Sim.cucumber_base_report_dir = "features/report"
|
41
|
+
Sim.base_screenshot_dir = 'spec/reports/HTML/screenshots'
|
42
|
+
Sim.local_run_args = ' -r html_formatter.rb -f CapybaraHtmlFormatter -o spec/reports/HTML/index.html -r fail_fast.rb -r local.rb '
|
43
|
+
|
44
|
+
Sim.grid_host = "10.242.1.187"
|
45
|
+
Sim.grid_port = "4444"
|
7
46
|
|
8
47
|
# webserver_ip
|
9
|
-
|
10
|
-
|
48
|
+
#Sim.webserver_ip = '10.242.1.171'
|
49
|
+
#Sim.webserver_port = 3000
|
data/lib/sim/support/sim_util.rb
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# these functions currently do not work properly
|
2
|
+
# which means logic intended for rspec/cucumber
|
3
|
+
# are loaded even when it's not necessary
|
4
|
+
|
5
|
+
# that's okay for now since loading logic for
|
6
|
+
# rspec doesn't hurt a cucumber run and
|
7
|
+
# vice versa
|
1
8
|
def is_cucumber()
|
2
9
|
respond_to? :After
|
3
10
|
end
|
@@ -8,13 +8,13 @@ if is_cucumber
|
|
8
8
|
require_relative 'cucumber_util'
|
9
9
|
require 'capybara/cucumber'
|
10
10
|
|
11
|
-
FileUtils.rm_rf(
|
12
|
-
FileUtils.mkdir(
|
11
|
+
FileUtils.rm_rf(Sim.cucumber_base_report_dir)
|
12
|
+
FileUtils.mkdir(Sim.cucumber_base_report_dir) # cucumber does not auto build directory when capturing screenshot
|
13
13
|
|
14
14
|
After do |scenario|
|
15
15
|
# if(scenario.failed?)
|
16
16
|
img_name = "#{scenario.__id__}.png"
|
17
|
-
path_to_img = File.join(
|
17
|
+
path_to_img = File.join(Sim.cucumber_base_report_dir,img_name)
|
18
18
|
|
19
19
|
page.save_screenshot(path_to_img)
|
20
20
|
|
@@ -29,7 +29,7 @@ if is_rspec
|
|
29
29
|
require 'rspec/rails'
|
30
30
|
|
31
31
|
# TESTING SUITE
|
32
|
-
FileUtils.rm_rf(
|
32
|
+
FileUtils.rm_rf(Sim.base_screenshot_dir)
|
33
33
|
|
34
34
|
RSpec.configure do |config|
|
35
35
|
config.include Capybara::RSpecMatchers
|