Skip to content

Instantly share code, notes, and snippets.

@GCorbel
Last active December 18, 2015 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GCorbel/5753042 to your computer and use it in GitHub Desktop.
Save GCorbel/5753042 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe PaintingsController do
let!(:painting) { build_stubbed(:painting) }
before do
Painting.stub(:new).and_return(painting)
end
describe "POST 'create'" do
subject { get 'create' }
context "when the painting is valid" do
before { painting.stub(:save).and_return(true) }
it { should render_template('contract') }
end
end
end
require 'spec_helper'
describe PaintingsController do
let!(:painting) { build_stubbed(:painting) }
before do
Painting.stub(:new).and_return(painting)
painting.stub(:save).and_return(true)
end
describe "POST 'create'" do
subject { get 'create' }
context "when the painting is valid" do
it { should render_template('contract') }
end
end
end
Failure/Error: before { painting.stub(:valid?).and_return(true) }
NameError:
undefined local variable or method ` painting' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1::Nested_1:0x007fb7acbe5cb0>
# ./spec/controllers/painting_controller_spec.rb:10:in `block (4 levels) in <top (required)>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment