Questions tagged [factory]

1

votes
1

answer
137

Views

Factory girl conflict between field names with association

For legacy reasons, I have a model in Rails with two fields: city and city_id. city is a string with the city name. city_id is a reference to a city object. How should I declare my factory with factory_girl? I would like to populate both city_id and city like this: factory :address do street "Street...
Daniel Cukier
1

votes
0

answer
19

Views

Create an EF Core DbContext at runtime based on request parameters

Background We are building a web application using ASP.Net Core and Entity Framework Core 2.2 We are connecting to legacy databases. The setup is that there are 16 databases, all with the exact same schema, holding different contextual data. We cannot change this. We have a requirement to connect to...
JTech
1

votes
3

answer
55

Views

How to wait for invisibility of an element through PageFactory using Selenium and Java

Is there a way to wait for an element not present in Selenium using PageFactory annotations? When using: @FindBy(css= '#loading-content') WebElement pleaseWait; to locate the element, and then: wait.until(ExpectedConditions.invisibilityOfElementLocated(pleaseWait)); I would get: org.opeqa.selenium....
Mate Mrše
0

votes
0

answer
6

Views

How to map a string (ID) to the creation of a new subclass object c++

I've researched a lot but I can't seem to find anything that will actually work, or if its possible. What I need is an object factory or a registry I believe, I don't know how and no threads are really helping. They usually use ideas I'm not familiar with at all so it can be hard to follow. In my ex...
Cool Dudde
1

votes
1

answer
1.4k

Views

RSpec Controller Destroy Testing

I'm building a test application that lets user create/delete posts. I'm having a bug in my destroy action that I'm finding difficult to debug. Here's my test: describe '#destroy' do context 'existing post' do let (:post) { FactoryGirl.create(:post) } it 'removes post from table' do expect { delete :...
segue_segway
0

votes
0

answer
7

Views

How to fix “Fail to Read from Rest Source” error in REST connection to AzureDevops from Azure Data Factory V2?

I'm trying to connect to Azure Devops with a REST "resource" in Azure Data Factory V2. I've tried many different request URL provided by the documentation https://docs.microsoft.com/en-us/rest/api/azure/devops/?view=azure-devops-rest-5.1. Yet none seem to work, while other REST API connections work....
Pieter Bolte
1

votes
1

answer
18

Views

FactoryGirl not aware of new column

Hi I am using FactoryGirl 4.9.0 w/ Rails 4.2.11. I added a boolean column to a model called Query like so: class AddSetLatestResultToQueries < ActiveRecord::Migration def change add_column :queries, :latest_result_s3_url_flag, :boolean, null: false, default: false end end This flag works fine and th...
hiroprotagonist
0

votes
0

answer
3

Views

Oracle Integration Run Time Sharing Issue

I'm using Oracle Self hosted IR in my Dev data factory. Now I want to share this IR to another Data Factory and I've followed the below instructions to create the linked IR. https://docs.microsoft.com/en-us/azure/data-factory/create-self-hosted-integration-runtime But I'm receiving the below permis...
user11054940
0

votes
0

answer
3

Views

Azure ML Web Service Clustering Model

I am trying to build a web service that I can use for clustering. I will be feeding it new data and it should be running the clustering algorithm on the data and give me the output data. My doubt is whether this will be running the clustering algorithm each time the web service is called ? I basical...
frank
3

votes
1

answer
32

Views

Factorybot - How to set Nested attributes

I beleive it's better to create a new question... It follows my previous question my model product has many sizes (nested attributes) I want to create Factories but I can't make it work... A product is valid if it has at least one size (size_nameand quantity) FactoryBot.define do factory :product d...
user11025649
1

votes
1

answer
34

Views

How to populate a star schema using Azure Datafactory v2

I have a few source feeds from which I want to extract the data into a traditional star schema database (Azure SQL Database) for OLAP purposes, using Azure Data Factory v2. Most of the source feeds corresponds to a dimension, so they map to the schema in my data warehouse database, apart from the in...
jbx
0

votes
0

answer
6

Views

Ruby factory method returns a NoMethodError when it's called. What happened?

I'm trying to integrate a factory method into this imperial-to-metric converter. I can make it work independently, but when it's iterated through a hash of ingredients it brings up a NoMethodError. What did I do wrong? I've run independent instance variables through the factory without issue: @item...
Benjamin
1

votes
1

answer
1k

Views

Spring - Simply create Supplier<MyPrototypeBean>

I could not find a good and simple solution for my problem regarding different bean lifecycles. I would like to inject a @Resource private Supplier messageHandlerFactory; in a @Service bean to create a new MessageHandler instance (prototype, with its own dependencies) each time I call messageHandl...
Stefan K.
1

votes
1

answer
576

Views

angularJs loop not working in controller

I cant use loops on my controller and no error this is my code 'use strict'; var chartApp = angular.module('chartsApp'); chartApp.controller('chartController', ['$scope', 'ChartingService', function($scope, ChartingService){ var charts = ChartingService.query(); console.log(charts); for (var i = 0;...
Erez
1

votes
1

answer
482

Views

Deployment error -

I'm am getting an error when deploying ADF pipelines. I don't understand how to resolve this error message: Pipeline Populate SDW_dbo_UserProfiles from SDW_dbo_CTAS_ApptraxDevices is in Failed state. Cannot set active period Start=05/30/2017 00:00:00, End=05/29/2018 23:59:59 for pipeline 'Populate S...
Marc Jellinek
1

votes
1

answer
35

Views

Rspec before(:each) works but before(:all) does not

My ProductCategory spec:- require 'rails_helper' RSpec.describe ProductCategory, type: :model do before(:each) do @product_category = create(:product_category) end context "validations" do it "should have valid factory" do expect(@product_category).to be_valid end it "should have unique name" do...
Umesh Malhotra
1

votes
2

answer
36

Views

Clarifying uml class diagram of factory design pattern

I was learning factory method design pattern and found following class diagram in a tutorial. I understand product and concreteProduct part but Creator and ConcreteCreator part look little vague to me. I appreciate if someone clarifies the UML diagram. Thanks.
Abdur Rahman
1

votes
2

answer
102

Views

Enforce someone to use only factory for creating objects

I have a Shape interface and having Circle and Triangle classes which implements Shape interface. Lets say method is printShape() which just print type of shape. Now there is one factory class ie ShapeFactory based on factory design pattern which provides Circle and Triangle objects. Now i want t...
VJS
0

votes
0

answer
4

Views

I am confused between Unit of work pattern and Factory Pattern

factory Pattern Source https://en.wikipedia.org/wiki/Factory_method_pattern In class-based programming, the factory method pattern is a creational pattern that uses factory methods to deal with the problem of creating objects without having to specify the exact class of the object that will be creat...
Agha
2

votes
0

answer
19

Views

Laravel: Factory dependency in a model

I have a model, Log, which has a column data that stores some raw data of a message that could either represent MessageA or MessageB. I'm doing this in Laravel, and I thought a factory to return an instance of one of these messages from within Log would be the way to go via getMessage(). Below is...
musicliftsme
0

votes
0

answer
4

Views

Copy activity in Data Factory is super slow

I have source data coming from REST endpoint with sink going to SQL database. It's averaging at 20 KB/s and eventually times out at 30 mins. What could be the reason? I verified SQL is at 20% at most at DTUs
Gregory Suvalian
1

votes
2

answer
2.9k

Views

Friends, Abstract classes and Factory pattern

Good day to you all... I'm working on a complex project on my company which I use some wringled Factory Design pattern in the project. Omiting the details; I have some classes (I call them "Devices") which can only be created by "Readers": class DeviceBase // this is a virtual base class { public: /...
Ahmet Ipkin
1

votes
2

answer
458

Views

Cloning a model in Factory Girl?

I want to use Factory Girl to generate a large collection of models, each of which only differ by one or two attributes. Is there a way to have a factory accept an instance of a model? Ideally, I'd like before(:all) do data1 = create(:instance, :attribute_1 => 1, :attribute_2 => 2, :attribute_3 => "...
ayang
1

votes
3

answer
218

Views

Design inquiry: Choosing between Singleton, Factory, etc

I have read the book First Java: Design Patterns and am a newbie. I'm making my own game engine just for practice and I'm using Singleton Pattern (I know that's a sin for most of you) to create unique classes like: InputManager, ScreenManager, GameManager, etc. I really find it useful, but I don't w...
Jh62
1

votes
2

answer
986

Views

FactoryGirl calling `original_filename` for an object in rspec

I'm working the a Documents class, trying to test it. I've defined the following factory: require 'factory_girl' FactoryGirl.define do factory :document do user_id '6315' name 'Test doc' description 'W9' filename 'test_doc.pdf' filetype...
Brad Rice
1

votes
2

answer
47

Views

Where should creation conditions migrate in Factory pattern?

On this image you see some constants in source class that they help the factory to make the right object. I have been told that this is an anti-pattern and I should move those constants to another class. Should I move them to a factory class? Here is the code for Factory class: class Factory { publi...
Mohammad Rahmani
1

votes
1

answer
1.8k

Views

Factory Girl - overriding attributes of belongs_to object

I'm trying to create a Meeting object, and while doing so override the attribute of the Course object which the Meeting object belongs_to: Here are my models: class Course < ActiveRecord::Base attr_accessible :name, :description end class Meeting < ActiveRecord::Base attr_accessible :name belongs_to...
Nightwolf
1

votes
1

answer
435

Views

why does Xcode always use the method of the superclass rather than the subclass [closed]

I'm using the factory pattern in objective-c, but for some reason it's never calling the method of the subclass.. I'll explain by code: // MailBoxViewController.m -- file using the factory: SearchWorker* searchWorker = [SearchWorkerFactory getSearchWorker:param]; // whenever I call this method, it's...
abbood
1

votes
3

answer
102

Views

How to create an article of the user

I am testing the controllers with RSpec, FactoryGirls. It is my factories.rb FactoryGirl.define do factory :user do |user| user.sequence(:name) { Faker::Internet.user_name } user.email Faker::Internet.email user.password "password" user.password_confirmation "password" end factory :article do user t...
Aydar Omurbekov
1

votes
1

answer
160

Views

Do I need type checking for a C# object factory to call the appropriate methods?

Given the following pseudo C# code: class BigMessage : Message { } class SmallMessage : Message { } abstract class Message { static public Message Factory() { Random random = new Random(); int randomNumber = random.Next(0, 100); if (randomNumber > 50) { return new BigMessage(); } else { return new S...
Stephan Scheller
1

votes
3

answer
784

Views

Can a Domain Model Factory Call a Repository?

In our DDD project we are using a Factory to create our initial aggregate root model 'Order'. There is a business rule that says new Orders have their supplier 'Order.Supplier' defaulted to a specific supplier. We would need to fetch the default supplier from the database. Is it okay to call the s...
user2354863
1

votes
1

answer
46

Views

How do I do this in a more idiomatic way with RSpec and Capybara?

Doesn't work: feature "home: don't list inactive flash sales" do let(:inactive_flash_sale) { create(:inactive_flash_sale, active: false) } scenario "does not list inactive flash sales" do visit spree.root_path expect(page).to_not have_content(inactive_flash_sale.name) end end Works: feature "home: d...
Daniel Fischer
1

votes
1

answer
812

Views

Stubbing with FactoryGirl, MiniTest, and Rails 4

I am a big fan of FactoryGirl, but have never understood the ".build_stubbed" method and would like to incorporate stubbing/mocking into my TDD. Can someone help me with the basics of what kind of stubbing I can do with FactoryGirl? Should I start using Mocha or another similar GEM to handle the m...
Tom Rossi
1

votes
1

answer
142

Views

Difference between FactoryGirl.create and create

Can you explain to me what is the difference to write in my tests : FactoryGirl.create(:user, name: "boris", email: "[email protected]") and User.create(name: "boris", email: "[email protected]")
Flo Rahl
1

votes
2

answer
191

Views

Difference between using 'dynamic' vs base type when instantiating object

I am somewhat confused as to what the best approach would be when it comes to creating a new object when the type of this object is unknown until run time. Suppose I have a base class called Store in the following manner: public class Store { public Store() { Inventory = new List() } public string T...
Jose
1

votes
1

answer
432

Views

Should Factory Class' create() method be static? Or make Factory Class singleton?

Title pretty much sums it up. I have a factory class that will construct an instance of another class when it's create() method is called. I have setup my Factory Class to be a singleton, which forces invokation to look as such: SomeClass clazz = (SomeClass) FactoryClass.getInstance().create(ENUM.T...
SnakeDoc
1

votes
2

answer
1.1k

Views

FactoryGirl: Change an attribute after FactoryGirl.create is called

In my user model, all users are assigned the role of user in a before_create callback. So I'm having a lot of trouble creating an admin user to use in some tests. Here is what I've tried, which is not working: require 'spec_helper' describe "Exercises" do describe "GET /Exercises" do it "gives the e...
Arel
1

votes
1

answer
1.3k

Views

Rspec, FactoryGirl: FactoryGirl.create in before(:all) isn't persisting records?

I'm trying to create a few records for some tests I have for my Image object. However, it seems like they don't persist: describe Image do before(:all) do for i in 0..2 FactoryGirl.create(:image) end puts Image.count end it "blah blah blah" do puts Image.count end it "blah blah blah 2" do puts Imag...
deakolt
1

votes
1

answer
231

Views

Duplicated records when using factory_girl

I'm having some hard times using rspec + factory-girl. Just for start, here are my code samples: factories/users.rb require 'faker' FactoryGirl.define do factory :user do |f| f.email { Faker::Internet.email } f.password "SamplePassword" end end factories/favourites.rb FactoryGirl.define do factory :...
mbajur
1

votes
2

answer
5.5k

Views

Generic factory method to return specific object based on type

I Have the following base class : public abstract class ItemComponentSaver : where TType : ItemComponent { public abstract bool SaveItem(TType item, object objectRowInTableFromEF, PropertyInfo columnTypeProperty); } This one, also has some children, for each of the types that I support. My idea is t...
Daniel Perez

View additional questions