Hi All,
I am writing specs for View, that has a menu (which is in a partial) rendered in layout. I want to write specs for selected menu. Here is the code
it "should have User Administration link" do
template.stub!(:render).and_return(:partial => "layouts/admin/menu")
do_render
#render :partial => "layouts/admin/menu" #do
...
Hi,
I am using RSpec and want to test the constructor of a Singleton class more than one time.
How can I do this?
Best regards
...
When I'm using autospec to test a non-Rails Ruby project, I always have trouble getting my tests to show up red or green.
When I run a regular 'spec spec/ --color' command I get normal red/green responses. I've tried putting all sorts of commands in the .autotest file and I can't get that to work.
Also, in my Rails projects, I don't ge...
I found example how to use on:
http://www.claytonlz.com/index.php/2009/04/how-to-setup-rspec-cucumber-webrat-rcov-and-autotest-on-leopard/
but I try to find solution to put this all gems to gem.config (enviroment.rb) with using
gemcutter gem repository (this is prefered gems repository now ?)
Maybe some one have properly configured ge...
With the 2.3.x+ rails feature of nested models, I think I need to have access to a form builder instance to properly spec partials for rendering the nested models. Pulling from the complex-forms-examples:
For example, here is an enclosing form that creates and passes the form builder to the nested model rendering view:
<div class="chil...
In rspec (1.2.9), what is the correct way to specify that an object will receive multiple calls to a method with a different argument each time?
I ask because of this confusing result:
describe Object do
it "passes, as expected" do
foo = mock('foo')
foo.should_receive(:bar).once.ordered.with(1)
foo.should_receive(:bar).o...
With RSpec and Cucumber, why is it preferred to specify :lib => false in the environment files - and then explicitly require the gems in spec_helper.rb and env.rb?
...
So, I'm trying to learn the rspec BDD testing framework in the context of a rails project. The problem I'm having is that I can't, for the life of me, get my fixtures to load properly in rspec descriptions.
Disclaimer: Yes, there are better things than fixtures to use. I'm trying to learn one thing at a time, here (specifically rspec)...
I have been writing specs for controllers and models, but I have never written a helper spec. I have no idea where I start.
I have the following snippet in application_helper.rb
def title(page_title)
content_for(:title) { page_title }
end
How should I write a helper spec on the code?
Also if there's any open-source Rails app...
We have an asynchronous task that performs a potentially long-running calculation for an object. The result is then cached on the object. To prevent multiple tasks from repeating the same work, we added locking with an atomic SQL update:
UPDATE objects SET locked = 1 WHERE id = 1234 AND locked = 0
The locking is only for the asynchr...
Hi, I'm testing the following:
Account
class Account < ActiveRecord::Base
has_many :ownerships
has_many :brands, :through => :ownerships
end
Ownership join model
class Ownership < ActiveRecord::Base
belongs_to :brand
belongs_to :account
end
Test
it "should be able to apply for brand ownership" do
account = Account.cre...
I always run autospec to run features and RSpec at the same time, but running all the features is often time-consuming on my local computer. I would run every feature before committing code.
I would like to pass the argument in autospec command. autospec doesn't obviously doesn't accept the arguments directly. Here's the output of autos...
I'm trying to check that a new action in my RESTful controller set up an instance variable of the required Object type. Seems pretty typical, but having trouble executing it
Client Controller
def new
@client = Client.new
end
Test
describe "GET 'new'" do
it "should be successful" do
get 'new'
response.should be_success
...
Hi everyone. I've been getting an error, which I think could be solved by
disabling acts_as_audited when running tests, or at least stubbing
current_user in audit sweeper. The error is below. What do you think I
should do?
NoMethodError in 'Order should create a new instance given valid attributes'
You have a nil object when you didn't ...
I have a block of code like this:
def some_method
begin
do_some_stuff
rescue WWW::Mechanize::ResponseCodeError => e
if e.response_code.to_i == 503
handle_the_situation
end
end
end
I want to test what's going on in that if e.response_code.to_i == 503 section. I can mock do_some_stuff to throw the right type of ...
I'm getting a segfault in nokogiri (1.4.1) run (under cucumber 0.6.1/webrat 0.7.0/rspec 1.3.x)
response.should have_selector("div", :class => "fieldWithErrors")
and the div in the page is actually
<div class="fieldWithErrors validation_error"> stuff </div>
Everything runs fine if I just test nokogiri against a test document
>> req...
I am trying to decide if I should use Cuke4Nuke or SpecFlow.
What are the pro/cons of each? Opinions on which is better and why.
Thanks!
...
In my RSpec controller test, I'm trying to test a particular action that makes a call to a subfunction. But I don't want the test to include the call to that subfunction. (it'll raise an error that simply cannot be fixed in my dev environment)
What's the best way to omit this subfunction call from this controller action while I'm ru...
To start out, here is the failing message:
ActiveRecord::RecordInvalid in 'Event should be valid'
Validation failed: Single access token has already been taken, Login has already been taken, Email has already been taken
Here is my factory:
Factory.define :valid_event, :class => Event do |e|
e.event_date "2010-01-01"
e.critter { |...
What I'm trying to ahieve is to do integration tests with webrat in rails3 like Yehuda does with test-unit in http://pivotallabs.com/talks/76-extending-rails-3 minute 34.
an example:
describe SomeApp
it "should show the index page"
visit "/"
body.should =~ /hello world/
end
end
Does someone knows a way to do it?
...