Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-4971

Fix lib/rb/spec/union_spec.rb so that CI succeeds

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 0.13.0
    • Ruby - Library
    • None

    Description

      I found that recent CI jobs failed with the following error:

      Failures:
      
        1) Union Thrift::Union should raise for wrong set field when hash initialized and type checking is off
      
           Failure/Error: expect(example).to raise_error(RuntimeError, "set_field is not valid for this union!")
      
             You must pass a block rather than an argument to `expect` to use the provided block expectation matcher (raise RuntimeError with "set_field is not valid for this union!").
      
           # ./spec/union_spec.rb:55:in `block (3 levels) in <top (required)>'
      

      rspec-expectations 3.8.5 was released three or four days ago, and it probably caused this error. In accordance with the message, the test case in question should be fixed as follows,

           it "should raise for wrong set field when hash initialized and type checking is off" do
             Thrift.type_checking = false
             union = SpecNamespace::My_union.new({incorrect_field: :incorrect})
      -      example = lambda { Thrift::Serializer.new.serialize(union) }
      -      expect(example).to raise_error(RuntimeError, "set_field is not valid for this union!")
      +      expect { Thrift::Serializer.new.serialize(union) }.to raise_error(RuntimeError, "set_field is not valid for this union!")
           end
      

      just as the previous test case does as follows:

          it "should raise for wrong set field" do
            union = SpecNamespace::My_union.new
            union.integer32 = 25
            expect { union.some_characters }.to raise_error(RuntimeError, "some_characters is not union's set field.")
          end
      

      Attachments

        Issue Links

          Activity

            People

              sekikn Kengo Seki
              sekikn Kengo Seki
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m