cypress-on-rails 0.2.2 → 1.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +6 -1
- data/.rspec +1 -0
- data/.travis.yml +29 -0
- data/CHANGELOG.md +6 -0
- data/README.md +155 -54
- data/Rakefile +8 -0
- data/cypress-on-rails.gemspec +10 -9
- data/lib/cypress-on-rails.rb +3 -1
- data/lib/cypress/smart_factory_wrapper.rb +3 -0
- data/lib/cypress_dev.rb +4 -0
- data/lib/cypress_dev/command_executor.rb +33 -0
- data/lib/cypress_dev/configuration.rb +37 -0
- data/lib/cypress_dev/middleware.rb +65 -0
- data/lib/{cypress → cypress_dev}/railtie.rb +5 -7
- data/lib/cypress_dev/simple_rails_factory.rb +17 -0
- data/lib/cypress_dev/smart_factory_wrapper.rb +79 -0
- data/lib/cypress_dev/version.rb +3 -0
- data/lib/generators/cypress_dev/install_generator.rb +59 -0
- data/lib/generators/cypress_dev/templates/config/initializers/cypress_dev.rb.erb +9 -0
- data/lib/generators/cypress_dev/templates/spec/cypress.json +4 -0
- data/lib/generators/cypress_dev/templates/spec/cypress/app_commands/clean.rb +7 -0
- data/lib/generators/cypress_dev/templates/spec/cypress/app_commands/eval.rb +1 -0
- data/lib/generators/cypress_dev/templates/spec/cypress/app_commands/factory_bot.rb +12 -0
- data/lib/generators/cypress_dev/templates/spec/cypress/app_commands/scenarios/basic.rb +2 -0
- data/lib/generators/cypress_dev/templates/spec/cypress/cypress_helper.rb +30 -0
- data/lib/generators/cypress_dev/templates/spec/cypress/integration/on_rails_spec.js +33 -0
- data/lib/generators/cypress_dev/templates/spec/cypress/support/commands.js +25 -0
- data/lib/generators/cypress_dev/templates/spec/cypress/support/index.js +21 -0
- data/lib/generators/cypress_dev/templates/spec/cypress/support/on-rails.js +33 -0
- data/spec/cypress_dev/command_executor/cypress_helper.rb +6 -0
- data/spec/cypress_dev/command_executor/test_command.rb +1 -0
- data/spec/cypress_dev/command_executor/test_command_with_options.rb +1 -0
- data/spec/cypress_dev/command_executor_spec.rb +33 -0
- data/spec/cypress_dev/configuration_spec.rb +23 -0
- data/spec/cypress_dev/middleware_spec.rb +104 -0
- data/spec/cypress_dev/railtie_spec.rb +22 -0
- data/spec/cypress_dev/smart_factory_wrapper_spec.rb +83 -0
- data/spec/integrations/rails_3_2/.gitignore +9 -0
- data/spec/integrations/rails_3_2/Gemfile +7 -0
- data/spec/integrations/rails_3_2/README.rdoc +261 -0
- data/spec/integrations/rails_3_2/Rakefile +7 -0
- data/spec/integrations/rails_3_2/app/assets/stylesheets/application.css +13 -0
- data/spec/integrations/rails_3_2/app/controllers/application_controller.rb +3 -0
- data/spec/integrations/rails_3_2/app/controllers/welcome_controller.rb +4 -0
- data/spec/integrations/rails_3_2/app/helpers/application_helper.rb +2 -0
- data/spec/integrations/rails_3_2/app/models/post.rb +13 -0
- data/spec/integrations/rails_3_2/app/views/layouts/application.html.erb +13 -0
- data/spec/integrations/rails_3_2/app/views/welcome/index.html.erb +5 -0
- data/spec/integrations/rails_3_2/bin/rails +6 -0
- data/spec/integrations/rails_3_2/config.ru +4 -0
- data/spec/integrations/rails_3_2/config/application.rb +69 -0
- data/spec/integrations/rails_3_2/config/boot.rb +6 -0
- data/spec/integrations/rails_3_2/config/environment.rb +5 -0
- data/spec/integrations/rails_3_2/config/environments/development.rb +31 -0
- data/spec/integrations/rails_3_2/config/environments/production.rb +64 -0
- data/spec/integrations/rails_3_2/config/environments/test.rb +35 -0
- data/spec/integrations/rails_3_2/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/integrations/rails_3_2/config/initializers/inflections.rb +15 -0
- data/spec/integrations/rails_3_2/config/initializers/mime_types.rb +5 -0
- data/spec/integrations/rails_3_2/config/initializers/secret_token.rb +7 -0
- data/spec/integrations/rails_3_2/config/initializers/session_store.rb +8 -0
- data/spec/integrations/rails_3_2/config/initializers/wrap_parameters.rb +10 -0
- data/spec/integrations/rails_3_2/config/locales/en.yml +5 -0
- data/spec/integrations/rails_3_2/config/routes.rb +60 -0
- data/spec/integrations/rails_3_2/public/404.html +26 -0
- data/spec/integrations/rails_3_2/public/422.html +26 -0
- data/spec/integrations/rails_3_2/public/500.html +25 -0
- data/spec/integrations/rails_3_2/public/favicon.ico +0 -0
- data/spec/integrations/rails_3_2/public/robots.txt +5 -0
- data/spec/integrations/rails_3_2/test.sh +30 -0
- data/spec/integrations/rails_3_2/tmp/.keep +0 -0
- data/spec/integrations/rails_3_2/vendor/.gitkeep +0 -0
- data/spec/integrations/rails_4_2/.gitignore +10 -0
- data/spec/integrations/rails_4_2/Gemfile +8 -0
- data/spec/integrations/rails_4_2/README.rdoc +28 -0
- data/spec/integrations/rails_4_2/Rakefile +6 -0
- data/spec/integrations/rails_4_2/app/controllers/application_controller.rb +5 -0
- data/spec/integrations/rails_4_2/app/controllers/welcome_controller.rb +4 -0
- data/spec/integrations/rails_4_2/app/models/post.rb +13 -0
- data/spec/integrations/rails_4_2/app/views/layouts/application.html.erb +12 -0
- data/spec/integrations/rails_4_2/app/views/welcome/index.html.erb +5 -0
- data/spec/integrations/rails_4_2/bin/bundle +3 -0
- data/spec/integrations/rails_4_2/bin/rails +4 -0
- data/spec/integrations/rails_4_2/bin/rake +4 -0
- data/spec/integrations/rails_4_2/bin/setup +29 -0
- data/spec/integrations/rails_4_2/config.ru +4 -0
- data/spec/integrations/rails_4_2/config/application.rb +33 -0
- data/spec/integrations/rails_4_2/config/boot.rb +3 -0
- data/spec/integrations/rails_4_2/config/environment.rb +5 -0
- data/spec/integrations/rails_4_2/config/environments/development.rb +25 -0
- data/spec/integrations/rails_4_2/config/environments/production.rb +64 -0
- data/spec/integrations/rails_4_2/config/environments/test.rb +42 -0
- data/spec/integrations/rails_4_2/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/integrations/rails_4_2/config/initializers/cookies_serializer.rb +3 -0
- data/spec/integrations/rails_4_2/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/integrations/rails_4_2/config/initializers/inflections.rb +16 -0
- data/spec/integrations/rails_4_2/config/initializers/mime_types.rb +4 -0
- data/spec/integrations/rails_4_2/config/initializers/session_store.rb +3 -0
- data/spec/integrations/rails_4_2/config/initializers/to_time_preserves_timezone.rb +10 -0
- data/spec/integrations/rails_4_2/config/initializers/wrap_parameters.rb +9 -0
- data/spec/integrations/rails_4_2/config/locales/en.yml +23 -0
- data/spec/integrations/rails_4_2/config/routes.rb +56 -0
- data/spec/integrations/rails_4_2/config/secrets.yml +22 -0
- data/spec/integrations/rails_4_2/public/404.html +67 -0
- data/spec/integrations/rails_4_2/public/422.html +67 -0
- data/spec/integrations/rails_4_2/public/500.html +66 -0
- data/spec/integrations/rails_4_2/public/favicon.ico +0 -0
- data/spec/integrations/rails_4_2/public/robots.txt +5 -0
- data/spec/integrations/rails_4_2/test.sh +31 -0
- data/spec/integrations/rails_4_2/vendor/.keep +0 -0
- data/spec/integrations/rails_5_2/.gitignore +10 -0
- data/spec/integrations/rails_5_2/Gemfile +12 -0
- data/spec/integrations/rails_5_2/README.md +24 -0
- data/spec/integrations/rails_5_2/Rakefile +6 -0
- data/spec/integrations/rails_5_2/app/controllers/application_controller.rb +2 -0
- data/spec/integrations/rails_5_2/app/controllers/welcome_controller.rb +4 -0
- data/spec/integrations/rails_5_2/app/jobs/application_job.rb +2 -0
- data/spec/integrations/rails_5_2/app/models/post.rb +13 -0
- data/spec/integrations/rails_5_2/app/views/layouts/application.html.erb +12 -0
- data/spec/integrations/rails_5_2/app/views/welcome/index.html.erb +5 -0
- data/spec/integrations/rails_5_2/bin/bundle +3 -0
- data/spec/integrations/rails_5_2/bin/rails +4 -0
- data/spec/integrations/rails_5_2/bin/rake +4 -0
- data/spec/integrations/rails_5_2/bin/setup +25 -0
- data/spec/integrations/rails_5_2/bin/update +25 -0
- data/spec/integrations/rails_5_2/config.ru +5 -0
- data/spec/integrations/rails_5_2/config/application.rb +37 -0
- data/spec/integrations/rails_5_2/config/boot.rb +4 -0
- data/spec/integrations/rails_5_2/config/credentials.yml.enc +1 -0
- data/spec/integrations/rails_5_2/config/environment.rb +5 -0
- data/spec/integrations/rails_5_2/config/environments/development.rb +40 -0
- data/spec/integrations/rails_5_2/config/environments/production.rb +68 -0
- data/spec/integrations/rails_5_2/config/environments/test.rb +36 -0
- data/spec/integrations/rails_5_2/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/integrations/rails_5_2/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/integrations/rails_5_2/config/initializers/content_security_policy.rb +25 -0
- data/spec/integrations/rails_5_2/config/initializers/cookies_serializer.rb +5 -0
- data/spec/integrations/rails_5_2/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/integrations/rails_5_2/config/initializers/inflections.rb +16 -0
- data/spec/integrations/rails_5_2/config/initializers/mime_types.rb +4 -0
- data/spec/integrations/rails_5_2/config/initializers/wrap_parameters.rb +9 -0
- data/spec/integrations/rails_5_2/config/locales/en.yml +33 -0
- data/spec/integrations/rails_5_2/config/master.key +1 -0
- data/spec/integrations/rails_5_2/config/routes.rb +4 -0
- data/spec/integrations/rails_5_2/public/404.html +67 -0
- data/spec/integrations/rails_5_2/public/422.html +67 -0
- data/spec/integrations/rails_5_2/public/500.html +66 -0
- data/spec/integrations/rails_5_2/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/integrations/rails_5_2/public/apple-touch-icon.png +0 -0
- data/spec/integrations/rails_5_2/public/favicon.ico +0 -0
- data/spec/integrations/rails_5_2/public/robots.txt +1 -0
- data/spec/integrations/rails_5_2/test.sh +31 -0
- data/spec/integrations/rails_5_2/tmp/.keep +0 -0
- data/spec/integrations/rails_5_2/vendor/.keep +0 -0
- data/spec/spec_helper.rb +104 -0
- metadata +177 -25
- data/Gemfile.lock +0 -32
- data/bin/cypress +0 -3
- data/lib/cypress.rb +0 -27
- data/lib/cypress/configuration.rb +0 -41
- data/lib/cypress/middleware.rb +0 -69
- data/lib/cypress/runner.rb +0 -42
- data/lib/cypress/scenario_bank.rb +0 -21
- data/lib/cypress/scenario_context.rb +0 -23
- data/lib/cypress/version.rb +0 -3
- data/lib/generators/install_generator.rb +0 -77
data/Gemfile.lock
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
cypress-on-rails (0.1)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: http://rubygems.org/
|
8
|
-
specs:
|
9
|
-
diff-lcs (1.3)
|
10
|
-
rspec (3.7.0)
|
11
|
-
rspec-core (~> 3.7.0)
|
12
|
-
rspec-expectations (~> 3.7.0)
|
13
|
-
rspec-mocks (~> 3.7.0)
|
14
|
-
rspec-core (3.7.0)
|
15
|
-
rspec-support (~> 3.7.0)
|
16
|
-
rspec-expectations (3.7.0)
|
17
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
18
|
-
rspec-support (~> 3.7.0)
|
19
|
-
rspec-mocks (3.7.0)
|
20
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
21
|
-
rspec-support (~> 3.7.0)
|
22
|
-
rspec-support (3.7.0)
|
23
|
-
|
24
|
-
PLATFORMS
|
25
|
-
ruby
|
26
|
-
|
27
|
-
DEPENDENCIES
|
28
|
-
cypress-on-rails!
|
29
|
-
rspec
|
30
|
-
|
31
|
-
BUNDLED WITH
|
32
|
-
1.15.4
|
data/bin/cypress
DELETED
data/lib/cypress.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'active_support/dependencies/autoload'
|
2
|
-
|
3
|
-
module Cypress
|
4
|
-
extend ActiveSupport::Autoload
|
5
|
-
|
6
|
-
autoload :Runner, 'cypress/runner'
|
7
|
-
autoload :ScenarioBank, 'cypress/scenario_bank'
|
8
|
-
autoload :ScenarioContext, 'cypress/scenario_context'
|
9
|
-
autoload :Configuration, 'cypress/configuration'
|
10
|
-
autoload :Middleware, 'cypress/middleware'
|
11
|
-
|
12
|
-
def self.configuration
|
13
|
-
@configuration ||= Configuration.new
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.configure(&block)
|
17
|
-
yield configuration if block_given?
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.run_middleware?
|
21
|
-
Rails.env.test?
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
if defined?(Rails)
|
26
|
-
require_relative './cypress/railtie'
|
27
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
module Cypress
|
2
|
-
class Configuration
|
3
|
-
attr_accessor :test_framework, :db_resetter, :cache_classes, :server_port
|
4
|
-
|
5
|
-
def initialize(args=[])
|
6
|
-
setup(args)
|
7
|
-
end
|
8
|
-
|
9
|
-
def setup(args)
|
10
|
-
@args = args
|
11
|
-
@test_framework = :rspec
|
12
|
-
@db_resetter = :database_cleaner
|
13
|
-
@before = proc {}
|
14
|
-
@cache_classes = run_mode == 'run'
|
15
|
-
end
|
16
|
-
|
17
|
-
def include(mod)
|
18
|
-
ScenarioContext.send :include, mod
|
19
|
-
end
|
20
|
-
|
21
|
-
def before(&block)
|
22
|
-
if block_given?
|
23
|
-
@before = block
|
24
|
-
else
|
25
|
-
@before
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def run_mode
|
30
|
-
if @args.first == 'run'
|
31
|
-
'run'
|
32
|
-
else
|
33
|
-
'open'
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def load_support
|
38
|
-
require "./spec/cypress/cypress_helper"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
data/lib/cypress/middleware.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
module Cypress
|
4
|
-
class Middleware
|
5
|
-
def initialize(app)
|
6
|
-
@app = app
|
7
|
-
end
|
8
|
-
|
9
|
-
def call(env)
|
10
|
-
if env['REQUEST_PATH'].to_s.starts_with?('/__cypress__/')
|
11
|
-
path = env['REQUEST_PATH'].sub('/__cypress__/', '')
|
12
|
-
cmd = path.split('/').first
|
13
|
-
if respond_to?("handle_#{cmd}", true)
|
14
|
-
send "handle_#{cmd}", Rack::Request.new(env)
|
15
|
-
[201, {}, ["success"]]
|
16
|
-
else
|
17
|
-
[404, {}, ["unknown command: #{cmd}"]]
|
18
|
-
end
|
19
|
-
else
|
20
|
-
@app.call(env)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
def configuration
|
26
|
-
Cypress.configuration
|
27
|
-
end
|
28
|
-
|
29
|
-
def new_context
|
30
|
-
ScenarioContext.new(configuration)
|
31
|
-
end
|
32
|
-
|
33
|
-
def handle_setup(req)
|
34
|
-
reset_rspec if configuration.test_framework == :rspec
|
35
|
-
call_database_cleaner if configuration.db_resetter == :database_cleaner
|
36
|
-
new_context.execute configuration.before
|
37
|
-
end
|
38
|
-
|
39
|
-
def reset_rspec
|
40
|
-
require 'rspec/rails'
|
41
|
-
RSpec::Mocks.teardown
|
42
|
-
RSpec::Mocks.setup
|
43
|
-
end
|
44
|
-
|
45
|
-
def call_database_cleaner
|
46
|
-
require 'database_cleaner'
|
47
|
-
DatabaseCleaner.strategy = :truncation
|
48
|
-
DatabaseCleaner.clean
|
49
|
-
end
|
50
|
-
|
51
|
-
def json_from_body(req)
|
52
|
-
JSON.parse(req.body.read)
|
53
|
-
end
|
54
|
-
|
55
|
-
def handle_scenario(req)
|
56
|
-
handle_setup(req)
|
57
|
-
|
58
|
-
@scenario_bank = ScenarioBank.new
|
59
|
-
@scenario_bank.load
|
60
|
-
if block = @scenario_bank[json_from_body(req)['scenario']]
|
61
|
-
new_context.execute block
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def handle_eval(req)
|
66
|
-
new_context.execute json_from_body(req)['code']
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
data/lib/cypress/runner.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
module Cypress
|
2
|
-
class Runner
|
3
|
-
def initialize(args)
|
4
|
-
@args = args
|
5
|
-
@scenario_bank = ScenarioBank.new
|
6
|
-
end
|
7
|
-
|
8
|
-
def run
|
9
|
-
configuration.setup(@args)
|
10
|
-
boot_rails
|
11
|
-
Open3.popen2(*cypress_cli) do |sin, sout, status|
|
12
|
-
sout.each_line do |line|
|
13
|
-
puts "CYPRESS: #{line}"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
def configuration
|
20
|
-
Cypress.configuration
|
21
|
-
end
|
22
|
-
|
23
|
-
def boot_rails
|
24
|
-
require 'cypress/railtie'
|
25
|
-
configuration.load_support
|
26
|
-
require 'capybara/rails'
|
27
|
-
|
28
|
-
Capybara.current_driver = :selenium # oh, the irony....
|
29
|
-
Capybara.server = :puma
|
30
|
-
configuration.server_port = Capybara.current_session.server.port
|
31
|
-
end
|
32
|
-
|
33
|
-
def cypress_cli
|
34
|
-
result = ['yarn', 'run']
|
35
|
-
result += ['cypress', configuration.run_mode]
|
36
|
-
result += ['--env', "SERVER_PORT=#{configuration.server_port}"]
|
37
|
-
result += ['--record', "--key", "1511081a-e957-44f8-8df7-f305da53a39f"]
|
38
|
-
result += ['-c', 'videosFolder=spec/cypress/videos,fixturesFolder=spec/cypress/fixtures,integrationFolder=spec/cypress/integrations/,supportFile=spec/cypress/support/setup.js']
|
39
|
-
result
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Cypress
|
2
|
-
class ScenarioBank
|
3
|
-
def initialize
|
4
|
-
@scenarios = {}
|
5
|
-
end
|
6
|
-
|
7
|
-
def load
|
8
|
-
Dir['./spec/cypress/scenarios/**/*.rb'].each do |f|
|
9
|
-
instance_eval(File.read(f), f)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def scenario(name, &block)
|
14
|
-
@scenarios[name] = block
|
15
|
-
end
|
16
|
-
|
17
|
-
def [](name)
|
18
|
-
@scenarios[name.to_sym]
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Cypress
|
2
|
-
class ScenarioContext
|
3
|
-
def initialize(configuration)
|
4
|
-
if configuration.test_framework == :rspec
|
5
|
-
setup_rspec
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
def execute(block_or_code)
|
10
|
-
if block_or_code.is_a? Proc
|
11
|
-
instance_eval &block_or_code
|
12
|
-
else
|
13
|
-
instance_eval block_or_code
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
def setup_rspec
|
19
|
-
require 'rspec/rails'
|
20
|
-
extend RSpec::Mocks::ExampleMethods
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/lib/cypress/version.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
module Cypress
|
2
|
-
class InstallGenerator < Rails::Generators::Base
|
3
|
-
def install
|
4
|
-
empty_directory "spec/cypress"
|
5
|
-
empty_directory "spec/cypress/integrations"
|
6
|
-
empty_directory "spec/cypress/scenarios"
|
7
|
-
empty_directory "spec/cypress/support"
|
8
|
-
|
9
|
-
replace = [
|
10
|
-
"# when running the cypress UI, allow reloading of classes",
|
11
|
-
"config.cache_classes = (defined?(Cypress) ? Cypress.configuration.cache_classes : true)"
|
12
|
-
]
|
13
|
-
gsub_file 'config/environments/test.rb', 'config.cache_classes = true', replace.join("\n")
|
14
|
-
|
15
|
-
create_file "spec/cypress/cypress_helper.rb", <<-EOF
|
16
|
-
ENV['RAILS_ENV'] ||= 'test'
|
17
|
-
require File.expand_path('../../../config/environment', __FILE__)
|
18
|
-
|
19
|
-
Cypress.configure do |c|
|
20
|
-
# change this to nil, if you are not using RSpec Mocks
|
21
|
-
c.test_framework = :rspec
|
22
|
-
|
23
|
-
# change this to nil, if you are not using DatabaseCleaner
|
24
|
-
c.db_resetter = :database_cleaner
|
25
|
-
|
26
|
-
c.before do
|
27
|
-
# this is called when you call cy.setupScenario
|
28
|
-
# use it to reset your application state
|
29
|
-
end
|
30
|
-
|
31
|
-
# add a module to your run context
|
32
|
-
# c.include MyModule
|
33
|
-
end
|
34
|
-
EOF
|
35
|
-
|
36
|
-
create_file "spec/cypress/integrations/simple_spec.js", <<-FILE
|
37
|
-
describe('My First Test', function() {
|
38
|
-
it('visit root', function() {
|
39
|
-
// This calls to the backend to prepare the application state
|
40
|
-
// see the scenarios directory
|
41
|
-
cy.setupScenario('basic')
|
42
|
-
|
43
|
-
// The application unter test is available at SERVER_PORT
|
44
|
-
cy.visit('http://localhost:'+Cypress.env("SERVER_PORT"))
|
45
|
-
})
|
46
|
-
})
|
47
|
-
FILE
|
48
|
-
|
49
|
-
create_file "spec/cypress/scenarios/basic.rb", <<-FILE
|
50
|
-
scenario :basic do
|
51
|
-
# You can setup your Rails state here
|
52
|
-
# MyModel.create name: 'something'
|
53
|
-
end
|
54
|
-
FILE
|
55
|
-
|
56
|
-
create_file "spec/cypress/support/setup.js", <<-FILE
|
57
|
-
// cypress-on-rails: dont remove these command
|
58
|
-
Cypress.Commands.add('setupScenario', function(name) {
|
59
|
-
Cypress.log({ message: name })
|
60
|
-
cy.request('POST', 'http://localhost:' + Cypress.env("SERVER_PORT") + "/__cypress__/scenario", JSON.stringify({ scenario: name }))
|
61
|
-
});
|
62
|
-
|
63
|
-
Cypress.Commands.add('setupRails', function () {
|
64
|
-
cy.request('POST', 'http://localhost:' + Cypress.env("SERVER_PORT") + "/__cypress__/setup")
|
65
|
-
});
|
66
|
-
|
67
|
-
Cypress.Commands.add('rails', function(code) {
|
68
|
-
cy.request('POST', 'http://localhost:' + Cypress.env("SERVER_PORT") + '/__cypress__/eval', JSON.stringify({ code: code }))
|
69
|
-
})
|
70
|
-
// cypress-on-rails: end
|
71
|
-
|
72
|
-
// The next setup is optional, but if you remove it you will have to manually reset the database
|
73
|
-
beforeEach(() => { cy.setupRails() });
|
74
|
-
FILE
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|