Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Include acceptance specs for smoke app
Add an acceptance spec to the smoke app verifying that neither
rspec-rails nor rspec-mocks has broken working models. This ensures the
following basic functionality:

- stubbing model class methods
- attribute methods (currently the only dynamic AR type method we support)
  • Loading branch information
cupakromer committed Jun 13, 2015
1 parent 4e8c36c commit 811e1cb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions example_app_generator/generate_stuff.rb
Expand Up @@ -95,6 +95,11 @@ def using_source_path(path)
generate('rspec:feature gadget')
generate('controller things custom_action')

using_source_path(File.expand_path('..', __FILE__)) do
# rspec-core loads files alphabetically, so we want this to be the first one
copy_file 'spec/features/model_mocks_integration_spec.rb'
end

begin
require 'active_job'
generate('job upload_backups')
Expand Down
@@ -0,0 +1,15 @@
require 'rails_helper'

RSpec.describe "Using rspec-mocks with models" do
it "supports stubbing class methods on models" do
allow(Widget).to receive(:all).and_return(:any_stub)
expect(Widget.all).to be :any_stub
end

it "supports stubbing attribute methods on models" do
a_widget = Widget.new
allow(a_widget).to receive(:name).and_return("Any Stub")

expect(a_widget.name).to eq "Any Stub"
end
end

0 comments on commit 811e1cb

Please sign in to comment.