Skip to content

Add zip code lookup with specs and VCR cassettes#45

Open
Gilmoursa wants to merge 1 commit into
coderhs:masterfrom
Gilmoursa:fix/zip-specs
Open

Add zip code lookup with specs and VCR cassettes#45
Gilmoursa wants to merge 1 commit into
coderhs:masterfrom
Gilmoursa:fix/zip-specs

Conversation

@Gilmoursa
Copy link
Copy Markdown

This supersedes #28 with the missing test coverage added.

Changes

lib/open_weather/api.rb — adds .zip to ClassMethods, making it available on Current, Forecast, ForecastDaily, and History:

# Zip code format: '33704,US'
# Usage: OpenWeather::Current.zip('33704,US')
def zip(zip_code, options = {})
  new(options.merge(zip: zip_code)).retrieve
end

lib/open_weather/base.rb — adds :zip to valid_options so the parameter isn't stripped before the API request is sent.

spec/open_weather/api_spec.rb — adds a .zip context with two cases matching the style of every other method in the suite:

  • valid zip (33704,US) → expects cod: 200
  • invalid zip (00000,US) → expects cod: '404'

spec/fixtures/cassettes/api/ — adds current_zip_valid.yml and current_zip_invalid.yml VCR cassettes in the existing format.

README.md — moves the zip example into the Current API section (where the other single-location lookups live) and fixes a pre-existing "Doucumentation" typo.

Test plan

  • bundle exec rspec spec/open_weather/api_spec.rb — all existing tests pass, two new .zip tests pass

🤖 Generated with Claude Code

- Add .zip class method to ClassMethods module (available on Current,
  Forecast, ForecastDaily, and History)
- Add :zip to valid_options allowlist in Base so it isn't stripped
  before the API request is sent
- Add spec context for .zip with valid (33704,US) and invalid (00000,US)
  cases, backed by VCR cassettes matching the existing cassette format
- Move README example to the Current API section; fix "Doucumentation"
  typo

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant