shoulda

rake not running unit tests

I've upgraded my app from using config.gem to a Gemfile with bundler and have noticed that my unit tests have now stopped running. It's a bit strange and I'm not entirely sure where to start looking. When I run rake test:units --trace I can see my environment being setup and it lists the files it intends to execute, but then it just re...

Get HTTP response Using Shoulda Ruby on Rails

I'm migrating over to shoulda from rspec and I can't seem to get access to the http response. Can someone point out what I may be doing wrong? context "doing somethin" do setup do get :index end @response.body should respond_with :success end When i run this i get an error saying that @response is a...

Factory Girl with has many relationship (and a protected attribute)

Hello, I have this kind of relation: class Article < ActiveRecord::Base has_many :comments end class Comment < ActiveRecord::Base belongs_to :article attr_protected :article_id end The default scenario inside controllers looks like: @article = Article.create(:title => "foobar") @comment = @article.comments.create(:content => ...

NameError: uninitialized constant Test::Unit::AssertionFailedError when upgrading to rails3

I'm trying to upgrade my rails application to Rails3. When I run functional tests, I get a lot of NameError: uninitialized constant Test::Unit::AssertionFailedError errors. But unit tests and website itself seems to work fine. Trace looks like this: NameError: uninitialized constant Test::Unit::AssertionFailedError /Users/mantas/.rvm/...

shoulda should "be valid" do fails with "'handle_matcher': undefined method 'matches?'"

I'm trying out 'shoulda' on top of rspec (rails 3) with the following spec: require 'spec_helper' describe Article do should "be true" do assert true end end and it fails with /Users/jeppe/.rvm/gems/ruby-1.8.7-p302/gems/rspec-expectations-2.0.0.beta.20/lib/rspec/expectations/handler.rb:11:in `handle_matcher': undefined method...

Association not finding created objects in tests

I have following models in my app: class Game < ActiveRecord::Base has_many :players has_many :villages, :through => :players end class Village < ActiveRecord::Base belongs_to :player end class Player < ActiveRecord::Base belongs_to :game has_many :villages before_create :build_starting_village protected def...

Shoulda helpers don't work

I have one spec: require 'spec_helper' # hmm... I need to include it here because if I include it inside describe block `method_missing` exception raises. include Shoulda::ActionController::Matchers describe CategoriesController do include Devise::TestHelpers render_views context "new should render template :new" do setup ...

assigns_to doesn't work for Rails 3 Shoulda on Ubuntu

Hi I'm using Rails3 with rspec and shoulda. I have the below spec describe PagesController, "on GET to show while logged off" do before(:each) do @site = Factory.create(:site) @site.domains << Factory.create(:domain) @site.save! @site.pages << Factory.create(:page) @site.menus << Factory.create(:menu, {:site=>@si...

Shoulda: unknown error with validates_each

I'm having an awful time trying to understand what my validation method is having trouble with. I installed shoulda and when I tried to use it it errors out with a strange undefined method NoMethodError: undefined method '[]' for false:FalseClass which is very odd. I narrowed it down to this piece of offending code: validates_each :na...

Mocking/Stubbing an Application Controller method with Mocha (Using Shoulda, Rails 3)

While writing functional tests for a controller, I came across a scenario where I have a before_filter requesting some information from the database that one of my tests requires. I'm using Factory_girl to generate test data but I want to avoid hitting the database when its not explicitly needed. I'd also like to avoid testing my before_...

How are both of these tests passing?

I'm using Shoulda, Mocha, and Test::Unit for testing. I have the following controller and test: class FoosController < ApplicationController caches_action :show def show @foo = requested_foo end private def requested_foo Foo.find(params[:id]) end end class FoosCachingTest < ActionController::IntegrationTest def s...

Rspec, shoulda and spork does not work together

Hi all, when I run rspec spec/models result is OK. But when I use spork, every test where shoulda macros (like it { should validate_presence_of(:title) } is used FAILS with error like: undefined method 'validate_presence_of' for ... I use: rails (3.0.0) shoulda (2.11.3) spork (0.8.4) rspec-rails (>= 2.0.0.beta.22) spec/spec_helper....

Adding custom shoulda matchers to TestCase

After using shoulda it is very clear that shoulda no longer uses macros (They are all deprecated for the preferred matchers) For example: should_allow_custom_test is deprecated for the following: should allow_custom_test However all the documentation I can find is for the former macro setup by placing them in the shoulda_macros dir...

Can you use RSpec, Shoulda, RCov?

I am attempting to get RCov to work with my RSpec and Shoulda test for a rails 3 app. It seems to work fine with my RSpec after using the Rake task below but all of the shoulda tests fail and I cant seem to find any documentation on getting these to work. They all run fine under autotest(rspec and shoulda). namespace :spec do desc "...