
Security News
New CVE Forecasting Tool Predicts 47,000 Disclosures in 2025
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Functionality of mock_model
and stub_model
from rspec-rails for those using Mocha.
Installation for Rails 3 (rspec-rails v2.6 and above):
# Gemfile
group :development, :test do
gem 'rspec-rails', '~> 2.4'
end
group :test do
gem 'rspec-rails-mocha', '~> 0.3.1', :require => false
end
# spec/spec_helper.rb
require 'rspec/rails'
require 'rspec/rails/mocha'
For Rails 2 (rspec-rails v1.3.x), use the '0.2.x' branch:
gem 'rspec-rails-mocha', '~> 0.2.1'
Then, for any version of Rails, ensure that your "spec_helper.rb" file
doesn't contain config.mock_with :rspec
.
Usage:
describe "Mocha plugin" do
it "#mock_model should use given ID" do
person = mock_model(Person, :id => 66)
person.should_not be_new_record
person.id.should == 66
end
end
You should be able to use mock_model
and stub_model
in the same way
you use them when mocking with rspec instead of mocha. Here are the
docs.
FAQs
Unknown package
We found that rspec-rails-mocha demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.