similar to: Fixtures for non AR object

Displaying 20 results from an estimated 40000 matches similar to: "Fixtures for non AR object"

2005 Dec 12
2
Using a lib in YAML fixtures
I''m using the runt library [1] to do some temporal expression matching. I want to keep the expression in a binary field in my db. I figured that then in order to do the fixtures, I''d need to do some erb in the yaml file. So I came up with this: onetime: id: 1 name: One Time description: This event occurs only one time. timex: <%= REYear.new(7) & REMonth.new(24)
2006 Jun 07
6
I want to stick my models in a module
I''ve got enough models now that I''d like to separate them into modules. For example, I have the class Player that I want to stick in the Trainer module. I''ve changed the definition to class Trainer::Player I''ve created a models/trainer dir, test/unit/trainer, and test/fixtures/trainer. Change the PlayerTest class to be Trainer::PlayerTest. I get the
2005 Dec 21
6
Rails without a db - how to run tests
I''m writing a simple app that doesn''t need to use a database. I added :active_record to the config.frameworks -= line in environment.rb file. This lets me run ./script/generate fine without complaining about no connection. However if I try to run a functional test, it complains about no connection being established. Well...I don''t want a connection to be established.
2006 May 04
2
Testing associations
I have a pretty simple model, articles and users. class Article belongs_to :user end class User has_many :articles end In my unit tests I want to ensure that the associations work properly. What''s the best way to do this? The obvious thing to do is a test in each model. # user_test.rb def test_add_post u = users(:first) before_articles = u.articles.count u.articles
2007 Jun 26
4
Can I stub a method on a belongs_to association:
describe Asset, " when destroyed" do fixtures :assets, :videos, :sites, :publish_settings before(:each) do @asset = assets(:test_asset) @mock_hook = mock("hook") @asset.video.stub!(:hook).and_return @mock_hook # error occurs here end it "should call the delete hook" do @mock_hook.should_receive(:update).with("test_video",
2007 Mar 01
2
error_on is deprecated?
The docs say DEPRECATED. See Spec::Rails::Expectations model.should_have(:no).errors_on(:attribute) model.should_have(1).error_on(:attribute) model.should_have(3).errors_on(:attribute) However the rdoc for Spec::Rails::Expectations shows the same code. The only difference is that it''s "model.should have(1).error_on(:attribute) instead" So is error_on itself deprecated, or is
2006 Jul 26
1
fixtures not loading when running rake test - ok other times
Hallo -- I have the most bizzare problem. I have a test called PropertyTest that runs absolutely fine. Even if I totally clear the test database before running it, it happily scoots off, loads all necessary fixtures, runs & passes all tests. My problem arises when I run rake test:units. Then, all other tests pass fine, but this one starts failing as if the fixture data simply
2006 Dec 08
0
Dump plugin models to fixtures?
So I''ve got several plugins running on a site I''m developing. I''m dumping my own models to fixtures using db:fixtures:dump, but models that are part of plugins like authorization/acts_as_authenticated aren''t accessible. How can I dump this data to fixtures to? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You
2006 Dec 24
6
What do you think of this controller spec?
Here''s a controller spec I wrote, it''s for a very simple RESTful controller (well, aren''t all RESTful controllers simple? :) I''ve created a couple spec helper methods to refactor some of the common code...for example, require_login_and_correct_user creates two specifications: one for when the user isn''t logged in, and one when the user is logged in but
2007 May 21
4
Just upgraded to 1.0.0, should render_text isn''t working for me
I finally got around to upgrading from 0.8.2 (!!). I had a spec which looked like specify "should render abc123" do controller.should_render :text => "abc123" get :key end With 1.0.0, the new spec is it "should render abc123" do get :key response.should render_text("abc123") end However it doesn''t work, giving me the error: undefined
2006 Jun 08
1
Module nastiness
Yesterday I was having problems getting fixtures to load correctly after moving my models into separate modules. Wrote a patch for fixtures and all was fine. Then I put my app into production mode. I''ve got two classes named Player. HHConv::Player and Trainer::Player. Rails seems to only care about the Player class that first gets loaded in, even if I name them explicitly using the
2007 Feb 22
7
We can''t 100% remove our unit tests from the database, can we?
I hope this isn''t too rambly. This is sort of a brain dump of a subject I''ve been thinking about for months as I''ve used RSpec. Let''s say we''ve got a simple query method, that will find all the users in the DB older than 18. Our model could look like class User < ActiveRecord::Base def self.find_older_than(age) find :all, :conditions =>
2006 Mar 27
5
Fixtures, Postgres & Constraints
Anyone have any tips for handling postgres constraints when using fixtures to load the database, other than to sort out the proper insertion orders or leaving the constraints out? I''d prefer not to do the former since I''d rather use my app to generate my fixture data (using a dump_fixtures task) and I''d prefer not to do the latter because leaving out constraints till the
2006 Mar 19
4
Trouble with composed_of
I''m trying to use composed_of within my model. I have a field in my database named ''card1'', which is simply a string. I have this in my model class Player < ActiveRecord::Base composed_of :card1, :class_name => ''Card'' end class Card attr_reader :value, :suit def initialize(s) @value = s[0].chr @suit = s[1].chr end end The
2006 Dec 21
5
Advice with Model tests
Hi! I''m developing a rails applicaton with specify-before approach, with nice results so far. I use mocks and stubs in both Controller and views tests, but the main issue is with model testing. Since I''ve seen many examples here and there, I don''t know if the right way is to use fixtures or not at all (in model specs). Atm, I''m using them, but I
2007 Sep 10
2
Removing an AR class definition, for testing plugins
I''m writing an acts_as_* plugin and am trying to BDD it. Ideally my specs would look like: describe ActsAsCloneable, " basic cloning" do load_example_classes School.class_eval do acts_as_cloneable end before(:each) do @old_school = School.create! :name => "Baylake Pines", :city => "Virginia Beach", :guid => "abc123"
2007 Mar 13
1
Opening the singleton class of mocked objects
I wrote a plugin [1] a while ago that lets me do validations on a single AR instance. Instead of defining validations in an AR class, I can define them on a AR instance''s singleton class: class << @video validates_presence_of :title end One of my specs mocks Video.find, and the above code is run on the mock object. When I run the spec, I get the expected undefined method
2008 Jan 11
13
Role of stories vs specs, revisited
A couple months ago I asked how stories and specs might impact each other. [1] If you look at Dan North''s example of what''s in a story [2], and you imagine using the spec framework to drive the design, you can probably imagine a significant bit of overlap in the two. Is that a bad thing? I''m not sure. It has made me a bit uncomfortable though, and I''ve
2007 Nov 13
5
Role of stories vs specs
I''ve been thinking about the role that stories played compared to specs, and that "should we use should" thread brought those thoughts up again. First I want to discuss whether or not specs are authoritative regarding the desired behavior of a system. I would say they''re a good approximation of how the system currently runs according to the developer''s
2008 Sep 09
8
Cucumber and fixtures/FixtureReplacement
Hey guys, I''d never used RSpec Stories before, so I decided to follow the apparent direction of the wind and just jump right into cucumber. I''m dabbling with/using Cucumber and really like it. Good job, aslak! Where i''m struggling right now is using either fixtures or a model factory methodology like the FixtureReplacement. In both cases, I''m not