It seems like it'd be useful to have a method that returns the token if the
file exists, or false if it does not. Then you could use this method in
your bin file to prompt the user to log in if there's no saved token and
they try to use a method that requires one, and you could stub out this
method in your tests with some fake token that matches what's in your VCR
cassette.

Joey


On Sun, Sep 1, 2013 at 9:52 PM, Zach <notifications@github.com> wrote:

> In spec/gist_nuke_spec.rb:
>
> > +
> > +describe GistNuke do
> > +  describe ".get_github_token" do
> > +    it "should return a valid GitHub auth token" do
> > +      VCR.use_cassette('github') do
> > +        credentials = {username: "test", password: "test"}
> > +
> > +        token = GistNuke.get_github_token(credentials)
> > +        token.should == "fe71e9391a26d6280ac377081d7ba3bfe2364993"
> > +      end
> > +    end
> > +  end
> > +
> > +  describe ".load_gists" do
> > +    let(:token) {"fe71e9391a26d6280ac377081d7ba3bfe2364993"}
> > +    it "should return the GitHub gist JSON with expected keys" do
>
> Hey Joey! Yeah I have Travis set up and when I removed the .gist_nuke file
> which should have the token I blew up the tests. I am actually happy you
> wrote me. I was trying to figure out how to mock this file so I have a.
> gist_nuke file with the token in it but without it being in source control!
> Any ideas? You are an awesome mentor for emailing me so late on a Sunday!
> … <#140dc964a73ab865_>
> On Sep 1, 2013, at 9:36 PM, Joey Schoblaska <notifications@github.com>
> wrote: In spec/gist_nuke_spec.rb: > + > +describe GistNuke do > + describe
> ".get_github_token" do > + it "should return a valid GitHub auth token" do
> > + VCR.use_cassette('github') do > + credentials = {username: "test",
> password: "test"} > + > + token = GistNuke.get_github_token(credentials) >
> + token.should == "fe71e9391a26d6280ac377081d7ba3bfe2364993" > + end > +
> end > + end > + > + describe ".load_gists" do > + let(:token)
> {"fe71e9391a26d6280ac377081d7ba3bfe2364993"} > + it "should return the
> GitHub gist JSON with expected keys" do Open a terminal, cd to a blank
> folder, and run these commands. There's a big problem with these tests, and
> doing this will show you what it is. git clone
> https://github.com/zachgersh/gist_nuke cd gist_nuke git branch --track
> working origin/working git checkout working bundle bundle exec rspec
> spec/gist_nuke_spec.rb:20 — Reply to this email directly or view it on
> GitHub.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/zachgersh/gist_nuke/pull/1/files#r6104490>
> .
>