shoulda

Shoulda vs Remarkable for rspec and rails

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 or remarkable. What should I prefer to use with rspec: shoulda or remarkable? And why? ...

Action works, but test doesn't (Shoulda)

I am trying to test my update action in Rails with this: context "on PUT to :update" do setup do @countdown = Factory(:countdown) @new_countdown = Factory.stub(:countdown) put :update, :id => @countdown.id, :name => @new_countdown.name, :end => @new_countdown.end end should_respond_with :redirect should_redirect_to(...

Allow blank on should validate_uniqueness_of

Using shoulda, any ideas how to allow blank when having this test: should validate_uniqueness_of(:email) Thanks. ...

why should_change macro causes deprecation warning in shoulda 2.11.0

DEPRECATION WARNING: You are using deprecated behavior which will be removed from the next major or minor release. (called from should_change at /usr/local/lib/ruby/gems/1.8/gems/shoulda-2.11.0/lib/shoulda/macros.rb:40) How e.g. this kind of test should be changed to work without a warning with new shoulda: fast_context "a" do setup ...

Test with shoulda macro fails with error

Hello! I have model: class Company < ActiveRecord::Base attr_accessible :name, :address, :description, :email, :www validates_presence_of :name, :address, :email validates_uniqueness_of :user, :name, :email validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i, :on => :create has_many :items, :...

Devise DoubleRenderError

Application-Stack: Rails3, CanCan, Devise, Shoulda I've got some nested Resources and want to test them with Shoulda and i get the following DoubleRenderError: Error: test: If anonymous user tries to GET index of fav_blogs should respond with 401. (BlogItemsControllerTest): AbstractController::DoubleRenderError: Render and/or redire...

Shoulda POST and GET Parameters for create action

How to call a create action on a nested resource with shoulda? The following code does not actual work - the end_user_id won't be used as the id for my parent resource. /blog_items_controller_test.rb post :create, :blog_item => {:id => blog_items(:blog_item_one).id}, :end_user_id => end_users(:end_user_two).id, :format => "xml" Any ...

Errors with RSpec, Shouda, and Rails 3: undefined method `response_code'

I'm not sure why I am getting these errors, seemingly only on the Shoulda matcher tests. Any advice would be helpful. http://pastie.org/1020788 ...

Shoulda rspec matchers :on => :create

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 validation in my model looks like this: validates_format_of :priority, :with => /^(Low|Normal|High|Urgent)$/, :on => :update So when runn...

Hello, I have a question about an error on shoulda macros

Hello I have a question about this error. I dont know why it happened to me, but in another pc it worked well. I've try this method class BookTest < ActiveSupport::TestCase should_validate_presence_of(:author_id) should_have_many(:customer_reviews) should_belong_to(:author) end And I got an error lik this 1) Error: test: Book...

How to make 'Shoulda' test output easier to read and in Colour!

I currently working on a project which uses Spree Cart and which has hence forced me to switch from testing with RSpec to testing with Shoulda. I really like the output I get from rspec and am wanting to get similarly readable output using Shoulda. Specifically how do I achieve similar output as I would achieve with the rspec command ...

Translating Rspec tests to Shoulda

Hello, I have a pre-written Rails app for handling subscription based payments that is currently covered with an Rspec test suite. I'm trying to merge it into a Rails app that is covered using the Shoulda test suite. I'd really hate to have to rewrite all the tests into Shoulda compatible matchers manually, so I was wondering if there m...

Current trend in testing models in a rails3 + datamapper application

Hi, What is the current trend for testing models in a Rails3+DataMapper application. I want to use RSpec but sorely miss the concise testing provided by shoulda macros. Question - Is there a way of getting the best of both worlds, ie. a nice dsl for testing and the brevity of shoulda macros, which can be used to test datamapper models. ...

@controller is nil when testing delete :destroy with Shoulda

The code below: context "should destroy participation" do setup do @p = Factory.create :participation delete :destroy, :id => @p.id.to_param end should_redirect_to(:controller => 'configuration', :action => 'edit') end Gives me the error below, any idea why? RuntimeError: @controller is nil: make sure ...

How can I test common Rails controller behavior while staying DRY?

I've been writing RSpec tests for some Rails controllers and I've discovered a strong impulse to ensure that the Authlogic authentication is working properly. I also feel like I should be verifying that each action uses the same application-wide layout. However, writing tests for this behavior in every single action seems silly. What I'...

Textmate and Shoulda: how to run a focused test

TextMate has a command 'run focused test'. The command fails to recognize that the code is a test, it says "Error: This doesn't appear to be a TestCase or spec." Does anyone know how to run a focused test from textmate or a trick/hack to get around this problem? Thanks! ...

Failing an entire context with Shoulda Unit Tests

Using shoulda with unit/test I have a context which requires one test to pass before the others are even tried. Is there a method I can invoke which will fail all following tests in the current context? Or not even run them? I'm imagining something like: context "My thing" do setup do my_variable = false end should "have my...

Unit Testing with Shoulda

edit: this problem only happens sometimes This only appears to happen when I run the test from within TextMate (even when I specify the ruby to run it from by hand with a shebang). If I run it from the terminal then everything is peachy… Here's some code: require 'test/unit' require 'shoulda' class TestingTest < Test::Unit::TestCas...

RSpec vs. Shoulda?

I am new to the unit testing seen; 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 read about RSpec and how it follows the BDD methodology. I also have read about Shoulda which is a in between the two frameworks. My question is, ...

Problem with testing validations using Shoulda .

Here's my test. class AlertSettingTest < ActiveSupport::TestCase context "For ALL Alert Settings" do setup do @alert = AlertSetting.create({ :alert_type_id=>'1',:name => 'xxx'}) end subject { @alert } should_belong_to :alert_type should_validate_presence_of :name end end Here's my model. class AlertSetting < ActiveR...