10000 [rspec] Avoid matching on EXACT returns, use hash_including and other matchers · Issue #688 · github-changelog-generator/github-changelog-generator · GitHub
[go: up one dir, main page]

Skip to content
[rspec] Avoid matching on EXACT returns, use hash_including and other matchers #688
Open
@olleolleolle

Description

@olleolleolle

This issue is about avoiding brittle tests, by using RSpec Matchers which only check for the data the tested behavior needs.

One example failure: https://circleci.com/gh/szemek/github-changelog-generator/54

Failures:

  1) GitHubChangelogGenerator::OctoFetcher#fetch_commit when API call is valid returns commit
     Failure/Error: expect(commit[property]).to eq(val)
     
       expected: {"avatar_url"=>"https://avatars2.githubusercontent.com/u/3356474?v=4", "events_url"=>"https://api.git...com/users/skywinder/subscriptions", "type"=>"User", "url"=>"https://api.github.com/users/skywinder"}
            got: {"avatar_url"=>"https://avatars2.githubusercontent.com/u/3356474?v=4", "events_url"=>"https://api.git...com/users/skywinder/subscriptions", "type"=>"User", "url"=>"https://api.github.com/users/skywinder"}
     
       (compared using ==)
     
       Diff:
       @@ -7,6 +7,7 @@
        "html_url" => "https://github.com/skywinder",
        "id" => 3356474,
        "login" => "skywinder",
       +"node_id" => "MDQ6VXNlcjMzNTY0NzQ=",
        "organizations_url" => "https://api.github.com/users/skywinder/orgs",
        "received_events_url" => "https://api.github.com/users/skywinder/received_events",
        "repos_url" => "https://api.github.com/users/skywinder/repos",
       
     # ./spec/unit/octo_fetcher_spec.rb:524:in `block (5 levels) in <top (required)>'

Metadata

Metadata

Assignees

No one assigned

    Labels

    hacktoberfestEnjoy flashmob: https://hacktoberfest.digitalocean.com. Get a swag!help wanted

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0