473,320 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to automate the testing of my Rails project via Ruby?

Hi,

I'm still new to Ruby on Rails, and I want to utilize
ActiveRecord::Observer. I got Observer working under the rails
environment by putting my rb files under app/model and configuring
config/environment.rb. However, I want to automate the testing of my
site via command line. Is this possible?

So, I have a foo.rb

Expand|Select|Wrap|Line Numbers
  1. (bchin ~/setup/rails/pratice/app/models)cat foo.rb
  2. class Foo < ActiveRecord::Base
  3. end
  4.  
  5.  
and my foo_observer.rb

Expand|Select|Wrap|Line Numbers
  1. (bchin ~/setup/rails/pratice/app/models)cat foo_observer.rb
  2. class FooObserver < ActiveRecord::Observer
  3.  
  4.   def after_create(foo)
  5.     puts foo.id
  6.     Foo.find(foo.id)
  7.   end
  8.  
  9. end
  10.  
  11.  
and I registered foo_observer under config/environment

Expand|Select|Wrap|Line Numbers
  1. (bchin ~/setup/rails/pratice/app/models)grep 'foo'
  2. ../../config/environment.rb
  3.   config.active_record.observers = :foo_observer
  4.  
And, when I go to the console, everything works as expected

Expand|Select|Wrap|Line Numbers
  1. (bchin ~/setup/rails/pratice/script)./console
  2. Loading development environment (Rails 2.3.2)
  3. >> Foo.create
  4. 2
  5. => #<Foo id: 2>
  6. >>
  7.  
How can I use ruby to test this? I tried creating a main.rb, which
'require' foo and foo_observer, but that doesn't seem to work. What am I
missing? Thanks for any help anyone can provide.
Oct 27 '10 #1
0 1688

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Dennis Wheeler | last post by:
I'm trying to find a commandline solution for switching projects. Currently I have to modify the IIS virtual directory path to the source files, and then open the solution file in .Net to be...
2
by: interuser | last post by:
I want to automate deployment that I now do using the "copy project" button. Is there a script that does this or ideas how to make one? I do not want to make a deployment project or use xcopy ,...
5
by: Matias | last post by:
I'm not asking if it's better or not than php... I want to know the opinions of web developers about this new toy... Byee..
122
by: seberino | last post by:
I'm interested in knowing which Python web framework is most like Ruby on Rails. I've heard of Subway and Django. Are there other Rails clones in Python land I don't know about? Which one...
10
by: rdps | last post by:
hello, I am trying to open up a webpage, say "http://gmail.com", enter username, passwd, click on submit button and do loads of other things - ALL THROUGH AUTOMATION, writing a script in python. ...
4
by: jobs | last post by:
vs.net 2005 asp.net 2.0 website. While in vs.net, and testing my project, I don't want errors to end up in debug mode in the code. I'd like them to go to the preset error page set in the web.conig....
2
by: niraan | last post by:
Hi guys, am new to rails and now am doing a project in rubyonrails. for development purpose i have use instant rails. Now i need to upload my project to the live server. i have register the domain...
2
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, can someone please tell me if this is possible and what the best way of doing it is; on my aspx page i'd like to have 2 buttons and depending on which one was clicked i'd like to go and...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.