Skip to content

Commit b7d5f51

Browse files
author
Nathan Sutton
committed
Adding documentation for Fog.unmock! and Fog::Mock.reset
1 parent eb86ba7 commit b7d5f51

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

docs/about/getting_started.markdown

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ After that you should be able to check your directory list in fog or your filesy
6565

6666
## Next Steps
6767

68-
Using the same interface you can also practice working against a real provider (such as Amazon S3). Rather than worrying about signing up for an account right away though, we can use mocks to simulate S3 while we practice.
68+
Using the same interface you can also practice working against a real provider (such as Amazon S3). Rather than worrying about signing up for an account right away though, we can use mocks to simulate S3 while we practice.
6969

7070
This time we will turn on mocking and then, just like before, we will need to make a connection.
7171

@@ -76,8 +76,33 @@ This time we will turn on mocking and then, just like before, we will need to ma
7676
:provider => 'AWS'
7777
})
7878

79-
You may notice that we used bogus credentials, this is fine since we are just simulating things. To use real S3 you can simply omit `Fog.mock!` and swap in your real credentials.
79+
You may notice that we used bogus credentials, this is fine since we are just simulating things. To use real S3 you can simply omit Fog.mock! and swap in your real credentials.
8080

81-
Once you have your connection you can go through all the steps you did before, only now you will be working against a real cloud service (or at least a simulated one).
81+
If you'd like to turn off mocking after turning it on, you can do it at any time and every subsequent connection will be a real connection.
82+
83+
# Turn on mocking
84+
Fog.mock!
85+
86+
# Create a mock connection to S3
87+
storage = Fog::Storage.new({
88+
:aws_access_key_id => "asdf",
89+
:aws_secret_access_key => "asdf",
90+
:provider => "AWS"
91+
})
92+
93+
# Turn off mocking
94+
Fog.unmock!
95+
96+
# Create a real connection to S3
97+
storage = Fog::Storage.new({
98+
:aws_access_key_id => "asdf",
99+
:aws_secret_access_key => "asdf",
100+
:provider => "AWS"
101+
})
102+
103+
Don't worry about your losing mock data, it stays around until you reset it or until your process exits.
104+
105+
# Reset all mock data
106+
Fog::Mock.reset
82107

83108
Congratulations and welcome to the cloud! Continue your journey at [fog.io](http://fog.io)

0 commit comments

Comments
 (0)