Permalink
Browse files

Support rspec/rails/mocks without the rest of the rails framework.

  • Loading branch information...
1 parent cc1c55e commit 91ba13154f4ef1ad7bada9261aa38416e27bc0f7 @dchelimsky dchelimsky committed Apr 11, 2011
Showing with 19 additions and 0 deletions.
  1. +16 −0 features/mocks/mock_model.feature
  2. +3 −0 lib/rspec/rails/mocks.rb
View
16 features/mocks/mock_model.feature
@@ -129,3 +129,19 @@ Feature: mock_model
"""
When I run `rspec spec/models/widget_spec.rb`
Then the examples should all pass
+
+ Scenario: mock_model outside rails
+ Given a file named "mock_model_outside_rails_spec.rb" with:
+ """
+ require 'rspec/rails/mocks'
+
+ describe "Foo" do
+ it "is mockable" do
+ foo = mock_model("Foo")
+ foo.id.should eq(1001)
+ foo.to_param.should eq("1001")
+ end
+ end
+ """
+ When I run `rspec mock_model_outside_rails_spec.rb`
+ Then the examples should all pass
View
3 lib/rspec/rails/mocks.rb
@@ -1,3 +1,6 @@
+require 'active_support/core_ext'
+require 'active_model'
+
module RSpec
module Rails

0 comments on commit 91ba131

Please sign in to comment.