To test whether two arrays have the same elements regardless of order, you can use the =~ matcher in RSpec < 2.11...
Update: This trick probably isn't very useful anymore in Ruby 2.x. The Ruby GC has improved a lot...
If you’re testing the behavior of deprecated code in your Ruby project, the warning messages littered throughout your spec...
In RSpec 2 shared_examples_for can have parameters. You can simply hand over arguments from it_behaves...
You can usually just use the eq matched to compare two numbers: expect(deal.total).to eq(120)
RSpec 1, RSpec 2 To test whether two arrays have the same elements regardless of order, RSpec 1 and 2...
If your controller spec never reaches your controller code: Make sure you are signed in. Make sure you are actually...
Plugins (and gems) are typically tested using a complete sample rails application that lives in the spec folder of the...
If a controller action responds to other formats than HTML (XML, PDF, Excel, JSON, ...), you can reach that code in...
You will need to upgrade to RSpec >= 2 and rspec-rails >= 2 for Rails 3. Here are some hints to...
Inside before :each blocks you can refer to variables that you introduce via let later on. They do not need...
RSpec's context (which is basically an alias for describe) takes over your whole application. No object may have its...
With its you can switch the subject of an example to a method value of the current subject: describe Array...
To only run a single describe/context block in a long spec, you can say spec spec/models/note_spec.rb:545 ... where the describe...
When a spec only runs when it is called directly, but not as part of the whole test suite, make...
By default, Cucumber uses mocha. This note shows to use RSpec stubs and mocks instead. Rspec 1 / Rails 2
This is an awesome gadget in your toolbox, even if your test coverage is great. gem install ruby-debug (Ruby...
This raises "Could not find first Keyword": describe Keyword do it { should validate_uniqueness_of(:text) } end Do this instead...
There will probably be better solutions as we become more experienced with using Bundler, and more command line tools become...
Update RubyGems and Passenger Bundler requires Rubygems >= 1.3.6. Run gem update --system if you have an older version.
There are three ways to define your own RSpec matchers, with increasing complexibility and options: 1) Use RSpec::Matchers.define
When you roll custom URLs with hacks like routing-filter, you can put a spec like this into spec/routing/routing_spec.rb:
Don't use should validate_format_of(...) because that matcher works in weird ways. Use the allow_value matcher instead...
Our awesome collection of rspec helpers (formerly known as "spec_candy.rb") is now available as a gem. It works, it is...