rainforest_ruby_runtime 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4340afeebc12c607980d704c88783c3b2276b404
4
+ data.tar.gz: bbb7b788017d82bee9487fa1ad51cb0fd8e3f52d
5
+ SHA512:
6
+ metadata.gz: 5a4a3eb68e24e6fe9a6e24a27c0120de0479851bc60f3caea7283ac4c27a65950dd83759f34d932fe65fb52e0f39701a03be860864bd2971a3d6df7f73d34ccf
7
+ data.tar.gz: f9d60bcef218c27099050803cad4b161eb30b9655b09b4db8abda6a6e6d1216439f15931a1df1918c0906945eba3c943787b05d8f418811ae57564200dfbfecb
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ tags
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 2.1.2@rainforest_ruby_runtime --create
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+
3
+ notifications:
4
+ email: false
5
+ webhooks:
6
+ on_success: always
7
+ on_failure: always
8
+
9
+ rvm:
10
+ - 2.1.1
11
+
12
+ script: bundle exec rake test
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rainforest_ruby_runtime.gemspec
4
+ gemspec
5
+
6
+ gem 'pry'
7
+ gem 'awesome_print'
8
+ gem 'm'
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Simon Mathieu
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ # Rainforest Ruby Runtime
2
+
3
+ [![Build Status](https://travis-ci.org/rainforestapp/rainforest_ruby_runtime.svg)](https://travis-ci.org/rainforestapp/rainforest_ruby_runtime)
4
+
5
+ TODO: Write a gem description
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'rainforest_ruby_runtime'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install rainforest_ruby_runtime
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/rainforestapp/rainforest_ruby_runtime/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.pattern = "test/**/*_test.rb"
7
+ end
8
+
9
+ task :default => [:test]
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), "../lib")
4
+ require 'rainforest_ruby_runtime'
5
+
6
+ RainforestRubyRuntime::Runner.new(browsers: %w(firefox)).run ARGF.read
7
+
8
+ puts "Your test completed successfuly!"
@@ -0,0 +1,17 @@
1
+ require "sauce"
2
+ require "sauce/capybara"
3
+ require 'rspec/expectations'
4
+
5
+ require "rainforest_ruby_runtime/version"
6
+ require "rainforest_ruby_runtime/exceptions"
7
+ require "rainforest_ruby_runtime/test"
8
+ require "rainforest_ruby_runtime/dsl"
9
+ require "rainforest_ruby_runtime/runner"
10
+ require "rainforest_ruby_runtime/drivers/sauce"
11
+ require "rainforest_ruby_runtime/drivers/selenium"
12
+ require "rainforest_ruby_runtime/variables/value"
13
+ require "rainforest_ruby_runtime/variables/registery"
14
+ require "rainforest_ruby_runtime/variables/scope"
15
+
16
+ module RainforestRubyRuntime
17
+ end
@@ -0,0 +1,34 @@
1
+ module RainforestRubyRuntime
2
+ module Drivers
3
+ class Sauce
4
+ attr_reader :options
5
+
6
+ def initialize(options)
7
+ @options = options
8
+ end
9
+
10
+ def call
11
+ ::Sauce.config do |c|
12
+ c[:browsers] = browsers
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ def browsers
19
+ Array(options[:browsers]).map do |browser|
20
+ {
21
+ 'ie8' => ["Windows 7", "Internet Explorer", "8"],
22
+ 'ie9' => ["Windows 7", "Internet Explorer", "9"],
23
+ 'ie10' => ["Windows 7", "Internet Explorer", "10"],
24
+ 'ie11' => ["Windows 7", "Internet Explorer", "11"],
25
+ 'chrome' => ["Windows 7", "Chrome", "35"],
26
+ 'firefox' => ["Windows 7", "Firefox", "30"],
27
+ 'safari' => ["Mavericks", "Safari", "7"],
28
+ }.fetch(browser)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+
@@ -0,0 +1,14 @@
1
+ module RainforestRubyRuntime
2
+ module Drivers
3
+ class Selenium
4
+ def initialize(options)
5
+ @options = options
6
+ end
7
+
8
+ def call
9
+ # No configuration
10
+ end
11
+ end
12
+ end
13
+ end
14
+
@@ -0,0 +1,13 @@
1
+ module RainforestRubyRuntime
2
+ module DSL
3
+ def test(id: , title: , &block)
4
+ RainforestRubyRuntime::Test.new(id: id, title: title, &block)
5
+ end
6
+
7
+ def define_variable_scope(name, &block)
8
+ scope = Variables::Scope.new(name, &block)
9
+ Variables.scope_registery.register(scope)
10
+ end
11
+ end
12
+ end
13
+
@@ -0,0 +1,12 @@
1
+ module RainforestRubyRuntime
2
+ class Exception < RuntimeError
3
+ end
4
+
5
+ class WrongReturnValueError < Exception
6
+ attr_reader :returned_value
7
+ def initialize(returned_value)
8
+ @returned_value = returned_value
9
+ super "The script must return a Test object"
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,111 @@
1
+ module RainforestRubyRuntime
2
+ class Runner
3
+ attr_reader :config_options
4
+
5
+ def initialize(options = {})
6
+ @config_options = options.dup.freeze
7
+ @step_variables = options[:step_variables]
8
+ end
9
+
10
+ def run(code)
11
+ extend RainforestRubyRuntime::DSL
12
+ Capybara.default_driver = :"#{driver}"
13
+ Capybara.default_wait_time = wait_time
14
+
15
+ apply_config!
16
+ setup_scope_registery!
17
+
18
+ test = eval(code)
19
+ if Test === test
20
+ test.run
21
+ else
22
+ raise WrongReturnValueError, test
23
+ end
24
+ test
25
+ ensure
26
+ terminate_session!
27
+ end
28
+
29
+ def extract_results(code, fake_session_id: nil)
30
+ stdout = stderr = nil
31
+ payload = nil
32
+ begin
33
+ stdout, stderr = capture_output2 do
34
+ run(code)
35
+ end
36
+ rescue RSpec::Expectations::ExpectationNotMetError => e
37
+ payload = exception_to_payload e, status: 'failed'
38
+ rescue StandardError => e
39
+ payload = exception_to_payload e, status: 'error'
40
+ rescue SyntaxError, Exception => e
41
+ payload = exception_to_payload e, status: 'fatal_error'
42
+ end
43
+
44
+ payload ||= { status: 'passed' }
45
+
46
+ payload.merge({
47
+ stdout: stdout,
48
+ stderr: stderr,
49
+ session_id: fake_session_id || session_id
50
+ })
51
+ end
52
+
53
+ def driver
54
+ ENV.fetch("CAPYBARA_DRIVER") { "selenium" }
55
+ end
56
+
57
+ private
58
+ def exception_to_payload(e, payload = {})
59
+ payload.merge({
60
+ exception: e.class.to_s,
61
+ message: e.message,
62
+ backtrace: e.backtrace,
63
+ })
64
+ end
65
+
66
+ def apply_config!
67
+ config = {
68
+ "selenium" => Drivers::Selenium,
69
+ "sauce" => Drivers::Sauce,
70
+ }.fetch(driver)
71
+
72
+ config.new(config_options).call
73
+ end
74
+
75
+ def current_driver
76
+ Capybara.current_session.driver
77
+ end
78
+
79
+ def terminate_session!
80
+ # Terminate the Sauce session if needed
81
+ current_driver.finish! if current_driver.respond_to?(:finish!)
82
+ end
83
+
84
+ def wait_time
85
+ ENV.fetch("CAPYBARA_WAIT_TIME", 20).to_i
86
+ end
87
+
88
+ def session_id
89
+ current_driver.browser.session_id if current_driver.browser.respond_to?(:session_id)
90
+ end
91
+
92
+ def capture_output2
93
+ previous_stdout, $stdout = $stdout, StringIO.new
94
+ previous_stderr, $stderr = $stderr, StringIO.new
95
+ yield
96
+ [$stdout.string, $stderr.string]
97
+ ensure
98
+ # Restore the previous value of stdout (typically equal to STDERR).
99
+ $stdout = previous_stdout
100
+ $stderr = previous_stderr
101
+ end
102
+
103
+ def setup_scope_registery!
104
+ if @step_variables.nil?
105
+ Variables.scope_registery = Variables::Registery.new
106
+ else
107
+ Variables.scope_registery = Variables::StaticVariableRegistery.new(@step_variables)
108
+ end
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,49 @@
1
+ module RainforestRubyRuntime
2
+ class Test
3
+ attr_reader :id, :title, :steps
4
+
5
+ def initialize(id: , title: , &block)
6
+ @id = id
7
+ @title = title
8
+ @steps = []
9
+ @block = block
10
+ end
11
+
12
+ def step(**args, &block)
13
+ step = Step.new(**args, &block)
14
+ @steps << step
15
+ step.run
16
+ step
17
+ end
18
+
19
+ def run
20
+ extend RSpec::Matchers
21
+ extend Capybara::DSL
22
+ instance_eval &@block
23
+ end
24
+
25
+ def method_missing(name, *args, &block)
26
+ if Variables.scope_registery.has_variable?(name)
27
+ Variables.scope_registery[name]
28
+ else
29
+ super
30
+ end
31
+ end
32
+ end
33
+
34
+ class Step
35
+ attr_reader :id, :action, :response
36
+
37
+ def initialize(id: , action: , response: , &block)
38
+ @id = id
39
+ @action = action
40
+ @response = response
41
+ @block = block
42
+ end
43
+
44
+ def run
45
+ @block.call
46
+ end
47
+ end
48
+ end
49
+
@@ -0,0 +1,59 @@
1
+ module RainforestRubyRuntime
2
+ module Variables
3
+ class Registery
4
+ def initialize(variables = {})
5
+ @variables = {}
6
+ end
7
+
8
+ def register(variable)
9
+ variables[variable.name] = variable
10
+ end
11
+
12
+ def has_variable?(name)
13
+ variables.has_key?(name)
14
+ end
15
+
16
+ def [](name)
17
+ variables[name]
18
+ end
19
+
20
+ private
21
+
22
+ attr_reader :variables
23
+ end
24
+
25
+ class StaticVariableRegistery
26
+ def initialize(variables)
27
+ @variables = variables.inject({}) do |variables, (name, var_and_values)|
28
+ scope = Scope.new(name)
29
+ var_and_values.each do |name, value|
30
+ scope.define_variable(name.to_sym) { value }
31
+ end
32
+ variables[name] = scope
33
+ variables
34
+ end
35
+ end
36
+
37
+ def has_variable?(name)
38
+ @variables.has_key?(name.to_s)
39
+ end
40
+
41
+ def [](name)
42
+ @variables[name.to_s]
43
+ end
44
+
45
+ def register(*)
46
+ # noop
47
+ end
48
+ end
49
+
50
+ def self.scope_registery
51
+ @scope_registery ||= Registery.new
52
+ end
53
+
54
+ def self.scope_registery=(registery)
55
+ @scope_registery = registery
56
+ end
57
+ end
58
+ end
59
+
@@ -0,0 +1,25 @@
1
+ module RainforestRubyRuntime
2
+ module Variables
3
+ class Scope < Value
4
+ attr_reader :name, :block
5
+
6
+ def initialize(*, &block)
7
+ super
8
+ @registry = Registery.new
9
+ instance_eval &block if block_given?
10
+ end
11
+
12
+ def define_variable(name, &block)
13
+ @registry.register Value.new(name, &block)
14
+ end
15
+
16
+ def method_missing(name, *args, &block)
17
+ if @registry.has_variable?(name)
18
+ @registry[name].call *args, &block
19
+ else
20
+ super
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,17 @@
1
+ module RainforestRubyRuntime
2
+ module Variables
3
+ class Value
4
+ attr_reader :name, :block
5
+
6
+ def initialize(name, &block)
7
+ @name = name
8
+ @block = block
9
+ end
10
+
11
+ def call(*args, &block)
12
+ @block.call *args, &block
13
+ end
14
+ end
15
+ end
16
+ end
17
+
@@ -0,0 +1,3 @@
1
+ module RainforestRubyRuntime
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rainforest_ruby_runtime/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rainforest_ruby_runtime"
8
+ spec.version = RainforestRubyRuntime::VERSION
9
+ spec.authors = ["Simon Mathieu"]
10
+ spec.email = ["simon@rainforestqa.com"]
11
+ spec.summary = %q{}
12
+ spec.description = %q{}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_dependency "sauce", "~> 3.4"
24
+ spec.add_dependency "sauce-connect", "~> 3.4"
25
+ spec.add_dependency "rspec-expectations", "~> 3.0"
26
+ spec.add_dependency 'capybara', "~> 2.4"
27
+ end
@@ -0,0 +1,2 @@
1
+ test(id: 1, title: "") do
2
+ end
@@ -0,0 +1,6 @@
1
+ test(id: 1, title: 'One step') do
2
+ step id: 1, action: "", response: "" do
3
+ expect(1).to eq(2)
4
+ end
5
+ end
6
+
@@ -0,0 +1,37 @@
1
+ # To execute this code, you require the rainforest_ruby_runtime. https://github.com/rainforestapp/rainforest_ruby_runtime
2
+ #
3
+ # The best way to get started is to have a look at our sample tests here:
4
+ # https://github.com/rainforestapp/sample-capybara-test
5
+ #
6
+ # Please only edit code within the `step` blocks.
7
+ #
8
+ # You can use any RSpec 3 assection and Capybare method
9
+ #
10
+ test(id: 3742, title: "Vagrant-KVM") do
11
+ visit "https://github.com/adrahon/vagrant-kvm"
12
+ step id: :ignored,
13
+ action: "Locate the README section. ",
14
+ response: "Does the section contains the words \"Vagrant KVM\"?" do
15
+ # Replace this comment with the code for this action an response here.
16
+ end
17
+ step id: :ignored,
18
+ action: "Click on the \"lib\" directory.",
19
+ response: "Are you shown a file name \"vagrant-kvm.rb\"?" do
20
+ # Replace this comment with the code for this action an response here.
21
+ end
22
+ step id: :ignored,
23
+ action: "Click on the \"vagrant-kvm\" directory?",
24
+ response: "Do you see a file named \"version.rb\"?" do
25
+ # Replace this comment with the code for this action an response here.
26
+ end
27
+ step id: :ignored,
28
+ action: "Click on the \"version.rb\" file?",
29
+ response: "Does the file open where the file browser use to be?" do
30
+ # Replace this comment with the code for this action an response here.
31
+ end
32
+ step id: :ignored,
33
+ action: "Locate the version number.",
34
+ response: "Is the version specified 9000?" do
35
+ # Replace this comment with the code for this action an response here.
36
+ end
37
+ end
@@ -0,0 +1,5 @@
1
+ test(id: 1, title: 'One step') do
2
+ step id: 1, action: "", response: "" do
3
+ #REPLACE
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ test(id: 1, title: 'One step') do
2
+ step id: 1, action: "", response: "" do
3
+ end
4
+ end
@@ -0,0 +1,8 @@
1
+ test(id: 1, title: 'My Sample Test') do
2
+ visit "http://simonmathieu.com"
3
+ step id: 1,
4
+ action: "Fill up the login form and click submit",
5
+ response: "Were you logged in?" do
6
+ end
7
+ end
8
+
@@ -0,0 +1,9 @@
1
+ test(id: 1, title: 'My Sample Test') do
2
+ step id: 1,
3
+ action: "Fill up the login form and click submit",
4
+ response: "Were you logged in?" do
5
+
6
+ # Content of test
7
+ $simple_test_was = :run
8
+ end
9
+ end
@@ -0,0 +1,25 @@
1
+ define_variable_scope :my_custom_scope do
2
+ define_variable :uuid do
3
+ SecureRandom.uuid
4
+ end
5
+
6
+ define_variable :time do
7
+ "time is: #{Time.now}"
8
+ end
9
+ end
10
+
11
+ define_variable_scope :my_other_scope do
12
+ define_variable :constant do
13
+ "1"
14
+ end
15
+ end
16
+
17
+
18
+ test(id: 1, title: 'My Sample Test') do
19
+ step id: 1, action: "", response: "" do
20
+ $step_variable_1_was = my_custom_scope.uuid
21
+ $step_variable_2_was = my_custom_scope.time
22
+ end
23
+ $step_variable_3_was = my_other_scope.constant
24
+ end
25
+
@@ -0,0 +1,139 @@
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 "#run" do
9
+ describe "with a limited browser set" do
10
+ subject { Runner.new browsers: %w(chrome) }
11
+
12
+ it "applies the correct configuration" do
13
+ subject.stub(:driver, 'sauce') do
14
+ subject.run(code)
15
+ Sauce.get_config.browsers.must_equal [["Windows 7", "Chrome", "35"]]
16
+ end
17
+ end
18
+ end
19
+
20
+ describe "for a rainforest test" do
21
+ let(:code) { read_sample "simple" }
22
+
23
+ it "runs the content of the step" do
24
+ test = subject.run(code)
25
+ test.must_be_instance_of(Test)
26
+ $simple_test_was.must_equal :run
27
+ end
28
+ end
29
+
30
+ describe "for another type of test" do
31
+ it "raises an exception" do
32
+ -> do
33
+ subject.run("")
34
+ end.must_raise(WrongReturnValueError)
35
+ end
36
+ end
37
+
38
+ describe "with custom step variables" do
39
+ let(:code) { read_sample "step_variables" }
40
+
41
+ it "makes the variable accessible in the test" do
42
+ subject.run(code)
43
+ $step_variable_1_was.wont_be_nil
44
+ $step_variable_2_was.must_match /time is: .*/
45
+ $step_variable_3_was.must_equal "1"
46
+ end
47
+ end
48
+ end
49
+
50
+ describe "#extract_results" do
51
+ subject { Runner.new.extract_results(code, fake_session_id: :test) }
52
+
53
+ describe "a failing spec" do
54
+ let(:code) { format_step "expect(1).to eq(2)" }
55
+ it "catches failled rspec assertions" do
56
+ subject[:message].must_include "expected: 2"
57
+ subject[:status].must_equal "failed"
58
+ end
59
+ end
60
+
61
+ describe "a passing spec" do
62
+ let(:code) { format_step "expect(1).to eq(1)" }
63
+ it "returns a 'passed'" do
64
+ subject[:status].must_equal "passed"
65
+ end
66
+ end
67
+
68
+ describe "a spec raising a runtime error" do
69
+ let(:code) { format_step "raise 'foo'" }
70
+ it "returns an 'error'" do
71
+ subject[:status].must_equal "error"
72
+ end
73
+ end
74
+
75
+ describe "a spec raising a selenium error" do
76
+ let(:code) { format_step "raise Selenium::WebDriver::Error::WebDriverError" }
77
+ it "returns an 'error'" do
78
+ subject[:status].must_equal "error"
79
+ end
80
+ end
81
+
82
+ describe "a spec with syntax error" do
83
+ let(:code) { format_step "if if true; puts true; end;" }
84
+ it "returns an 'fatal_error'" do
85
+ subject[:status].must_equal "fatal_error"
86
+ end
87
+ end
88
+
89
+ describe "a tests that outputs to stdout" do
90
+ let(:code) { format_step "print 'hello'" }
91
+ it "captures it and adds it to the payload" do
92
+ subject[:stdout].must_equal "hello"
93
+ end
94
+ end
95
+
96
+ describe "a tests that errputs to stderr" do
97
+ let(:code) { format_step "$stderr.print 'hello'" }
98
+ it "captures it and adds it to the payload" do
99
+ subject[:stderr].must_equal "hello"
100
+ end
101
+ end
102
+
103
+ describe "a test with predefined values for custom variables" do
104
+ let(:code) { read_sample "step_variables" }
105
+ let(:step_variables) do
106
+ {
107
+ "my_custom_scope" => {
108
+ "uuid" => "some_uuid",
109
+ "time" => "some_time",
110
+ },
111
+ "my_other_scope" => {
112
+ "constant" => "some_constant",
113
+ }
114
+ }
115
+ end
116
+ let(:runner) { Runner.new(step_variables: step_variables) }
117
+
118
+ subject do
119
+ runner.extract_results(code, fake_session_id: :test)
120
+ end
121
+
122
+ it "uses the passed in variables" do
123
+ subject[:status].must_equal "passed"
124
+ $step_variable_1_was.must_equal "some_uuid"
125
+ $step_variable_2_was.must_equal "some_time"
126
+ $step_variable_3_was.must_equal "some_constant"
127
+ end
128
+ end
129
+ end
130
+
131
+ def read_sample(name)
132
+ File.read(File.expand_path("../sample_tests/#{name}.rb", __dir__))
133
+ end
134
+
135
+ def format_step(code)
136
+ read_sample("one_step").gsub("#REPLACE", code)
137
+ end
138
+ end
139
+ end
@@ -0,0 +1,8 @@
1
+ $LOAD_PATH.unshift File.join(__dir__, "../lib")
2
+
3
+ require 'pry'
4
+ require 'awesome_print'
5
+ require 'rainforest_ruby_runtime'
6
+ require 'minitest/spec'
7
+ require 'minitest/autorun'
8
+ require 'minitest/pride'
metadata ADDED
@@ -0,0 +1,161 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rainforest_ruby_runtime
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Simon Mathieu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sauce
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.4'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sauce-connect
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.4'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-expectations
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: capybara
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.4'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.4'
97
+ description: ''
98
+ email:
99
+ - simon@rainforestqa.com
100
+ executables:
101
+ - rainforest_test
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".rvmrc"
107
+ - ".travis.yml"
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - bin/rainforest_test
113
+ - lib/rainforest_ruby_runtime.rb
114
+ - lib/rainforest_ruby_runtime/drivers/sauce.rb
115
+ - lib/rainforest_ruby_runtime/drivers/selenium.rb
116
+ - lib/rainforest_ruby_runtime/dsl.rb
117
+ - lib/rainforest_ruby_runtime/exceptions.rb
118
+ - lib/rainforest_ruby_runtime/runner.rb
119
+ - lib/rainforest_ruby_runtime/test.rb
120
+ - lib/rainforest_ruby_runtime/variables/registery.rb
121
+ - lib/rainforest_ruby_runtime/variables/scope.rb
122
+ - lib/rainforest_ruby_runtime/variables/value.rb
123
+ - lib/rainforest_ruby_runtime/version.rb
124
+ - rainforest_ruby_runtime.gemspec
125
+ - sample_tests/empty.rb
126
+ - sample_tests/fail.rb
127
+ - sample_tests/from_template.rb
128
+ - sample_tests/one_step.rb
129
+ - sample_tests/pass.rb
130
+ - sample_tests/real.rb
131
+ - sample_tests/simple.rb
132
+ - sample_tests/step_variables.rb
133
+ - test/runner_test.rb
134
+ - test/test_helper.rb
135
+ homepage: ''
136
+ licenses:
137
+ - MIT
138
+ metadata: {}
139
+ post_install_message:
140
+ rdoc_options: []
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ requirements: []
154
+ rubyforge_project:
155
+ rubygems_version: 2.2.2
156
+ signing_key:
157
+ specification_version: 4
158
+ summary: ''
159
+ test_files:
160
+ - test/runner_test.rb
161
+ - test/test_helper.rb