dblock / strava-ruby-client

A complete Ruby client for the Strava API v3.
https://code.dblock.org/2018/11/27/writing-a-new-strava-api-ruby-client.html
MIT License
97 stars 22 forks source link

Update gear.rb #41

Closed deuber closed 3 years ago

deuber commented 3 years ago

Added missing "frame_type". See https://developers.strava.com/docs/reference/#api-Gears Strava-Developers response

dblock commented 3 years ago

Was this added recently? I don't see it in https://github.com/dblock/strava-ruby-client/blob/master/spec/fixtures/strava/client/gear.yml. Re-record that VCR and add a test for this new (and other fields), please?

deuber commented 3 years ago

Sorry, not sure how to Re-record the VCR and add a test for "frame_type" field. I see no other missing. Let me know steps and will do.

dblock commented 3 years ago

The spec, https://github.com/dblock/strava-ruby-client/blob/master/spec/strava/api/client/endpoints/gears/gear_spec.rb, uses vcr, with , vcr: { cassette_name: 'client/gear' }. If the K7 doesn't exist, it makes an actual HTTP call. Otherwise it replays the K7.

  1. You need a working STRAVA_ACCESS_TOKEN.
  2. Delete https://github.com/dblock/strava-ruby-client/tree/master/spec/fixtures/strava/....yml that is used by the test, in this case gear.yml.
  3. Re-run the spec with STRAVA_ACCESS_TOKEN=token rspec spec/strava/api/client/endpoints/gears/gear_spec.rb
  4. Examine the newly created gear.yml, double check that it doesn't have your token in there (it gets removed here).
  5. Update the spec to do the right thing, in this case add code that checks the value of frame_type.
  6. Make a PR.

Could you please also add a section to CONTRIBUTING.md with a cleaned up version of the above? Appreciate it.

deuber commented 3 years ago

About steps... I deleted https://github.com/dblock/strava-ruby-client/blob/master/spec/fixtures/strava/client/gear.yml and updated gear_spec.rb .

But, sorry stuck on step 3. I downloaded gear_spec.rb than ran:

bundle exec rspec spec/gear_spec.rb

An error occurred while loading ./spec/gear_spec.rb. Failure/Error: include_context 'API client'

ArgumentError: Could not find shared context "API client"

./spec/gear_spec.rb:4:in `block in <top (required)>'

./spec/gear_spec.rb:3:in `<top (required)>'

No examples found.

Where do i set my token? Once working this creates a new .yml file?

Thanks

deuber commented 3 years ago

hang on, think i see what's needed.

deuber commented 3 years ago

I downloaded a zip of https://github.com/deuber/strava-ruby-client, unpacked it. Ran bundle install, then ran from within strava-ruby-client-master below, but still auth issues.

STRAVA_ACCESS_TOKEN=<my access token here> rspec spec/strava/api/client/endpoints/gears/gear_spec.rb

Strava-API token

Sorry, what am I missing? Thanks

dblock commented 3 years ago

You should be cloning the repo with git and doing all this command-line. Restart by following https://github.com/dblock/strava-ruby-client/blob/master/CONTRIBUTING.md? You make a fork, check out the code, do bundle install, then rake to see all tests pass. Then you can make changes that I described above. LMK if you need more help and thanks for hanging in here!

deuber commented 3 years ago

Thanks for your patience, sorry been a while since done this.

Created clone as directed: https://github.com/dblock/strava-ruby-client/blob/master/CONTRIBUTING.md

git clone https://github.com/contributor/strava-ruby-client.git
cd strava-ruby-client
git remote add upstream https://github.com/dblock/strava-ruby-client.git

I ran bundle install without issues, but when I run >bundle exec rake Running RuboCop... RuboCop failed!

Guess I need different vers of RuboCop?

So deleted gemfile.lock and made change to gemfile (below).

gem 'rubocop', '~> 0.61.1'

gem 'rubocop'

Ran bundle install again without errors But see this now. >bundle exec rake Running RuboCop... Inspecting 134 files 134 files inspected, 159 offenses detected, 156 offenses auto-correctable

Tip: Based on detected gems, the following RuboCop extension libraries might be helpful:

You can opt out of this message by adding the following to your config (see https://docs.rubocop.org/rubocop/extensions.html#extension-suggestions for more options): AllCops: SuggestExtensions: false RuboCop failed!

I recently broke my wrist mountain biking, sorry please forgive typos and spellos. Such a pain typing with one hand, thanks!

dblock commented 3 years ago

Undo any code changes, run bundle insall, then bundle exec rake, what's the actual error from rubocop? It shouldn't fail and you don't need to change anything.

If you were to change the version of rubocop, then you'd expect it to complain about some new things. But the version locked via Gemfile.lock should pass clean as our build succeeds here.

deuber commented 3 years ago

Did exactly that, but limited output why failed. Dies almost silently.

Details below. I've included my rails, ruby versions below.

strava-ruby-client>bundle install Fetching gem metadata from http://rubygems.org/......... Resolving dependencies.... Using rake 13.0.6 Using concurrent-ruby 1.1.9 Using minitest 5.14.4 Using bundler 2.2.26 Using public_suffix 4.0.6 Using colored2 3.1.2 Using zeitwerk 2.4.2 Using open4 1.3.4 Using coderay 1.1.3 Using rexml 3.2.5 Using claide 1.0.3 Using faraday-em_synchrony 1.0.0 Using faraday-excon 1.1.0 Using faraday-httpclient 1.0.1 Using ast 2.4.2 Using faraday-net_http_persistent 1.2.0 Using faraday-patron 1.0.0 Using faraday-rack 1.0.0 Using nap 1.1.0 Using ruby2_keywords 0.0.5 Using rchardet 1.8.0 Using no_proxy_fix 0.1.2 Using faraday-em_http 1.0.0 Using diff-lcs 1.4.4 Using dotenv 2.7.6 Using racc 1.5.2 Using faraday-net_http 1.0.1 Using hashie 4.1.0 Using unicode-display_width 1.4.1 Using method_source 1.0.0 Using multi_xml 0.6.0 Using parallel 1.20.1 Using hashdiff 1.0.1 Using powerpack 0.1.3 Using rainbow 3.0.0 Using rspec-support 3.10.2 Using multipart-post 2.1.1 Using vcr 6.0.0 Using i18n 1.8.10 Using tzinfo 2.0.4 Using jaro_winkler 1.5.4 Using cork 0.3.0 Using crack 0.4.5 Using kramdown 2.3.1 Using polylines 0.4.0 Using git 1.9.1 Using nokogiri 1.12.4 (x86_64-darwin) Using terminal-table 3.0.1 Using ruby-progressbar 1.11.0 Using faraday 1.7.1 Using rspec-core 3.10.1 Using rspec-expectations 3.10.1 Using rspec-mocks 3.10.2 Using activesupport 6.1.4.1 Using pry 0.14.1 Using kramdown-parser-gfm 1.1.0 Using gpx 1.0.0 Using faraday-http-cache 2.2.0 Using addressable 2.8.0 Using rspec 3.10.0 Using sawyer 0.8.2 Using webmock 3.14.0 Using octokit 4.21.0 Using claide-plugins 0.9.2 Using faraday_middleware 1.1.0 Using parser 3.0.2.0 Using danger 8.3.1 Using rubocop 0.61.1 Using danger-plugin-api 1.0.0 Using strava-ruby-client 0.4.2 from source at . and installing its executables Using danger-toc 0.1.3 Using danger-changelog 0.4.2 Bundle complete! 13 Gemfile dependencies, 72 gems now installed. Use bundle info [gemname] to see where a bundled gem is installed. Davids-MacBook-Pro-2:~/strava-ruby-client>bundle exec rake Running RuboCop... RuboCop failed! Davids-MacBook-Pro-2:~/strava-ruby-client>rails -v Rails 6.1.4.1 Davids-MacBook-Pro-2:~/strava-ruby-client>ruby -v ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-darwin17] Davids-MacBook-Pro-2:~/strava-ruby-client>

Note: ignore strike through, it's artifact from cut and paste of commands and output.

deuber commented 3 years ago

I see your https://github.com/dblock/strava-ruby-client/blob/master/.gitignore shows Gemfile.lock included, so mine is created at install.

dblock commented 3 years ago

Oooh you’re right. We need to check that in and lock rubocop. Run rubocop -a and let’s see if that fixes it.

deuber commented 3 years ago

Hi,

I ran

rubocop -a I see many "Correctable" literal string messages like this:

spec/strava/api/client/endpoints/routes/export_route_gpx_spec.rb:1:1: C: [Correctable] Style/FrozenStringLiteralComment: Missing frozen string literal comment.
Followed by
134 files inspected, 151 offenses detected, 148 more offenses can be corrected with `rubocop -A`

followed by

spec/support/shared/it_behaves_like_web_client.rb:101:33: C: [Correctable] Style/GlobalStdStream: Use $stdout instead of STDOUT.
      let(:logger) { Logger.new(STDOUT) }
                                ^^^^^^
spec/support/vcr.rb:1:1: C: [Correctable] Style/FrozenStringLiteralComment: Missing frozen string literal comment.
require 'vcr'
^
strava-ruby-client.gemspec:1:1: C: Gemspec/RequiredRubyVersion: required_ruby_version should be specified.
$LOAD_PATH.push File.expand_path('lib', __dir__)
^
strava-ruby-client.gemspec:1:1: C: [Correctable] Style/FrozenStringLiteralComment: Missing frozen string literal comment.
$LOAD_PATH.push File.expand_path('lib', __dir__)
^

Running 'bundle exec rake' yields same results.

Can you fork and try this? As i have made no changes, I assume you'll get same results?

deuber commented 3 years ago

or, i should run rubocop -A ?

dblock commented 3 years ago

So rubocop auto-corrects with -a, and for everything else you can just update the config with rubocop --auto-gen-config. Then rubocop should finish clean.

Btw, if you don't want to deal with this, last time the build passed used rubocop 0.61.1, so you could just lock the version at that in Gemfile and move on. Either way, please PR a Gemfile.lock so we don't run into this issue again.

deuber commented 3 years ago

Tried 'rubocop --auto-gen-config' too, but same results with minimal message.

bundle exec rake Running RuboCop... RuboCop failed!

I am using rubocop 0.61.1, see my full gemlock file below. Maybe you diff yours with below?

Thanks, David

PATH
  remote: .
  specs:
    strava-ruby-client (0.4.2)
      activesupport
      faraday (>= 1.0.0)
      faraday_middleware
      hashie

GEM
  remote: http://rubygems.org/
  specs:
    activesupport (6.1.4.1)
      concurrent-ruby (~> 1.0, >= 1.0.2)
      i18n (>= 1.6, < 2)
      minitest (>= 5.1)
      tzinfo (~> 2.0)
      zeitwerk (~> 2.3)
    addressable (2.8.0)
      public_suffix (>= 2.0.2, < 5.0)
    ast (2.4.2)
    claide (1.0.3)
    claide-plugins (0.9.2)
      cork
      nap
      open4 (~> 1.3)
    coderay (1.1.3)
    colored2 (3.1.2)
    concurrent-ruby (1.1.9)
    cork (0.3.0)
      colored2 (~> 3.1)
    crack (0.4.5)
      rexml
    danger (8.3.1)
      claide (~> 1.0)
      claide-plugins (>= 0.9.2)
      colored2 (~> 3.1)
      cork (~> 0.1)
      faraday (>= 0.9.0, < 2.0)
      faraday-http-cache (~> 2.0)
      git (~> 1.7)
      kramdown (~> 2.3)
      kramdown-parser-gfm (~> 1.0)
      no_proxy_fix
      octokit (~> 4.7)
      terminal-table (>= 1, < 4)
    danger-changelog (0.4.2)
      danger-plugin-api (~> 1.0)
    danger-plugin-api (1.0.0)
      danger (> 2.0)
    danger-toc (0.1.3)
      activesupport
      danger-plugin-api (~> 1.0)
      kramdown
    diff-lcs (1.4.4)
    dotenv (2.7.6)
    faraday (1.7.1)
      faraday-em_http (~> 1.0)
      faraday-em_synchrony (~> 1.0)
      faraday-excon (~> 1.1)
      faraday-httpclient (~> 1.0.1)
      faraday-net_http (~> 1.0)
      faraday-net_http_persistent (~> 1.1)
      faraday-patron (~> 1.0)
      faraday-rack (~> 1.0)
      multipart-post (>= 1.2, < 3)
      ruby2_keywords (>= 0.0.4)
    faraday-em_http (1.0.0)
    faraday-em_synchrony (1.0.0)
    faraday-excon (1.1.0)
    faraday-http-cache (2.2.0)
      faraday (>= 0.8)
    faraday-httpclient (1.0.1)
    faraday-net_http (1.0.1)
    faraday-net_http_persistent (1.2.0)
    faraday-patron (1.0.0)
    faraday-rack (1.0.0)
    faraday_middleware (1.1.0)
      faraday (~> 1.0)
    git (1.9.1)
      rchardet (~> 1.8)
    gpx (1.0.0)
      nokogiri (~> 1.7)
      rake
    hashdiff (1.0.1)
    hashie (4.1.0)
    i18n (1.8.10)
      concurrent-ruby (~> 1.0)
    jaro_winkler (1.5.4)
    kramdown (2.3.1)
      rexml
    kramdown-parser-gfm (1.1.0)
      kramdown (~> 2.0)
    method_source (1.0.0)
    minitest (5.14.4)
    multi_xml (0.6.0)
    multipart-post (2.1.1)
    nap (1.1.0)
    no_proxy_fix (0.1.2)
    nokogiri (1.12.4-x86_64-darwin)
      racc (~> 1.4)
    octokit (4.21.0)
      faraday (>= 0.9)
      sawyer (~> 0.8.0, >= 0.5.3)
    open4 (1.3.4)
    parallel (1.20.1)
    parser (3.0.2.0)
      ast (~> 2.4.1)
    polylines (0.4.0)
    powerpack (0.1.3)
    pry (0.14.1)
      coderay (~> 1.1)
      method_source (~> 1.0)
    public_suffix (4.0.6)
    racc (1.5.2)
    rainbow (3.0.0)
    rake (13.0.6)
    rchardet (1.8.0)
    rexml (3.2.5)
    rspec (3.10.0)
      rspec-core (~> 3.10.0)
      rspec-expectations (~> 3.10.0)
      rspec-mocks (~> 3.10.0)
    rspec-core (3.10.1)
      rspec-support (~> 3.10.0)
    rspec-expectations (3.10.1)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.10.0)
    rspec-mocks (3.10.2)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.10.0)
    rspec-support (3.10.2)
    rubocop (0.61.1)
      jaro_winkler (~> 1.5.1)
      parallel (~> 1.10)
      parser (>= 2.5, != 2.5.1.1)
      powerpack (~> 0.1)
      rainbow (>= 2.2.2, < 4.0)
      ruby-progressbar (~> 1.7)
      unicode-display_width (~> 1.4.0)
    ruby-progressbar (1.11.0)
    ruby2_keywords (0.0.5)
    sawyer (0.8.2)
      addressable (>= 2.3.5)
      faraday (> 0.8, < 2.0)
    terminal-table (3.0.1)
      unicode-display_width (>= 1.1.1, < 3)
    tzinfo (2.0.4)
      concurrent-ruby (~> 1.0)
    unicode-display_width (1.4.1)
    vcr (6.0.0)
    webmock (3.14.0)
      addressable (>= 2.8.0)
      crack (>= 0.3.2)
      hashdiff (>= 0.4.0, < 2.0.0)
    zeitwerk (2.4.2)

PLATFORMS
  x86_64-darwin-17

DEPENDENCIES
  danger-changelog (~> 0.4.2)
  danger-toc (~> 0.1.3)
  dotenv
  gpx
  multi_xml
  polylines
  pry
  rake
  rspec
  rubocop (~> 0.61.1)
  strava-ruby-client!
  vcr
  webmock

BUNDLED WITH
   2.2.26
deuber commented 3 years ago

My bundle install shows 'Using rubocop 0.61.1' too.

deuber commented 3 years ago

Sure wish we had more to see then this when it fails.

bundle exec rake Running RuboCop... RuboCop failed!

deuber commented 3 years ago

i see where once working from your link ruby/2.5.0 will try that version as i was using

ruby -v
ruby 2.7.4p19
deuber commented 3 years ago

still failing with ruby 2.5.0 but more message.

rbenv install 2.5.0 rbenv local 2.5.0

ruby -v ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]

gem install bundler bundle install

bundle exec rake Running RuboCop... Inspecting 134 files ...........................................................................CCC........................................................

Offenses:

lib/strava/models/mixins/elevation.rb:22:19: C: Style/FormatStringToken: Prefer annotated tokens (like %s) over unannotated tokens (like %s). format('%gm', format('%.1f', total_elevation_gain_in_meters)) ^^ lib/strava/models/mixins/elevation.rb:28:19: C: Style/FormatStringToken: Prefer annotated tokens (like %s) over unannotated tokens (like %s). format('%gft', format('%.1f', total_elevation_gain_in_feet)) ^^ lib/strava/models/mixins/distance.rb:26:19: C: Style/FormatStringToken: Prefer annotated tokens (like %s) over unannotated tokens (like %s). format('%gmi', format('%.2f', distance_in_miles)) ^^ lib/strava/models/mixins/distance.rb:36:19: C: Style/FormatStringToken: Prefer annotated tokens (like %s) over unannotated tokens (like %s). format('%gyd', format('%.1f', distance_in_yards)) ^^ lib/strava/models/mixins/distance.rb:42:19: C: Style/FormatStringToken: Prefer annotated tokens (like %s) over unannotated tokens (like %s). format('%gm', format('%d', distance_in_meters)) ^^ lib/strava/models/mixins/distance.rb:42:33: C: Style/FormatStringToken: Prefer annotated tokens (like %s) over unannotated tokens (like %s). format('%gm', format('%d', distance_in_meters)) ^^ lib/strava/models/mixins/distance.rb:52:19: C: Style/FormatStringToken: Prefer annotated tokens (like %s) over unannotated tokens (like %s). format('%gkm', format('%.2f', distance_in_kilometers)) ^^ lib/strava/models/mixins/time.rb:67:44: C: Style/FormatStringToken: Prefer annotated tokens (like %s) over unannotated tokens (like %s). hours.to_i.positive? ? format('%dh', hours) : nil, ^^ lib/strava/models/mixins/time.rb:68:46: C: Style/FormatStringToken: Prefer annotated tokens (like %s) over unannotated tokens (like %s). minutes.to_i.positive? ? format('%dm', minutes) : nil, ^^ lib/strava/models/mixins/time.rb:69:46: C: Style/FormatStringToken: Prefer annotated tokens (like %s) over unannotated tokens (like %s). seconds.to_i.positive? ? format('%ds', seconds) : nil ^^

134 files inspected, 10 offenses detected RuboCop failed!

deuber commented 3 years ago

i would expect it not fail as it did before? but maybe due to new code added since?

deuber commented 3 years ago

Ran

STRAVA_ACCESS_TOKEN=myAccessTokenHere rspec spec/strava/api/client/endpoints/gears/gear_spec.rb

It created gear.yml but still auth issues.


http_interactions:

dblock commented 3 years ago

Looks like you made progress with rubocop. The version 0.61.1 is right. The error is probably from new code (rubocop -a should fix it).

For the token, first make sure it's actually valid. Does this work?

curl -H 'Accept: application/json' -H "Authorization: Bearer put-your-token-here" https://www.strava.com/api/v3/gear/g3423618 

Then make sure to get rid of the existing gear.yml, or it will just replay/reuse that one, before running rspec.

deuber commented 3 years ago

no success with rubocop -a

bundle exec rake Running RuboCop... Inspecting 134 files ...........................................................................CCC........................................................

Offenses:

lib/strava/models/mixins/elevation.rb:22:19: C: Style/FormatStringToken: Prefer annotated tokens (like %s) over unannotated tokens (like %s). format('%gm', format('%.1f', total_elevation_gain_in_meters)) ^^ lib/strava/models/mixins/elevation.rb:28:19: C: Style/FormatStringToken: Prefer annotated tokens (like %s) over unannotated tokens (like %s). format('%gft', format('%.1f', total_elevation_gain_in_feet)) ^^ lib/strava/models/mixins/distance.rb:26:19: C: Style/FormatStringToken: Prefer annotated tokens (like %s) over unannotated tokens (like %s). format('%gmi', format('%.2f', distance_in_miles)) ^^ lib/strava/models/mixins/distance.rb:36:19: C: Style/FormatStringToken: Prefer annotated tokens (like %s) over unannotated tokens (like %s). format('%gyd', format('%.1f', distance_in_yards)) ^^ lib/strava/models/mixins/distance.rb:42:19: C: Style/FormatStringToken: Prefer annotated tokens (like %s) over unannotated tokens (like %s). format('%gm', format('%d', distance_in_meters)) ^^ lib/strava/models/mixins/distance.rb:42:33: C: Style/FormatStringToken: Prefer annotated tokens (like %s) over unannotated tokens (like %s). format('%gm', format('%d', distance_in_meters)) ^^ lib/strava/models/mixins/distance.rb:52:19: C: Style/FormatStringToken: Prefer annotated tokens (like %s) over unannotated tokens (like %s). format('%gkm', format('%.2f', distance_in_kilometers)) ^^ lib/strava/models/mixins/time.rb:67:44: C: Style/FormatStringToken: Prefer annotated tokens (like %s) over unannotated tokens (like %s). hours.to_i.positive? ? format('%dh', hours) : nil, ^^ lib/strava/models/mixins/time.rb:68:46: C: Style/FormatStringToken: Prefer annotated tokens (like %s) over unannotated tokens (like %s). minutes.to_i.positive? ? format('%dm', minutes) : nil, ^^ lib/strava/models/mixins/time.rb:69:46: C: Style/FormatStringToken: Prefer annotated tokens (like %s) over unannotated tokens (like %s). seconds.to_i.positive? ? format('%ds', seconds) : nil ^^

134 files inspected, 10 offenses detected RuboCop failed!

See https://stackoverflow.com/questions/50631272/rubocop-throwing-issue-on-date-strftime Accordingly, I should update it. Removed rubocop (~> 0.61.1) from gem file and deleted gemlock file and run bundle install again. With rubocop (1.20.0) bundle exec rake runs, but fails auth issue.

I will investigate why my token not working later, i still see Authorization Error. Thanks for simple curl test.

Question: Ok if i use rubocop 1.20.0?

Failures:

1) Strava::Api::Client#gear returns gear Failure/Error: raise Strava::Errors::Fault, response_values(env)

 Strava::Errors::Fault:
   Authorization Error
dblock commented 3 years ago

Ignore rubocop for now, you can run tests with rspec spec. If that passes, you're good.

Does your token work with curl?

deuber commented 3 years ago

Will get to that next week, thanks

On Fri, Sep 3, 2021 at 7:23 PM Daniel Doubrovkine (dB.) < @.***> wrote:

Ignore rubocop for now, you can run tests with rspec spec. If that passes, you're good.

Does your token work with curl?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dblock/strava-ruby-client/pull/41#issuecomment-912892280, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACYZZLY5FWFAPNP4CN7F5DDUAF7KZANCNFSM5CXNQVYA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

deuber commented 3 years ago

You wrote: "For the token, first make sure it's actually valid. Does this work? curl -H 'Accept: application/json' -H "Authorization: Bearer put-your-token-here" https://www.strava.com/api/v3/gear/g3423618 "

I see this would only work if i know the token for the Strava API demo user with gear with ID g3423618 curl -H 'Accept: application/json' -H "Authorization: Bearer put-your-token-here" https://www.strava.com/api/v3/gear/g3423618

Both these curl commands below work as expected, as i know my own token and gearID.

curl -H 'Accept: application/json' -H "Authorization: Bearer put-your-token-here" https://www.strava.com/api/v3/athlete

AND here a token plus a valid gear ID. curl -H 'Accept: application/json' -H "Authorization: Bearer put-your-token-here" https://www.strava.com/api/v3/gear/b2043043

Seems g3423618 is hard coded in rspec tests? How then do i get this Strava API demo users token? I don't see it shared here. https://developers.strava.com/docs/reference/

Note once working gear.yml shows:

http_interactions:
- request:
    method: get
    uri: https://www.strava.com/api/v3/gear/g3423618

How did that work ?

Ok, getting closer. What am i missing? Thanks!

deuber commented 3 years ago

Side note, no issues with Ruby 2.7.4 and rubocop (1.20.0)

New Gemfile:

source 'http://rubygems.org'

gemspec

group :development, :test do gem 'danger-changelog', '~> 0.4.2' gem 'danger-toc', '~> 0.1.3' gem 'dotenv' gem 'gpx' gem 'multi_xml' gem 'polylines' gem 'pry' gem 'rake' gem 'rspec' gem 'rubocop' gem 'vcr' gem 'webmock' end

(ignore strike throughs above)

Remove Gemfile.lock

bundle install rubocop (1.20.0) now seen in new Gemfile.lock

Cloned Gemfile had: gem 'rubocop', '~> 0.61.1'

This likely was my earlier issue with rubocop.

dblock commented 3 years ago

Both these curl commands below work as expected, as i know my own token and gearID.

Ok, great.

Seems g3423618 is hard coded in rspec tests? How then do i get this Strava API demo users token?

Short version: don't need to, change the gear ID requested in code first.

Long version: A VCR request is just a recording for a request/response. The first time you make an actual call, it records a K7 with the request/response. The next time(s) it uses the K7 as long as the request matches (or it tries to make an actual request). We do this so that subsequent runs (tests, my machine, someone else's machine) don't make actual API requests - we'd have to share secret tokens which would be bad (TM).

So, since you're re-recording a VCR request and you only have access to your ID, you should also change the gear ID being requested in code, in https://github.com/dblock/strava-ruby-client/blob/master/spec/strava/api/client/endpoints/gears/gear_spec.rb#L19 (and elsewhere it appears), otherwise it will try to request whichever old ID that was in code, and produce access denied since you don't have access to it. This was a gear ID for some shoes I own :)

deuber commented 3 years ago

i see now, i need to change most all fields within gear_spec.rb to get it to pass and match my bike, but working (no auth message). will do tmrw , thanks.

deuber commented 3 years ago

Success!

new gear.yml shows:

response: status: code: 200 message: OK

  encoding: UTF-8
  string: '{"id":"b2338517","primary":false,"name":"Trek","nickname":"Trek","resource_state":3,"retired":false,"distance":54349,"converted_distance":54.3,"brand_name":"Trek
    ","model_name":"Madrone","frame_type":3,"description":"white","weight":9.1}'

recorded_at: Wed, 08 Sep 2021 17:27:38 GMT

Followed Contributing.md But before i run "git push origin my-feature-branch" i want to see what I'm about to push. https://stackoverflow.com/questions/3636914/how-can-i-see-what-i-am-about-to-push-with-git

git diff --stat --cached origin/master Output shows many files, but I only want to commit gemfile, gear.rb, gear_spec.rb and gear.yml.

git status On branch my-feature-branch nothing to commit, working tree clean

git branch -a
master

  • my-feature-branch remotes/origin/HEAD -> origin/master remotes/origin/athlete_activities-by-id remotes/origin/master remotes/upstream/add-gemfile-lock remotes/upstream/athlete_activities-by-id remotes/upstream/master Davids-MacBook-Pro-2:~/strava-ruby-client>git checkout master Checking out files: 100% (9820/9820), done. Switched to branch 'master' Your branch is up to date with 'origin/master'.
dblock commented 3 years ago

git log -p will show you what you've committed

If you're not sure you can do this:

git checkout master
git pull upstream master # makes sure you are in sync with upstream (here)
git checkout -b add-gear-field # new branch 
git merge my-feature-branch --squash # merges changes but leaves them uncommitted

# revert anything you didn't intend to commit, git add and git commit what you want 
git push origin add-gear-field
deuber commented 3 years ago

Git log shows i made two commits and appears as expected (see below), good.

But I get this now

git push origin add-gear-field remote: Permission to dblock/strava-ruby-client.git denied to deuber. fatal: unable to access 'https://github.com/dblock/strava-ruby-client.git/': The requested URL returned error: 403

Don't I need to push to my https://github.com/deuber/strava-ruby-client ? Or, do you need to grant me permission?

Note latest commit shows head->master, prior is my-feature-branch. ok?

Thanks!

>git log -p

commit 11e008a309bdda218a527b6b411466252154e40f (HEAD -> master)
Author: David Deuber <xx@xxxx.com>
Date:   Thu Sep 9 08:53:55 2021 -0700

    added my contribution

diff --git a/CHANGELOG.md b/CHANGELOG.md
index dabab8a..bd429ed 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,8 @@

 * Your contribution here.

+* [#41](https://github.com/dblock/strava-ruby-client/pull/41): Added `Gear#frame_type` `Gear#retired` `Gear#weight`- [@deuber](https://github.com/deuber).
+
 ### 0.4.1 (2021/07/11)

 * [#37](https://github.com/dblock/strava-ruby-client/pull/38): Added `Club#club_events` - [@simonneutert](https://github.com/simonneutert).

commit 8d1e441502f152ee8e3f2b14ef5990fec2b67acd (my-feature-branch)
Author: David Deuber <xxxx@xxxxx.com>
Date:   Wed Sep 8 11:34:12 2021 -0700

    Added missing properties: frame_type, weight and retired to gear.rb, gear_spec.rb file
            modified:   Gemfile
            modified:   lib/strava/models/gear.rb
            modified:   spec/fixtures/strava/client/gear.yml
            modified:   spec/strava/api/client/endpoints/gears/gear_spec.rb
dblock commented 3 years ago

Yes you should push to your fork.

https://gist.github.com/Chaser324/ce0505fbed06b947d962 is a good read

One way out of this. First make sure you clicked the fork button on GitHub, then

git remote add upstream <this repo>
git remote rm origin
git remote add origin <your fork>
git push origin add-gear-field 
dangerpr-bot commented 3 years ago
1 Error
:no_entry_sign: The TOC found in README.md doesn't match the sections of the file.
1 Warning
:warning: Unless you're refactoring existing code or improving documentation, please update CHANGELOG.md.

Here's the expected TOC for README.md:

# Table of Contents

- [Installation](#installation)
- [Usage](#usage)
  - [Activities](#activities)
    - [Create an Activity](#create-an-activity)
    - [Get Activity](#get-activity)
    - [List Activity Photos](#list-activity-photos)
    - [List Activity Comments](#list-activity-comments)
    - [List Activity Kudoers](#list-activity-kudoers)
    - [List Activity Laps](#list-activity-laps)
    - [List Athlete Activities](#list-athlete-activities)
    - [Get Activity Zones](#get-activity-zones)
    - [Update Activity](#update-activity)
  - [Athletes](#athletes)
    - [Get Authenticated Athlete](#get-authenticated-athlete)
    - [Get Zones](#get-zones)
    - [Get Athlete Stats](#get-athlete-stats)
    - [Update Athlete](#update-athlete)
  - [Clubs](#clubs)
    - [List Club Activities](#list-club-activities)
    - [List Club Events](#list-club-events)
    - [List Club Administrators](#list-club-administrators)
    - [Get Club](#get-club)
    - [List Club Members](#list-club-members)
    - [List Athlete Clubs](#list-athlete-clubs)
  - [Gears](#gears)
    - [Get Equipment](#get-equipment)
  - [Routes](#routes)
    - [Export Route GPX](#export-route-gpx)
    - [Export Route TCX](#export-route-tcx)
    - [Get Route](#get-route)
    - [List Athlete Routes](#list-athlete-routes)
  - [Running Races](#running-races)
    - [Get Running Race](#get-running-race)
    - [List Running Races](#list-running-races)
  - [Segment Efforts](#segment-efforts)
    - [List Segment Efforts](#list-segment-efforts)
    - [Get Segment Effort](#get-segment-effort)
  - [Segments](#segments)
    - [Explore Segments](#explore-segments)
    - [Get Segment Leaderboard](#get-segment-leaderboard)
    - [List Starred Segments](#list-starred-segments)
    - [Get Segment](#get-segment)
    - [Star Segment](#star-segment)
  - [Streams](#streams)
    - [Get Activity Streams](#get-activity-streams)
    - [Get Segment Effort Streams](#get-segment-effort-streams)
    - [Get Segment Streams](#get-segment-streams)
  - [Uploads](#uploads)
    - [Upload Activity](#upload-activity)
    - [Get Upload](#get-upload)
  - [Pagination](#pagination)
  - [OAuth](#oauth)
    - [OAuth Workflow](#oauth-workflow)
    - [Deauthorize](#deauthorize)
    - [Command Line OAuth Workflow](#command-line-oauth-workflow)
  - [Webhooks](#webhooks)
- [Configuration](#configuration)
  - [Web Client Options](#web-client-options)
  - [API Client Options](#api-client-options)
  - [OAuth Client Options](#oauth-client-options)
  - [Webhooks Client Options](#webhooks-client-options)
- [Errors](#errors)
- [Tools](#tools)
  - [Strava OAuth Token](#strava-oauth-token)
- [Users](#users)
- [Resources](#resources)
- [Upgrading](#upgrading)
- [Contributing](#contributing)
- [Copyright and License](#copyright-and-license)

Here's an example of a CHANGELOG.md entry:

* [#41](https://github.com/dblock/strava-ruby-client/pull/41): Update gear.rb - [@deuber](https://github.com/deuber).

Generated by :no_entry_sign: Danger

deuber commented 3 years ago

Argh, seems I didn't follow directions earlier in CONTRIBUTING.md. git clone https://github.com/**contributor**/strava-ruby-client.git I cloned yours, should have been mine. I'll restart the process.

deuber commented 3 years ago

Maybe we close this as I just now created new PR, so work from there? https://github.com/dblock/strava-ruby-client/pull/45 Thanks!

dblock commented 3 years ago

Merged via https://github.com/dblock/strava-ruby-client/pull/45

@deuber Amazing to see how long you've hung in here to finish this change! Kudos.

deuber commented 3 years ago

And kudos to you, thanks for your patience!

On Wed, Sep 22, 2021 at 2:31 PM Daniel Doubrovkine (dB.) < @.***> wrote:

Merged via #45 https://github.com/dblock/strava-ruby-client/pull/45

@deuber https://github.com/deuber Amazing to see how long you've hung in here to finish this change! Kudos.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dblock/strava-ruby-client/pull/41#issuecomment-925345480, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACYZZL2FYPL4AMQMXO2HKU3UDJDJRANCNFSM5CXNQVYA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

dblock commented 3 years ago

If you want another challenge, https://github.com/dblock/strava-ruby-client/issues/42 should be next. We need to get rid of Travis-CI and replace with GitHub actions. You can do all this in your fork and when it's working, PR.