I get the error in subj when I'm trying to run specs or generators in a fresh rails project.
This happens when I add shoulda to the mix.
I added the following in the config/environment.rb:
config.gem 'rspec', :version => '1.2.6', :lib => false
config.gem 'rspec-rails', :version => '1.2.6', :lib => false
config.gem "thoughtbot-shoulda"...
I have a set of Test::Unit tests for a Rails application. It was developed on OS X under Ruby 1.8.6, Rails 2.3.4.
I'm also using thoughtbot-shoulda 2.10.2.
I'm using standard Rails fixtures, not factories.
I've checked out the project onto a CentOS Linux 5 workstation for another developer to work on. He's running Ruby 1.8.7.
(The ap...
With the many testing framework that is available in the Ruby community namely: unittest, rspec, shoulda, and coulda, what would be the most appropriate testing framework to test my Rails model?
Do they basically have the same functionality, which is to unittest my model? When should I use which? What is the advantage of using one and ...
For a new application I want to start dabbling in BDD and I'm trying to decide between using RSpec or Thoughtbot's Shoulda. I like the macros that Shoulda uses, and the fact that it doesn't seem to reinvent the way Ruby/Rails does testing, but simply provides an add-on. On the other hand, the macros seem like a bit too much "magic" ins...
I want to modify the test runner when using Ruby and shoulda. The standard runner produces output like this:
....
Finished in 0.009167 seconds
4 examples, 0 failures
As a starting point, I'd like to be able to modify this. Later, I want to create custom HTML output.
How do I get started on this? I've done a lot of googling, but can...
I can typically test a regular Test::Unit method using the following commandline syntax for a method "delete_user_test":
ruby functional/user_controller_test.rb -n delete_user_test
Now when I'm using the shoulda plugin with Test::Unit I try to use the same technique as follows:
...
context "Deleting a User" do
should "remove user ...
I'm looking for a way to speed up my Shoulda + FactoryGirl tests.
The model I'm trying to test (StudentExam) has associations to other models. These associated objects must exist before I can create a StudentExam. For that reason, they are created in setup.
However, one of our models (School) takes significant time to create. Becaus...
I am finding holes in my coverage because I have been mocking my models in controller examples. When I remove a model's method upon which a controller depends, I do not get a failure.
Coming from TDD in statically typed languages, I would always mock dependencies to the object under test that hit the database to increase speed. I would...
I created a new model in my rails app. Since it's a one-to-one relation with another table, there's no need for the new model to have an id column. Everything is working fine, but for some reason, all of my Shoulda tests on this model are failing. For example:
should_validate_presence_of :first_name
is throwing this error:
ActiveR...
I'm using Shoulda in combination with Test::Unit on one of the projects I work on. The issue I'm running into is that I recently changed this:
class MyModel < ActiveRecord::Base
validates_presence_of :attribute_one, :attribute_two
end
to this:
class MyModel < ActiveRecord::Base
validates_presence_of :attribute_one
validates_pr...
I have a model called "Post" which is a nested resource under a model called "Project" and I'm trying to test the controller. The code works find in my browser, but I can't get it to work in the test. Here's the test
context "on POST to :edit" do
setup do
post( :edit,
:project_id => @project1.to_param,
:id => @post1...
I recently noticed my test database is not being cleaned up after my tests run if my tests subclass Test::Unit::TestCase. If my tests subclass ActiveSupport::TestCase, everything is cleaned up properly.
Can anyone explain why, and/or provide an explanation of using one versus the other?
I am using shoulda and factory_girl.
Thanks.
...
Some functionality in my app works differently depending on the client's IP address. Is there a way to test that in Rails functional tests? I'm using Test::Unit and Shoulda.
...
Is there an easy ruby or rails command to get a list of all the tests in an application? I use Shoulda primarily, but if there's a ruby solution regardless of test suite that would work too.
...
I am using rails 2.3.5 and here is the main action in my controller.
@klass.paginated_each(:conditions => @cond ) do |record|
klass.send(:delete, record)
end
Here is my functional test with shoulda and flexmock
context 'xhr advance_search with delete_all action' do
setup do
flexmock(Article).new_instances.should_receive(:de...
I would like to stub a web service proxy before all my unit tests. I could call some shared code in each unit test, but I was wondering if there is a better way.
I am using Shoulda.
Thanks
...
Hi all,
I would appreciate if someone could help/explain the following please.
I am trying to test a controller with shoulda to see if a correct layout is used.
The method should_render_with_layout throws a NoMethodError whilst should render_with_layout passes but says the function is deferred.
Any help would be appreciated..
Thanks
...
Is there any way to logout and login another user when testing with Authlogic?
The following test case just fails
class MessagesControllerTest < ActionController::TestCase
setup :activate_authlogic
should "sender send a message and recipient delete it" do
@sender = Factory(:user, :login => 'sender')
@recipient = Factory(:u...
I have a shoulda macro/method that tests controller responses for XPath conditions like so:
def self.should_have_xpath(path, &block)
should "have an element matching the path: #{path}" do
xml = REXML::Document.new @response.body
match = XPath.match(xml, path)
if block_given?
yield match
else
assert match.si...
I wrote some tests for a several models and controllers of a Rails application using Shoulda macros, but one after another they each fail with the error
ActiveRecord::StatementInvalid: Mysql::Error: Duplicate entry '1' for key 1: INSERT INTO `replies` (`created_at`, `from_user`, `updated_at`, `read`, `text`, `tweeted_at`, `id`, `user_id...