fixtures

How do you solve FixtureClassNotFound: No class attached to find

不羁的心 提交于 2019-12-05 01:10:03
When running my tests I get this error: FixtureClassNotFound: No class attached to find What causes this error and how to fix it? Yoni Baciu Most likely this happens because a custom table name is used for a Model (using the set_table_name) or the model is in a module. To solve, you need to add a set_fixture_class line in the test_helper.rb before the fixtures :all line: class ActiveSupport::TestCase self.use_transactional_fixtures = true . . . set_fixture_class my_table_name: MyModule::MyClass fixtures :all end In this case the fixtures file should be called my_table_name.yml NOTE: It would

Can I parameterize a pytest fixture with other fixtures?

别来无恙 提交于 2019-12-04 23:37:37
问题 I have a python test that uses a fixture for credentials (a tuple of userid and password) def test_something(credentials) (userid, password) = credentials print("Hello {0}, welcome to my test".format(userid)) and I have pytest fixture for credentials: @pytest.fixture() def credentials(): return ("my_userid", "my_password") It works great Now I want to extend this for multiple credentials (say staging and production) so that my test will run twice (once each for staging and production). I

How can I load HABTM-with-foreign-key relationships in my fixtures?

一曲冷凌霜 提交于 2019-12-04 22:33:26
问题 I have the following two models: School and User, and a HABTM relationship between them, with a join table. In this join table, the foreign key refering to the User table is not called user_id but student_id . class School < ActiveRecord::Base has_and_belongs_to_many :students, :class_name => "User", :join_table => "schools_students", :foreign_key => "student_id" end class User < ActiveRecord::Base has_and_belongs_to_many :studying_schools, :class_name => "School", :join_table => "schools

Error while integrating html with testacularjs

我的未来我决定 提交于 2019-12-04 21:25:10
问题 How do I integrate (html) fixtures with testacular? Is there any recommendation for performing DOM based tests or is it an anti-pattern? Objective : I am trying to test a custom module which parses the DOM tree and creates a new data structure. The DOM tree can be dynamic (like contents of a html/markdown editor) and hence is not a good candidate for end to end testing Problem : I am trying to use jasmine-jquery for this DOM testing and in my testacular.conf.js, I have the section to allow

How to create fixtures with foreign key alias in rails?

六月ゝ 毕业季﹏ 提交于 2019-12-04 19:26:20
I have two models, App and User , where an App has a creator who is a User . # app.rb class App < ActiveRecord::Base belongs_to :creator, class_name: 'User' end # user.rb class User < ActiveRecord::Base has_many :apps, foreign_key: "creator_id" end How do I create fixtures for this? I tried: # apps.yml myapp: name: MyApp creator: admin (User) # users.yml admin: name: admin But this doesn't work, since the relation is an aliased foreign key, not a polymorphic type. Omitting the (User) in the creator line doesn't work either. I have seen several threads about Foreign Key and fixtures, but none

What is the difference between “rake db:seed” and rake db:fixtures:load"

你离开我真会死。 提交于 2019-12-04 12:54:20
问题 I am new to Ruby and Rails and am curious about something. In two different tutorials I am looking at they use different methods for populating a database with basic test information. One uses "rake db:seed" to pull from a text file with sample data. The other uses "rake db:fixtures:load". To me they appear to do the exact same thing. Do they, or am I missing something here? (Highly likely) 回答1: rake db:seeds loads the data from db/seeds.rb into the database. This is generally used for

Can I pass arguments to pytest fixtures?

假装没事ソ 提交于 2019-12-04 11:30:06
问题 The baseline of all my tests is that there will always be a taxi with at least one passenger in it. I can easily achieve this setup with some basic fixtures: from blah import Passenger, Taxi @pytest.fixture def passenger(): return Passenger() @pytest.fixture def taxi(passenger): return Taxi(rear_seat=passenger) Testing the baseline is straightforward: def test_taxi_contains_passenger(taxi) assert taxi.has_passenger() My issue crops up when I start needing more complicated test setup. There

Doctrine fixtures - circular references

我与影子孤独终老i 提交于 2019-12-04 08:55:43
Is there any way to load fixtures that have circular referencing? As an example I have the following fixture: BusinessEntityTeam: Nicole_Team: name: Nicole's Team Manager: [Nicole] Business: [ACMEWidgets] sfGuardUser Nicole: first_name: Nicole last_name: Jones email_address: nicole@example.com username: nicole password: nicole Groups: [Group_abc] Team: [Nicole_Team] As you can see, Nicole_Team references Nicole... but Nicole also references Nicole_Team. When Manager wasn't a required column this was OK (the fixture loaded, but Manager was NULL), but now it's required it's impossible to load

Symfony framework - load Cyrillic data into database from fixtures

左心房为你撑大大i 提交于 2019-12-04 06:43:48
问题 How can I load data into database from fixture files with Cyrillic data? I've tried, but data in database is converted to ??? symbols. My fixture file is saved in UTF-8 encoding. 回答1: Are you using MySQL? You may need to change the collation and/or character sets for the tables in your database. A whole section exists in the MySQL Manual on this topic which I recommend if your project scope for internationalisation is wide, but essentially applying this SQL to each table will help you: ALTER

How to make has_many :through association with fixtures?

旧时模样 提交于 2019-12-04 06:15:36
问题 I can't use factory_girl because I'm testing sunspot and need real database. Edit : nope. It can works with sunspot. I'm wrong. How can I build has_many :through(a.k.a many-to-many) associations in fixtures? I google it and get a invalid solution Edit : Finally I use factory_girl. I google-copy-paste a snippet: factory :tagging do question { |a| a.association(:question) } tag { |a| a.association(:tag) } end (question has_many tags through taggings, vice versa) It works well. But what's it?