rspec-ui 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 36979e24385e4b719e3aba13f5de8c2fa69d4645
4
+ data.tar.gz: 856dc3c8ab3e863a1927d62ff0b30fad000f10c8
5
+ SHA512:
6
+ metadata.gz: 75f36736d9924e418bb6898e6dbe42bbd39805bb107caf9ea3550fff0c1fc4b140b897175d10c0399d8e64fc8804aeea853bacba55bbc82ce8372928a8806a97
7
+ data.tar.gz: 41c27c530f9e001cb4f2aa773670c95c4794011831eb08dc5cda0a11e6dd4ccb48d9e829d8173b676b0536329b2081f49474a4db50d471127e573e0e5582cd57
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rspec-ui.gemspec
4
+ gemspec
5
+
6
+ gem 'capybara', '~> 2.2.0', :require => false
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Chris Teague
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.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Rspec::Ui
2
+
3
+ Gem that integrates with Rspec & UXSpec.com to help you build a suite of UI & UX
4
+ features to test across multiple devices.
5
+
6
+ Warning: very much ALPHA software, do not use yet!
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'rspec-ui'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install rspec-ui
23
+
24
+ ## Usage
25
+
26
+
27
+ In your spec helper file:
28
+
29
+ ```ruby
30
+ require "rspec/ui"
31
+
32
+ UxSpec.configure do |config|
33
+ config.token = 'your_token_here'
34
+ end
35
+ ```
36
+
37
+ ## Contributing
38
+
39
+ 1. Fork it ( https://github.com/[my-github-username]/rspec-ui/fork )
40
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
41
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
42
+ 4. Push to the branch (`git push origin my-new-feature`)
43
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,53 @@
1
+ module RSpec
2
+ module Ui
3
+ # Fake class to document RSpec Rails configuration options. In practice,
4
+ # these are dynamically added to the normal RSpec configuration object.
5
+ class Configuration
6
+ # @!method infer_spec_type_from_file_location!
7
+ # Automatically tag specs in conventional directories with matching `type`
8
+ # metadata so that they have relevant helpers available to them. See
9
+ # `RSpec::Rails::DIRECTORY_MAPPINGS` for details on which metadata is
10
+ # applied to each directory.
11
+
12
+ # @!method render_views=(val)
13
+ #
14
+ # When set to `true`, controller specs will render the relevant view as
15
+ # well. Defaults to `false`.
16
+
17
+ # @!method render_views(val)
18
+ # Enables view rendering for controllers specs.
19
+
20
+ # @!method render_views?
21
+ # Reader for currently value of `render_views` setting.
22
+ end
23
+
24
+ # Mappings used by `infer_spec_type_from_file_location!`.
25
+ #
26
+ # @api private
27
+ DIRECTORY_MAPPINGS = {
28
+ :ui => %w[spec ui]
29
+ }
30
+
31
+ # @private
32
+ def self.initialize_configuration(config)
33
+
34
+ config.add_setting :always_run_ui_tests, :default => false
35
+
36
+ # Borrowed from rspec-rails
37
+ config.instance_exec do
38
+ def infer_spec_type_from_file_location!
39
+ DIRECTORY_MAPPINGS.each do |type, dir_parts|
40
+ escaped_path = Regexp.compile(dir_parts.join('[\\\/]') + '[\\\/]')
41
+ define_derived_metadata(:file_path => escaped_path) do |metadata|
42
+ metadata[:type] ||= type
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ config.include RSpec::Ui::UiExampleGroup, :type => :ui
49
+ end
50
+
51
+ initialize_configuration RSpec.configuration
52
+ end
53
+ end
@@ -0,0 +1,11 @@
1
+ module RSpec
2
+ module Ui
3
+ module Context
4
+
5
+ def test_ui
6
+ #binding.pry
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ module RSpec
2
+ module Ui
3
+ module DSL
4
+ def test_ui
5
+ # binding.pry
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,42 @@
1
+ require 'httparty'
2
+ require 'locoyo'
3
+
4
+ module RSpec
5
+ module Ui
6
+
7
+ class NgrokHook
8
+
9
+ ConfigFile = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'config', 'ngrok-config-testing'))
10
+ @@current_port = nil
11
+
12
+ def self.update_port(port)
13
+ return if @@current_port == port
14
+ shutdown
15
+
16
+ tunnel = Locoyo::Tunnel.new(
17
+ port: port,
18
+ address: '127.0.0.1',
19
+ protocol: 'http'
20
+ )
21
+ tunnel.run
22
+
23
+ sleep(3)
24
+ subdomain = tunnel.get_subdomain
25
+ update_browser_army(subdomain)
26
+
27
+ puts "View on http://uxspec.com/#{UxSpec.configuration.token}"
28
+ @@current_port = port
29
+ end
30
+
31
+ def self.shutdown
32
+ # TODO
33
+ end
34
+
35
+ def self.update_browser_army(subdomain)
36
+ HTTParty.patch("https://#{UxSpec.configuration.uxspec_uri}/#{UxSpec.configuration.token}.json", body: { project: { ngrok_id: subdomain, ngrok_port: @@current_port }}).body
37
+ end
38
+
39
+ end
40
+
41
+ end
42
+ end
@@ -0,0 +1,75 @@
1
+ require "pry"
2
+
3
+ module RSpec
4
+ module Ui
5
+ # Container module for routing spec functionality.
6
+ module UiExampleGroup
7
+ extend ActiveSupport::Concern
8
+ # include RSpec::Rails::RailsExampleGroup
9
+
10
+ # Default host to be used in Rails route helpers if none is specified.
11
+ DEFAULT_HOST = "www.example.com"
12
+
13
+ included do
14
+ app = ::Rails.application
15
+ if app.respond_to?(:routes)
16
+ include app.routes.url_helpers if app.routes.respond_to?(:url_helpers)
17
+ include app.routes.mounted_helpers if app.routes.respond_to?(:mounted_helpers)
18
+
19
+ if respond_to?(:default_url_options)
20
+ default_url_options[:host] ||= ::RSpec::Ui::UiExampleGroup::DEFAULT_HOST
21
+ end
22
+ end
23
+ end
24
+
25
+ # Shim to check for presence of Capybara. Will delegate if present, raise
26
+ # if not. We assume here that in most cases `visit` will be the first
27
+ # Capybara method called in a spec.
28
+ def visit(*)
29
+ if defined?(super)
30
+ super
31
+ else
32
+ raise "Capybara not loaded, please add it to your Gemfile:\n\ngem \"capybara\""
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+
40
+ unless RSpec.respond_to?(:ui)
41
+ opts = {
42
+ :ui_feature => true,
43
+ :type => :ui,
44
+ :skip => <<-EOT.squish
45
+ Feature specs require the Capybara (http://github.com/jnicklas/capybara)
46
+ gem, version 2.2.0 or later. We recommend version 2.4.0 or later to avoid
47
+ some deprecation warnings and have support for
48
+ `config.expose_dsl_globally = false`.
49
+ EOT
50
+ }
51
+
52
+ # Capybara's monkey patching causes us to have to jump through some hoops
53
+ top_level = self
54
+ main_feature = nil
55
+ if defined?(Capybara) && ::Capybara::VERSION.to_f < 2.4
56
+ # Capybara 2.2 and 2.3 do not use `alias_example_xyz`
57
+ opts[:skip] = <<-EOT.squish
58
+ Capybara < 2.4.0 does not support RSpec's namespace or
59
+ `config.expose_dsl_globally = false`. Upgrade to Capybara >= 2.4.0.
60
+ EOT
61
+ main_feature = top_level.method(:ui) if top_level.respond_to?(:ui)
62
+ end
63
+
64
+ RSpec.configure do |c|
65
+ main_feature = nil unless c.expose_dsl_globally?
66
+ c.alias_example_group_to :ui, opts
67
+ c.alias_example_to :scenario
68
+ c.alias_example_to :xscenario
69
+ end
70
+
71
+ # Due to load order issues and `config.expose_dsl_globally?` defaulting to
72
+ # `true` we need to put Capybara's monkey patch method back. Otherwise,
73
+ # app upgrades have a high likelyhood of having all feature specs skipped.
74
+ top_level.define_singleton_method(:ui, &main_feature) if main_feature
75
+ end
@@ -0,0 +1,5 @@
1
+ module Rspec
2
+ module Ui
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
data/lib/rspec/ui.rb ADDED
@@ -0,0 +1,69 @@
1
+ require "pry"
2
+ require "rails"
3
+ require "capybara"
4
+ require "rspec/ui/version"
5
+ require "rspec/ui/ngrok_hook"
6
+ require 'rspec/ui/context'
7
+ require 'rspec'
8
+
9
+ class RackTestWithServer < Capybara::RackTest::Driver
10
+ def needs_server?;true;end
11
+ end
12
+
13
+ Capybara.register_driver :rack_test_with_server do |app|
14
+ RackTestWithServer.new(app)
15
+ end
16
+
17
+ Capybara.configure do |config|
18
+ config.default_driver = :rack_test_with_server
19
+ end
20
+
21
+ if Rails.env.test?
22
+ RSpec.configure do |config|
23
+ config.around(:example) do |ex|
24
+ Capybara.current_session.driver.header('X-Frame-Options', 'ALLOW-FROM https://uxspec.com')
25
+ RSpec::Ui::NgrokHook.update_port(Capybara.current_session.server.port)
26
+
27
+ # if VCR present, temporarily disable the localhost & uxspec addresses
28
+ ex.run
29
+ sleep(500)
30
+ end
31
+
32
+ # config.after(:suit) do |ex|
33
+ # RSpec::Ui::NgrokHook.shutdown
34
+ # end
35
+ end
36
+ end
37
+
38
+ module UxSpec
39
+ #
40
+ # Allow external configuration of UXSpec Token & URI (for self hosting)
41
+ # potentially more in future.
42
+ #
43
+ # e.g.
44
+ #
45
+ # UxSpec.configure do |config|
46
+ # config.token = 'your_token_here'
47
+ # end
48
+ #
49
+ # Reference: https://robots.thoughtbot.com/mygem-configure-block
50
+ #
51
+ class << self
52
+ attr_accessor :configuration
53
+ end
54
+
55
+ def self.configure
56
+ self.configuration ||= Configuration.new
57
+ yield(configuration)
58
+ end
59
+
60
+ class Configuration
61
+ attr_accessor :token, :uxspec_uri
62
+
63
+ def initialize
64
+ @token = nil
65
+ @uxspec_uri = 'uxspec.com'
66
+ end
67
+ end
68
+
69
+ end
data/rspec-ui.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rspec/ui/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rspec-ui"
8
+ spec.version = Rspec::Ui::VERSION
9
+ spec.authors = ["Chris Teague"]
10
+ spec.email = ["chris@cteague.com.au"]
11
+ spec.summary = %q{Build UI tests for manual validation across multiple devices.}
12
+ spec.description = %q{Build UI tests for manual validation across multiple devices.}
13
+ spec.homepage = "https://github.com/chris-teague/rspec-ui"
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.7'
22
+ spec.add_development_dependency 'rake', '~> 10.0'
23
+ spec.add_development_dependency 'rspec-core', '~> 0'
24
+ spec.add_development_dependency 'capybara', '~> 0'
25
+ spec.add_development_dependency 'pry', '~> 0'
26
+
27
+ spec.add_runtime_dependency 'locoyo', '~> 0'
28
+ spec.add_runtime_dependency 'httparty', '~> 0'
29
+ spec.add_runtime_dependency 'rspec', '~> 0'
30
+ end
metadata ADDED
@@ -0,0 +1,169 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-ui
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Chris Teague
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-28 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.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-core
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: capybara
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: locoyo
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: httparty
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Build UI tests for manual validation across multiple devices.
126
+ email:
127
+ - chris@cteague.com.au
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - Gemfile
134
+ - LICENSE.txt
135
+ - README.md
136
+ - Rakefile
137
+ - lib/rspec/ui.rb
138
+ - lib/rspec/ui/configuration.rb
139
+ - lib/rspec/ui/context.rb
140
+ - lib/rspec/ui/dsl.rb
141
+ - lib/rspec/ui/ngrok_hook.rb
142
+ - lib/rspec/ui/ui_example_group.rb
143
+ - lib/rspec/ui/version.rb
144
+ - rspec-ui.gemspec
145
+ homepage: https://github.com/chris-teague/rspec-ui
146
+ licenses:
147
+ - MIT
148
+ metadata: {}
149
+ post_install_message:
150
+ rdoc_options: []
151
+ require_paths:
152
+ - lib
153
+ required_ruby_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ required_rubygems_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ requirements: []
164
+ rubyforge_project:
165
+ rubygems_version: 2.4.5.1
166
+ signing_key:
167
+ specification_version: 4
168
+ summary: Build UI tests for manual validation across multiple devices.
169
+ test_files: []