shoulda Questions

2

I have a user class with an email that is unique but scoped to the tenant: class User < ActiveRecord::Base validates :email, :uniqueness => {:scope => :tenant_id, :allow_blank => true...
Predict asked 12/3, 2012 at 10:26

6

Solved

I have following Rspec test: describe Productlimit do before(:each) do @productlimit = Factory.create(:productlimit, :user => Factory.create(:user)) end subject { @productlimit } ... ...
Afflux asked 3/7, 2011 at 16:35

5

Solved

After learning about shoulda-matchers by answering another StackOverflow question on attribute accessibility tests (and thinking they were pretty awesome), I decided to try refactoring the model te...
Lockhart asked 20/8, 2012 at 1:13

8

Solved

I am setting up a rails app and I just finished making some unit tests and my friend said that apparently fixtures are no longer cool and people are now using RSpec or shoulda. I was wondering what...
Byzantium asked 21/9, 2008 at 1:47

1

Solved

In my code I had the following validation with Shoulda matchers, which works fine: it { should validate_presence_of(:name) } In my model, I've added the condition to my validation: validates_pr...
Seema asked 11/12, 2012 at 2:31

3

I have a test more or less like this: class FormDefinitionTest < ActiveSupport::TestCase context "a form_definition" do setup do @definition = SeedData.form_definition # ... I've purposel...
Alixaliza asked 18/11, 2010 at 11:26

1

Solved

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') {la...
Bicentenary asked 2/8, 2012 at 9:55

4

Solved

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.
Nordau asked 19/1, 2010 at 3:47

3

Solved

I've inherited an old Rails2.3 app. It's very complex and has (shock, horror) no tests whatsoever. I'm used to rspec and cucumber so I thought I'd start working on getting specs and features define...
Ascendancy asked 2/6, 2011 at 13:58

3

Solved

I'm testing my ActiveRecord models with Rspec. I've just added a custom error message to one of my validations, like this: validates :accepted_terms_at, :presence => {:message => 'You must a...
Deltoro asked 8/12, 2011 at 15:14

3

Solved

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 ...
Boddie asked 29/10, 2009 at 6:59

2

Solved

I'm using rspec and cucumber for BBD. Now I'm migrating to rails 3 and rspec 2 and as I could see both of frameworks (shoulda and remarkable) support rails 3 and rspec 2. I have never used shoulda...
Halloween asked 11/6, 2010 at 14:42

13

Solved

I'm trying to set up Factory Girl with Test::Unit and Shoulda in Ruby on Rails. I have installed the gem, created my factory file under the test/factories directory, and created my spec file under ...
Amor asked 21/7, 2009 at 15:38

1

I'm using shoulda-matchers with rails and I'm creating a model called "comments" and another model called "post". Comments is polymorphic. When I test with shoulda matchers in post like this it...
Legault asked 9/3, 2011 at 10:24

1

Solved

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 f...
Stauder asked 11/7, 2011 at 23:47

1

I am using some of the Shoulda rspec matchers to the test my model, one of them being: describe Issue do it { should_not allow_value("test").for(:priority) } end My problem with this is that my...
Eccrine asked 28/6, 2010 at 16:7

2

Solved

tried to find but with no success. Just wondering how could I test scopes in Rails 3. Could be using rspec, shoulda or just a test unit. Thanks. Actually, I trying this way, but it's not complet...
Beckerman asked 30/1, 2011 at 1:20

3

Solved

I am new to the unit testing scene; I have only been using unit tests for about 2 months now. When I unit test in Ruby I currently follow the TDD style and use Test::Unit::TestCase. I have also rea...
Taker asked 30/8, 2010 at 22:1

2

Solved

I've used Shoulda for a while, and I've read and played with Rspec. I have not done an in-depth compare and contrast. But it seems to me like there is some overlap between the two, but that they ar...
Moneymaking asked 5/1, 2011 at 21:46

3

Solved

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 lookin...
Cloying asked 1/9, 2010 at 23:21

2

Solved

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 'v...
Mither asked 8/10, 2010 at 20:53

1

Solved

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 defaul...

3

Solved

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 sh...
Dilator asked 7/4, 2010 at 7:54

2

Solved

I'm having some difficulties in testing devise with shoulda: 2) Error: test: handle :index logged as admin should redirect to Daily page. (Admin::DailyClosesControllerTest): NoMethodError: undefin...
Fossil asked 15/5, 2010 at 7:42

1

Solved

I am trying to simulate a session using FactoryGirl/shoulda (it worked with fixtures but i am having problems with using factories). I have following factories (user login and email both have uniqu...
Hedgerow asked 23/4, 2010 at 9:8

© 2022 - 2024 — McMap. All rights reserved.