webficient (owner)

Revisions

gist: 210655 Download_button fork
public
Description:
Example of Stubble with Shoulda
Public Clone URL: git://gist.github.com/210655.git
Embed All Files: show embed
photos_controller_test.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require 'test_helper'
 
class PhotosControllerTest < ActionController::TestCase
  context "creating a photo" do
    setup do
      login_as :valid_client_user
    end
    
    context "with valid attributes" do
      setup do
        stubbing(Photo) do |photo|
          post :create
        end
      end
 
      should_redirect_to("photo page") { photos_path }
      should "not have an error flash" do
        assert_nil flash[:error]
      end
    end
    
    context "with invalid attributes" do
      setup do
        stubbing(Photo, :as => :invalid) do |photo|
          post :create
        end
      end
      
      should_respond_with :success
      should_render_template :new
      should "have an error flash" do
        assert_not_nil flash[:error]
      end
      should_assign_to(:photo) { assigns[:photo] }
    end
  end
end