|
20 | 20 |
|
21 | 21 | describe CharactersController do |
22 | 22 |
|
| 23 | + login_user |
| 24 | + |
23 | 25 | # This should return the minimal set of attributes required to create a valid |
24 | 26 | # Character. As you add validations to Character, be sure to |
25 | 27 | # adjust the attributes here as well. |
26 | | - let(:valid_attributes) { { } } |
| 28 | + let(:valid_attributes) do |
| 29 | + char = FactoryGirl.attributes_for(:character) |
| 30 | + char.delete :user_id |
| 31 | + char.each do |k,v| |
| 32 | + char[k] = v.to_s |
| 33 | + end |
| 34 | + char.stringify_keys |
| 35 | + end |
| 36 | + let(:new_attributes) do |
| 37 | + char = FactoryGirl.attributes_for(:character) |
| 38 | + char.delete :user_id |
| 39 | + char.each do |k,v| |
| 40 | + char[k] = v.to_s |
| 41 | + end |
| 42 | + char.stringify_keys |
| 43 | + end |
27 | 44 |
|
28 | 45 | # This should return the minimal set of values that should be in the session |
29 | 46 | # in order to pass any filters (e.g. authentication) defined in |
30 | 47 | # CharactersController. Be sure to keep this updated too. |
31 | | - let(:valid_session) { {} } |
| 48 | + let(:valid_session) { session } |
32 | 49 |
|
33 | 50 | describe "GET index" do |
34 | 51 | it "assigns all characters as @characters" do |
|
106 | 123 | # specifies that the Character created on the previous line |
107 | 124 | # receives the :update_attributes message with whatever params are |
108 | 125 | # submitted in the request. |
109 | | - Character.any_instance.should_receive(:update).with({ "these" => "params" }) |
110 | | - put :update, {:id => character.to_param, :character => { "these" => "params" }}, valid_session |
| 126 | + Character.any_instance.should_receive(:update).with(new_attributes) |
| 127 | + put :update, {:id => character.to_param, :character => new_attributes}, valid_session |
111 | 128 | end |
112 | 129 |
|
113 | 130 | it "assigns the requested character as @character" do |
|
0 commit comments