You can stub a method to return different values each time it’s called;
allow(@family).to receive(:location).and_return('first', 'second', 'other')
So the first time you call @family.location
it will return ‘first’, the second time it will return ‘second’, and all subsequent times you call it, it will return ‘other’.
Related Contents:
- How to set request headers in rspec request spec?
- All Ruby tests raising: undefined method `authenticate’ for nil:NilClass
- How to check a checkbox in capybara?
- How to Test a Concern in Rails
- What’s the difference between RSpec and Cucumber? [closed]
- Rspec doesn’t see my model Class. uninitialized constant error
- How is spec/rails_helper.rb different from spec/spec_helper.rb? Do I need it?
- How to say “any_instance” “should_receive” any number of times in RSpec
- How do you test an AJAX request with RSpec/RoR?
- RSpec any_instance deprecation: how to fix it?
- Minitest and Rspec [closed]
- How to force an RSpec test to fail?
- Rspec – Rails – How to follow a redirect
- How to run a single RSpec test?
- Rails: Missing host to link to! Please provide :host parameter or set default_url_options[:host]
- How to get started on TDD with Ruby on Rails? [closed]
- How to check for a JSON response using RSpec?
- How to get current path with query string using Capybara
- Rspec, Rails: how to test private methods of controllers?
- How to say “should_receive” more times in RSpec
- RSpec controller testing – blank response.body
- Rails 4: How to reset test database?
- How do I prepare test database(s) for Rails rspec tests without running rake spec?
- RSpec: What is the difference between let and a before block?
- Generate a controller with all the RESTful functions
- Is it possible to mark a test as pending in MiniTest?
- How do I set HTTP_REFERER when testing in Rails?
- How to test ActionMailer deliver_later with rspec
- Running ruby debug in rspec?
- Ruby on Rails: Switch from test_unit to rspec
- How do I confirm a javascript popup with Capybara?
- undefined method `get’ for #
- Rails 3.1, RSpec: testing model validations
- Shoulda/RSpec matchers – conditional validation
- how to test params passed into a controller in rails 3, using rspec?
- How to stub ApplicationController method in request spec
- Clearing out ActionMailer::Base.deliveries after RSpec test
- Rails rspec set subdomain
- RSpec documentation…where is it hiding?
- How to spec a private method
- How do I test Rails migrations?
- Visit method not found in my rspec
- Rails : RuntimeError – can’t modify frozen Array when running rspec in rails
- Is it impossible to use Guard with RubyMine?
- Set Rspec default GET request format to JSON
- How to test rendering a partial with RSpec
- expected true to respond to true?
- Controller Specs vs Request Specs?
- How to test ApplicationController method defined also as a helper method?
- Why not use shared ActiveRecord connections for Rspec + Selenium?