1

この仕様に合格しようとしていますが、それが何を意味するのかわかりません。これが完全な仕様です。2 番目のは、失敗している例です。

describe "PUT update" do
    describe "with valid params" do
      it "updates the requested experience_level" do
        experience_level = ExperienceLevel.create! valid_attributes
        # Assuming there are no other experience_levels in the database, this
        # specifies that the ExperienceLevel created on the previous line
        # receives the :update_attributes message with whatever params are
        # submitted in the request.
        ExperienceLevel.any_instance.should_receive(:update_attributes).with({ "name" => "MyString" })
        put :update, {:id => experience_level.to_param, :experience_level => { "name" => "MyString" }}
      end

      it "assigns the requested experience_level as @experience_level" do
        experience_level = ExperienceLevel.create!(name: 'test'), valid_attributes
        put :update, {:id => experience_level.to_param, :experience_level => valid_attributes}
        assigns(:experience_level).should eq(experience_level)
      end

      it "redirects to the experience_level" do
        experience_level = ExperienceLevel.create! valid_attributes
        put :update, {:id => experience_level.to_param, :experience_level => valid_attributes}
        response.should redirect_to(experience_level)
      end
    end

ターミナルのメッセージは次のとおりです。

1) ExperienceLevelsController PUT update with valid params assigns the requested experience_level as @experience_level
     Failure/Error: assigns(:experience_level).should eq(experience_level)

       expected: [#<ExperienceLevel id: 1, name: "test", description: nil, created_at: "2013-10-10 20:40:05", updated_at: "2013-10-10 20:40:05">, {"name"=>"MyString"}]
            got: #<ExperienceLevel id: 1, name: "MyString", description: nil, created_at: "2013-10-10 20:40:05", updated_at: "2013-10-10 20:40:05">

       (compared using ==)

       Diff:
       @@ -1,3 +1,2 @@
       -[#<ExperienceLevel id: 1, name: "test", description: nil, created_at: "2013-10-10 20:40:05", updated_at: "2013-10-10 20:40:05">,
       - {"name"=>"MyString"}]
       +#<ExperienceLevel id: 1, name: "MyString", description: nil, created_at: "2013-10-10 20:40:05", updated_at: "2013-10-10 20:40:05">

     # ./spec/controllers/experience_levels_controller_spec.rb:100:in `block (4 levels) in <top (required)>'
4

1 に答える 1