所以我用记事本作为批处理文件创建了一个琐事游戏,一切都运行良好,直到我试图说些什么并且在输入数字1或2之后崩溃你能帮忙吗?这是我的代码:
# frozen_string_literal: true
module Capybara
module CustomMatchers
include Capybara::DSL
class Asset
def asset_exists?(actual, src)
js_script = <<JSS
xhr = new XMLHttpRequest();
xhr.open('GET', '#{src}', true);
xhr.send();
JSS
actual.execute_script(js_script)
status = actual.evaluate_script('xhr.status') # get js variable value
status == 200 || status == 302
end
end
class LoadImage < Asset
def initialize(*args)
@args = args
@src = args.first
end
def matches?(actual)
is_present = actual.has_selector?("img[src='#{@src}']")
is_present && asset_exists?(actual, @src)
end
def does_not_match?(actual)
actual.has_no_selector?("img[src='#{@src}']")
end
def failure_message
"No image loaded with source: '#{@src}'"
end
def failure_message_when_negated
"Image loaded with source: '#{@src}'"
end
def description
"Verify if image with source: '#{@src}' is loaded"
end
end
class LoadFavicon < Asset
def initialize(*args)
@args = args
@rel = args.first
@href = args.second
end
def matches?(actual)
is_present = actual.has_selector?("link[rel='#{@rel}'][href='#{@href}']", visible: false)
is_present && asset_exists?(actual, @href)
end
def does_not_match?(actual)
actual.has_no_selector?("link[rel='#{@rel}'][href='#{@href}']", visible: false)
end
def failure_message
"No favicon loaded with rel: '#{@rel}' and href: '#{@href}'"
end
def failure_message_when_negated
"Favicon loaded with rel: '#{@rel}' and href: '#{@href}'"
end
def description
"Verify if favicon with rel: '#{@rel}' and href: '#{@href}' is loaded"
end
end
def load_image(*args)
LoadImage.new(*args)
end
def load_favicon(*args)
LoadFavicon.new(*args)
end
end
end
RSpec.configure do |config|
config.include Capybara::CustomMatchers
end
答案 0 :(得分:2)
if %enjoy%=1 goto thanks
==
是比较运算符,而不是=
答案 1 :(得分:0)
您应该使用 EQU :是IF command
的'等于'比较运算符你的批处理文件看起来像这样:
@echo off
echo Did You Enjoy ?
echo(
echo 1. YES ! ! !
echo 2. Not at all :(
echo(
set /p "enjoy=Your answer here (1-2) : "
if "%enjoy%" equ "1" goto thanks
if "%enjoy%" equ "2" goto why
Exit
:thanks
cls
echo(
echo Thank you! if there were any problems please email me
pause
goto exit
:why
cls
echo(
echo Can you please take the time to email me any problems you had with the program Thanks!
pause
goto exit
:exit
cls
echo test