How to use RSpec’s should_raise with any kind of exception?
expect { some_method }.to raise_error RSpec 1 Syntax: lambda { some_method }.should raise_error See the documentation (for RSpec 1 syntax) and RSpec 2 documentation for more.
expect { some_method }.to raise_error RSpec 1 Syntax: lambda { some_method }.should raise_error See the documentation (for RSpec 1 syntax) and RSpec 2 documentation for more.
You need to add the following line at every environment: config.action_mailer.default_url_options = { :host => “yourhost” } That way, it can work in all environments and could be different from environment to environment. For example: development.rb config.action_mailer.default_url_options = { :host => “dev.yourhost.com” } test.rb config.action_mailer.default_url_options = { :host => “test.yourhost.com” } production.rb config.action_mailer.default_url_options = { … Read more
tl;dr At Pivotal we wrote Cedar because we use and love Rspec on our Ruby projects. Cedar isn’t meant to replace or compete with OCUnit; it’s meant to bring the possibility of BDD-style testing to Objective C, just as Rspec pioneered BDD-style testing in Ruby, but hasn’t eliminated Test::Unit. Choosing one or the other is … Read more
Try array.should =~ another_array The best documentation on this I can find is the code itself, which is here.
Or you can skip rake and use the ‘rspec’ command: bundle exec rspec path/to/spec/file.rb In your case I think as long as your ./spec/db_spec.rb file includes the appropriate helpers, it should work fine. If you’re using an older version of rspec it is: bundle exec spec path/to/spec/file.rb
Usually I do: rspec ./spec/controllers/groups_controller_spec.rb:42 Where 42 represents the line of the test I want to run. You can also use tags. See here. Using bundle exec: bundle exec rspec ./spec/controllers/groups_controller_spec.rb:42
I always prefer let to an instance variable for a couple of reasons: Instance variables spring into existence when referenced. This means that if you fat finger the spelling of the instance variable, a new one will be created and initialized to nil, which can lead to subtle bugs and false positives. Since let creates … Read more