This可能是重复的,但是对我来说不起作用。 请让我知道我想念的是什么。
配置详细信息:
#Gemfile
gem 'factory_bot_rails' # 4.8.2
#spec/rails_helper.rb
RSpec.configure do |config|
config.include FactoryBot::Syntax::Methods
#other config
end
spec / factories / otps.rb
FactoryBot.define do
factory :otp do
phone { Faker::Number.number(10) }
expiry { Time.now + Otp::Constants::EXPIRY_DURATION }
password { Faker::Number.number(4) }
end
end
spec / requests / authentication_controller_spec.rb
require 'spec_helper'
RSpec.describe "Authentication", :type => :request do
describe "when invalid OTP is passed" do
it "should return bad request" do
otp = create(:otp) # ===> Throws error
end
end
end
答案 0 :(得分:1)
更改您的规范以包括合适的助手:
Item
如果您使用的是@FXML
void handleAdd(){ //When add button is clicked
fontSize = 16.0;
listView.setCellFactory(cell -> {
ListCell<String> cel = new ListCell<String>() {
@Override
protected void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (item != null) {
setTextFill(colorPicker.getValue());
setFont(Font.font(16));
setText(item);
} else {
setText("");
}
}
};
return cel;
});
listView.getItems().add(input.getText()); //input is my TextField
input.clear();
}
文件,则还可以跳过该行,其中包括:
require 'rails_helper'
RSpec.describe "Authentication", :type => :request do
describe "when invalid OTP is passed" do
it "should return bad request" do
otp = create(:otp)
end
end
end