Questions tagged [shoulda]

Shoulda, developed by thoughtbot, provides constructs for organizing Test::Unit tests and matchers for testing Ruby on Rails applications that work with Test::Unit or RSpec.

Shoulda organizes Test::Unit tests into a collection of nested contexts with support for setup and teardown blocks and should clauses. Shoulda also provides matchers for testing Ruby on Rails applications that work with Test::Unit, Minitest or RSpec.

Along with shoulda, thoughtbot provides many many other community libraries.


Resources


Related tags

383 questions
6
votes
1 answer

undefined method 'assign_to' after updating shoulda-matchers

I updated 'shoulda-matchers' in the Gemfile in my rails project from version 1.4.2 to 2.0.0 and now when I run my rspec tests, it is giving me the following error undefined method `assign_to' for…
Ryan
  • 9,340
  • 5
  • 39
  • 42
6
votes
5 answers

What's the main difference between cucumber and shoulda?

How would you make a decision between cucumber and shoulda if you were about to choose a testing framework? What differentiates these two frameworks primarily?
Big Pete Taylor
  • 135
  • 1
  • 6
6
votes
1 answer

rails attr_accessible rspec check

When I want to test if attribute is / is not accessible with RSpec I'm doing it like this class Foo attr_accesible :something_else end describe Foo do it('author should not be accessible') {lambda{described_class.new(:author=>true)}.should…
equivalent8
  • 13,754
  • 8
  • 81
  • 109
5
votes
1 answer

Unit testing a module that is included in ActiveRecord models

I have a module like this (but more complicated): module Aliasable def self.included(base) base.has_many :aliases, :as => :aliasable end end which I include in several models. Currently for testing I make another module as below, which I…
mike
  • 431
  • 3
  • 8
5
votes
2 answers

How to correctly check uniqueness and scope with Shoulda

I have a User model that has a child association of items. The :name of items should be unique for the user, but it should allow different users to have an item with the same name. The Item model is currently set up as: class Item <…
5
votes
1 answer

Shoulda-matcher How to validate uniqueness of enum attribute?

I use rspec-rails with shoulda-matcher to test my model. Here is the code: user_ticket.rb class UserTicket < ActiveRecord::Base belongs_to :user belongs_to :ticket enum relation_type: %w( creator supporter ) validates_uniqueness_of…
Hieu Pham
  • 6,577
  • 2
  • 30
  • 50
5
votes
2 answers

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…
Mantas
  • 5,691
  • 6
  • 27
  • 24
5
votes
3 answers

Confused - spec_helper.rb:94:in `': uninitialized constant Shoulda (NameError)

I am working on a project with Rails 4 & Mongoid 4. I am trying to set up Shoulda-matchers (version 2.8.0), following thoughtbot/shoulda-matchers, which points to another README called README for 2.8.0. And I am hoping to use the mongoid-rspec for…
zkytony
  • 1,242
  • 2
  • 18
  • 35
5
votes
3 answers

testing my Ruby gem: undefined method `configure' for Shoulda::Matchers:Module (NoMethodError)

I'm working on my first Ruby gem and have bundled cucumber, rspec and shoulda-matches for testing. When I run rspec, I get the following error: /app/my_gem/spec/spec_helper.rb:6:in `': undefined method `configure' for…
sixty4bit
  • 7,422
  • 7
  • 33
  • 57
5
votes
2 answers

Autotest, Shoulda, Ruby - The Setup?

I am trying to get the whole setup working with Autotest/Growl/Shoulda on my Mac to test a gem I'm working on for Authlogic. I've used RSpec in the past quite a bit but would like to switch to Shoulda. This gem is going to work with Rails, but…
Lance
  • 75,200
  • 93
  • 289
  • 503
5
votes
3 answers

shoulda macros with rspec2 beta 5 and rails3 beta2

I've setup Rspec2 beta5 and shoulda as following to use shoulda macros inside rspec model tests. ================= Update 2011-Feb-18 Now we can use shoulda-matchers out of the box. Just add gem shoulda-matchers in you Gemfile and nothing else in…
millisami
  • 9,931
  • 15
  • 70
  • 112
5
votes
2 answers

How can I generate a report that shows me my slowest running tests in Rails 3.2, Ruby 1.9?

I know that RSpec has the --profile option, but I'm only using MiniTest/shoulda for my current project.
Farley Knight
  • 1,795
  • 1
  • 13
  • 17
5
votes
3 answers

Shoulda testing workflow from the trenches

Everyone is talking about TDD (BDD) in Rails (and not just Rails) development world today. It's easy to find plenty of good general information about it, there are quite a few tools you can use for this purpose and there are many (good) examples of…
Milan Novota
  • 15,506
  • 7
  • 54
  • 62
5
votes
4 answers

Shoulda + FactoryGirl: Can I make my tests faster?

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…
Kyle Fox
  • 3,133
  • 4
  • 23
  • 26
4
votes
3 answers

Capybara issue: @request must be an ActionDispatch::Request

I'm having problems making Capybara work with Rails. Just testing that suposedly interesting test thing. OK, in the attached code there are a couple of equivalent tests. The first one is made with shoulda-context + Test::Unit that comes with Rails. …
marcel massana
  • 367
  • 3
  • 11