Hi,
I'm using Test::Unit with shoulda to test a controller.
Since I'm just testing the controller I dont wanna the view to be rendered.
I'm stubbing some objects, some errors are throw when the view is rendered, but the test shouldn't fail, because the controller is correct.
So, theres any way to disable the rendering of a template/v...
Right now I have a model function that is something like this:
Class Address
def first_line
"#{self.building_name} #{self.street_name} #{self.suburb}".squeeze(" ").strip
end
end
My address factory is define like this:
Factory.define :address do |f|
f.building_name "Alpha"
f.street_name "Bravo St"
f.suburb "Charlie"
end
...
I have a small test project that I'm using to test the waters for a much larger project. I am using rspec on rails for testing, but recently looked into Cucumber. It looks very nice, but I'm wondering if there's a way for cucumber to run my spec tests, or for rspec (autospec) to run my cucumber features. I've looked around extensively...
I would like write RSpec for my controller using RR.
I wrote following code:
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe RegistrationController do
it "should work" do
#deploy and approve are member functions
stub.instance_of(Registration).approve { true }
stub.instance_of...
Is there any command available for generating all missing spec files for existing models / controllers? I have a project that has several models that have been generated with out spec files.
...
script/generate became very annoying since i started using rspec etc. i dont need unit test files and fixtures anymore, but script/generate makes them anyway.
is it possible to set --skip-fixtures and --skip-test to be default system-wide (or at least project-wide)?
...
I'm attempting to use rspec in a rails project I've just upgraded to rails 2.3.2. I've installed rspec 1.2.6 and rspec-rails 1.2.6 as plugins in the app.
My problem is the specs don't have access to my app classes or any of the rails standard libraries.
First I had to specify the model class I want to test by using the full path from R...
I have a feeling I'm just doing something wrong syntactically but it's surprisingly difficult to Google "GET" so I was hoping someone here might know the answer to this.
I'm trying to test a Rails controller from an RSpec test. I'm following an example I found here - http://www.elevatedrails.com/articles/2007/09/10/testing-controllers-...
I'm using rspec-rails, version 1.2.6. In a controller test
describe WebsController do ...
I don't seem to have access to the controller object in order to stub methods. For example, the following won't work:
before :all do
@feed = mock_model(Feed)
controller.should_receive(:feed_from_params).and_return @feed
end
I g...
Hey all, I am completely lost on this one.
I found a code snippet online to help validate fields via ajax as the user types into them. So I'm trying to write a spec against part of it and I just can't get it to pass.
Here's the code
def validate
field = params[:field]
user = User.new(field => params[:value])
output = ""
user...
In Ioke doc, the ISpec tests are included in the documentation, see ioke.org/dok/index.html
How can this be done with Ruby's RSpec and RDoc (or SDoc)? I can't find any commandline switches or external libs to do so. Any ideas (not including implementing it all by myself ;-) )?
...
Hi,
I am writing my specs on my model Thing which has a date field which should be after the date of creation, thus I use the *validate_timeliness* plugin like that
validate_date :date, :after Time.now
I want to be able to add some Things with an anterior date but validation fails. I want to bypass the validation when creating some T...
When creating an ActiveRecord in rspec, I use fixtures for valid records.
But when using the fxitures in tests, they seem to fail validation.
In the following example, the employee seems to be perfectly valid, and yet the associated validation in the spec says they are invalid.
class Employee < ActiveRecord::Base
validates_presence_o...
It seems my rspec route for :controller => 'phones', :action => 'edit' works...it should be 'phones/123/edit', and IS according to rspec tests and rake routes. But when I create a redirect_to expectation, the expectation fails.
Here's the routes test for the url:
it "maps #edit" do
route_for(:controller => "phones", :action ...
Is there a way to do integration tests with Rspec without using Cucumber? I prefer using just plain old Webrat. Thanks.
...
Hi all,
I've been trying to get RSpec running under Ruby 1.9, and my tests just aren't running. Here's my trace:
matt@matt-desktop:~/Development/my_app$ sudo rake spec --trace
(in /home/matt/Development/my_app)
** Invoke spec (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** I...
I'm adding more rspec testing to my app and would like to test a ScoringMethods module, which is in /lib/scoring_methods.rb. So I added a /spec/lib directory and added scoring_methods_spec.rb there. I required spec_helper and set up the describe block as so:
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
descri...
Hello all,
I've just gotten started using BDD with RSpec/Cucumber/Webrat and Rails and I've run into some frustration trying to get my view spec to pass.
First of all, I am running Ruby 1.9.1p129 with Rails 2.3.2, RSpec and RSpec-Rails 1.2.6, Cucumber 0.3.11, and Webrat 0.4.4.
Here is the code relevant to my question
config/routes.rb...
I am trying to write specs for a controller without using fixtures (instead employing mock models). This controller requires a user to be logged in, for which I'm employing AuthLogic, following the author's recommendations.
describe UsersController do
def mock_user(stubs={})
@mock_user ||= mock_model(User, stubs)
end
context...
As a learning experience I'm developing a small Rails application that is supposed to query an existing SOAP API/web service (using the handsoap gem) and will simply present the information gathered there to a user.
I like using rspec and am getting used to cucumber for testing my applications. The part that has me stumped is how to tes...