rainforest_ruby_runtime 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
1
+ $LOAD_PATH.unshift File.join(__dir__, "../lib")
2
+
3
+ require 'pry'
4
+ require 'awesome_print'
5
+ require 'rainforest_ruby_runtime'
6
+ require 'rspec'
7
+
8
+ ENV['RUNTIME_ENV'] = 'test'
9
+
10
+ RSpec.configure do |config|
11
+ config.color = true
12
+ config.formatter = :documentation
13
+
14
+ config.before(show_output: true) do
15
+ ENV['SHOW_OUTPUT'] = 'true'
16
+ end
17
+ config.after(show_output: true) do
18
+ ENV.delete('SHOW_OUTPUT')
19
+ end
20
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rainforest_ruby_runtime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Mathieu
@@ -9,24 +9,52 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-04-24 00:00:00.000000000 Z
12
+ date: 2018-04-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: bundler
15
+ name: pry
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '1.14'
20
+ version: '0'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - "~>"
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '1.14'
27
+ version: '0'
28
28
  - !ruby/object:Gem::Dependency
29
- name: rake
29
+ name: byebug
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: awesome_print
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec_junit_formatter
30
58
  requirement: !ruby/object:Gem::Requirement
31
59
  requirements:
32
60
  - - ">="
@@ -68,19 +96,19 @@ dependencies:
68
96
  - !ruby/object:Gem::Version
69
97
  version: '3.6'
70
98
  - !ruby/object:Gem::Dependency
71
- name: rspec-expectations
99
+ name: rspec
72
100
  requirement: !ruby/object:Gem::Requirement
73
101
  requirements:
74
- - - "~>"
102
+ - - '='
75
103
  - !ruby/object:Gem::Version
76
- version: '3.0'
104
+ version: 3.5.0
77
105
  type: :runtime
78
106
  prerelease: false
79
107
  version_requirements: !ruby/object:Gem::Requirement
80
108
  requirements:
81
- - - "~>"
109
+ - - '='
82
110
  - !ruby/object:Gem::Version
83
- version: '3.0'
111
+ version: 3.5.0
84
112
  - !ruby/object:Gem::Dependency
85
113
  name: capybara
86
114
  requirement: !ruby/object:Gem::Requirement
@@ -138,19 +166,33 @@ dependencies:
138
166
  - !ruby/object:Gem::Version
139
167
  version: '3.0'
140
168
  - !ruby/object:Gem::Dependency
141
- name: testingbot
169
+ name: bundler
170
+ requirement: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - "~>"
173
+ - !ruby/object:Gem::Version
174
+ version: '1.16'
175
+ type: :runtime
176
+ prerelease: false
177
+ version_requirements: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - "~>"
180
+ - !ruby/object:Gem::Version
181
+ version: '1.16'
182
+ - !ruby/object:Gem::Dependency
183
+ name: rake
142
184
  requirement: !ruby/object:Gem::Requirement
143
185
  requirements:
144
186
  - - "~>"
145
187
  - !ruby/object:Gem::Version
146
- version: 0.1.7
188
+ version: '12.3'
147
189
  type: :runtime
148
190
  prerelease: false
149
191
  version_requirements: !ruby/object:Gem::Requirement
150
192
  requirements:
151
193
  - - "~>"
152
194
  - !ruby/object:Gem::Version
153
- version: 0.1.7
195
+ version: '12.3'
154
196
  description: Rainforest Ruby Runtime
155
197
  email:
156
198
  - simon@rainforestqa.com
@@ -160,27 +202,26 @@ executables:
160
202
  extensions: []
161
203
  extra_rdoc_files: []
162
204
  files:
205
+ - ".circleci/config.yml"
163
206
  - ".gitignore"
164
207
  - ".ruby-gemset"
165
208
  - ".ruby-version"
166
- - ".travis.yml"
209
+ - CHANGELOG.md
167
210
  - Gemfile
168
211
  - LICENSE.txt
169
212
  - README.md
170
213
  - Rakefile
171
214
  - bin/rainforest_test
172
215
  - lib/rainforest_ruby_runtime.rb
173
- - lib/rainforest_ruby_runtime/drivers/browser_stack.rb
174
216
  - lib/rainforest_ruby_runtime/drivers/sauce.rb
175
217
  - lib/rainforest_ruby_runtime/drivers/selenium.rb
176
- - lib/rainforest_ruby_runtime/drivers/testing_bot.rb
177
218
  - lib/rainforest_ruby_runtime/dsl.rb
178
219
  - lib/rainforest_ruby_runtime/empty.rb
179
220
  - lib/rainforest_ruby_runtime/exceptions.rb
180
221
  - lib/rainforest_ruby_runtime/nil_delegator.rb
181
222
  - lib/rainforest_ruby_runtime/runner.rb
182
223
  - lib/rainforest_ruby_runtime/test.rb
183
- - lib/rainforest_ruby_runtime/variables/registery.rb
224
+ - lib/rainforest_ruby_runtime/variables/registry.rb
184
225
  - lib/rainforest_ruby_runtime/variables/scope.rb
185
226
  - lib/rainforest_ruby_runtime/variables/value.rb
186
227
  - lib/rainforest_ruby_runtime/version.rb
@@ -194,13 +235,19 @@ files:
194
235
  - sample_tests/simple.rb
195
236
  - sample_tests/step_variables.rb
196
237
  - sample_tests/two_steps.rb
197
- - test/runner_test.rb
198
- - test/test_helper.rb
238
+ - spec/rainforest_test_spec.rb
239
+ - spec/runner_spec.rb
240
+ - spec/spec_helper.rb
199
241
  homepage: https://www.rainforestqa.com/
200
242
  licenses:
201
243
  - MIT
202
244
  metadata: {}
203
- post_install_message:
245
+ post_install_message: |2
246
+ Thanks for installing!
247
+ If you plan to run scripts against Sauce Labs, please run
248
+ `rainforest_test --prepare-sauce`
249
+ and set the SAUCE_USERNAME, SAUCE_ACCESS_KEY, and CAPYBARA_DRIVER
250
+ environment variables.
204
251
  rdoc_options: []
205
252
  require_paths:
206
253
  - lib
@@ -216,10 +263,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
263
  version: '0'
217
264
  requirements: []
218
265
  rubyforge_project:
219
- rubygems_version: 2.5.2
266
+ rubygems_version: 2.6.14.1
220
267
  signing_key:
221
268
  specification_version: 4
222
269
  summary: Rainforest Ruby Runtime
223
270
  test_files:
224
- - test/runner_test.rb
225
- - test/test_helper.rb
271
+ - spec/rainforest_test_spec.rb
272
+ - spec/runner_spec.rb
273
+ - spec/spec_helper.rb
data/.travis.yml DELETED
@@ -1,12 +0,0 @@
1
- language: ruby
2
-
3
- notifications:
4
- email: false
5
- webhooks:
6
- on_success: always
7
- on_failure: always
8
-
9
- rvm:
10
- - 2.3.3
11
-
12
- script: bundle exec rake test
@@ -1,42 +0,0 @@
1
- require 'selenium/webdriver'
2
-
3
- module RainforestRubyRuntime
4
- module Drivers
5
- class BrowserStack
6
- attr_reader :options
7
-
8
- def initialize(options)
9
- @options = options
10
- end
11
-
12
- def call
13
- url = "https://#{ENV['BROWSER_STACK_USERNAME']}:#{ENV['BROWSER_STACK_PASSWORD']}@hub.browserstack.com/wd/hub"
14
- capabilities = ::Selenium::WebDriver::Remote::Capabilities.new browsers.first
15
- capabilities['browserstack.debug'] = 'true'
16
-
17
- ::Capybara.register_driver :browser_stack do |app|
18
- ::Capybara::Selenium::Driver.new(app, browser: :remote, url: url, desired_capabilities: capabilities)
19
- end
20
- end
21
-
22
- private
23
-
24
- def browsers
25
- Array(options[:browsers]).map do |browser|
26
- {
27
- "ie8" => {platform: "WINDOWS", browser: "internet explorer", browser_version: 8},
28
- "ie9" => {platform: "WINDOWS", browser: "internet explorer", browser_version: 9},
29
- "ie10" => {platform: "WINDOWS", browser: "internet explorer", browser_version: 10},
30
- "ie11" => {platform: "WINDOWS", browser: "internet explorer", browser_version: 11},
31
- "chrome" => {platform: "WINDOWS", browser: "chrome"},
32
- "firefox" => {platform: "WINDOWS", browser: "firefox", browser_version: 30.0},
33
- "safari" => {platform: "MAC", browser: "safari", browser_version: 7},
34
- }.fetch(browser)
35
- end
36
- end
37
- end
38
- end
39
- end
40
-
41
- Capybara.register_driver :browser_stack do |app|
42
- end
@@ -1,34 +0,0 @@
1
- module RainforestRubyRuntime
2
- module Drivers
3
- class TestingBot
4
- attr_reader :options
5
-
6
- def initialize(options)
7
- @options = options
8
- end
9
-
10
- def call
11
- ::TestingBot.config do |c|
12
- c[:desired_capabilities] = browsers
13
- end
14
- end
15
-
16
- private
17
-
18
- def browsers
19
- Array(options[:browsers]).map do |browser|
20
- {
21
- "ie8" => {platform: "WINDOWS", browserName: "internet explorer", version: 8, idletimeout: 90},
22
- "ie9" => {platform: "WINDOWS", browserName: "internet explorer", version: 9, idletimeout: 90},
23
- "ie10" => {platform: "WINDOWS", browserName: "internet explorer", version: 10, idletimeout: 90},
24
- "ie11" => {platform: "WINDOWS", browserName: "internet explorer", version: 11, idletimeout: 90},
25
- "chrome" => {platform: "XP", browserName: "googlechrome", idletimeout: 90},
26
- "firefox" => {platform: "XP", browserName: "firefox", version: 30.0, idletimeout: 90},
27
- "safari" => {platform: "MAC", browserName: "safari", version: 7, idletimeout: 90},
28
- }.fetch(browser)
29
- end
30
- end
31
- end
32
- end
33
- end
34
-
data/test/runner_test.rb DELETED
@@ -1,212 +0,0 @@
1
- require_relative './test_helper'
2
-
3
- module RainforestRubyRuntime
4
- describe Runner do
5
- subject { Runner.new }
6
- let(:code) { read_sample "empty" }
7
-
8
- describe "#session_id" do
9
- it "returns a session id" do
10
- subject.stub(:current_driver, OpenStruct.new(browser: OpenStruct.new(session_id: 'session'))) do
11
- subject.session_id.must_equal 'session'
12
- end
13
- end
14
- end
15
-
16
- describe "#run" do
17
- describe "with a limited browser set" do
18
- subject { Runner.new browsers: %w(chrome) }
19
-
20
- it "applies the correct configuration" do
21
- subject.stub(:driver, 'sauce') do
22
- subject.run(code)
23
- Sauce.get_config.browsers.must_equal [["Windows 7", "Chrome", "35"]]
24
- end
25
- end
26
- end
27
-
28
- describe "for a rainforest test" do
29
- let(:code) { read_sample "simple" }
30
-
31
- it "runs the content of the step" do
32
- test = subject.run(code)
33
- test.must_be_instance_of(Test)
34
- $simple_test_was.must_equal :run
35
- end
36
- end
37
-
38
- describe "for another type of test" do
39
- it "raises an exception" do
40
- -> do
41
- subject.run("")
42
- end.must_raise(WrongReturnValueError)
43
- end
44
- end
45
-
46
- describe "with custom step variables" do
47
- let(:code) { read_sample "step_variables" }
48
-
49
- it "makes the variable accessible in the test" do
50
- subject.run(code)
51
- $step_variable_1_was.wont_be_nil
52
- $step_variable_2_was.must_match(/time is: .*/)
53
- $step_variable_3_was.must_equal("1")
54
- end
55
- end
56
- end
57
-
58
- describe "#extract_results" do
59
- subject { Runner.new.extract_results(code, fake_session_id: :test) }
60
-
61
- describe "a failing spec" do
62
- let(:code) { format_step "expect(1).to eq(2)" }
63
- it "catches failled rspec assertions" do
64
- subject[:message].must_include "expected: 2"
65
- subject[:status].must_equal "failed"
66
- end
67
- end
68
-
69
- describe "select capybara error" do
70
- let(:code) { format_step "raise Capybara::ElementNotFound" }
71
- it "catches failled rspec assertions" do
72
- subject[:status].must_equal "failed"
73
- end
74
- end
75
-
76
- describe "a passing spec" do
77
- let(:code) { format_step "expect(1).to eq(1)" }
78
- it "returns a 'passed'" do
79
- subject[:status].must_equal "passed"
80
- end
81
- end
82
-
83
- describe "a spec raising a runtime error" do
84
- let(:code) { format_step "raise 'foo'" }
85
- it "returns an 'error'" do
86
- subject[:status].must_equal "error"
87
- end
88
- end
89
-
90
- describe "a spec raising a selenium error" do
91
- let(:code) { format_step "raise Selenium::WebDriver::Error::WebDriverError" }
92
- it "returns an 'error'" do
93
- subject[:status].must_equal "error"
94
- end
95
- end
96
-
97
- describe "a spec with syntax error" do
98
- let(:code) { format_step "if if true; puts true; end;" }
99
- it "returns an 'fatal_error'" do
100
- subject[:status].must_equal "fatal_error"
101
- end
102
- end
103
-
104
- describe "a tests that outputs to stdout" do
105
- let(:code) { format_step "print 'hello'" }
106
- it "captures it and adds it to the payload" do
107
- subject[:stdout].must_equal "hello"
108
- end
109
- end
110
-
111
- describe "a tests that errputs to stderr" do
112
- let(:code) { format_step "$stderr.print 'hello'" }
113
- it "captures it and adds it to the payload" do
114
- subject[:stderr].must_equal "hello"
115
- end
116
- end
117
-
118
- describe "a test with predefined values for custom variables" do
119
- let(:code) { read_sample "step_variables" }
120
- let(:step_variables) do
121
- {
122
- "my_custom_scope" => {
123
- "uuid" => "some_uuid",
124
- "time" => "some_time",
125
- },
126
- "my_other_scope" => {
127
- "constant" => "some_constant",
128
- }
129
- }
130
- end
131
- let(:runner) { Runner.new(step_variables: step_variables) }
132
-
133
- subject do
134
- runner.extract_results(code, fake_session_id: :test)
135
- end
136
-
137
- it "uses the passed in variables" do
138
- subject[:status].must_equal "passed"
139
- $step_variable_1_was.must_equal "some_uuid"
140
- $step_variable_2_was.must_equal "some_time"
141
- $step_variable_3_was.must_equal "some_constant"
142
- end
143
- end
144
- end
145
-
146
- describe "callbacks" do
147
- let(:callback) do
148
- Class.new do
149
- attr_reader :before_steps, :before_tests, :after_steps, :after_tests
150
-
151
- def initialize
152
- @before_steps = []
153
- @after_steps = []
154
- @after_tests = []
155
- @before_tests = []
156
- end
157
-
158
- def before_step(step)
159
- @before_steps << step
160
- end
161
-
162
- def after_step(step)
163
- @after_steps << step
164
- end
165
-
166
- def after_test(test)
167
- @after_tests << test
168
- end
169
-
170
- def before_test(test)
171
- @before_tests << test
172
- end
173
- end.new
174
- end
175
-
176
- let(:code) { read_sample "two_steps" }
177
- subject { Runner.new callback: callback }
178
-
179
- it "calls the right method on the callback object" do
180
- subject.run(code)
181
- callback.before_tests.size.must_equal 1
182
- callback.after_tests.size.must_equal 1
183
- callback.before_steps.size.must_equal 2
184
- callback.after_steps.size.must_equal 2
185
-
186
- callback.before_steps.map(&:id).must_equal [1, 2]
187
- callback.after_steps.map(&:id).must_equal [1, 2]
188
-
189
- callback.before_steps.map(&:action).must_equal ["action 1", "action 2"]
190
- end
191
-
192
- describe "a partially define callback object" do
193
- let(:callback) do
194
- Class.new do
195
- end.new
196
- end
197
-
198
- it "should not rise a method missing exception" do
199
- subject.run(code)
200
- end
201
- end
202
- end
203
-
204
- def read_sample(name)
205
- File.read(File.expand_path("../sample_tests/#{name}.rb", __dir__))
206
- end
207
-
208
- def format_step(code)
209
- read_sample("one_step").gsub("#REPLACE", code)
210
- end
211
- end
212
- end