|
95 | 95 | }
|
96 | 96 |
|
97 | 97 | Describe 'Copy-GitHubGist' {
|
98 |
| - Context 'By files' { |
99 |
| - BeforeAll { |
| 98 | + BeforeAll { |
| 99 | + $originalGist = Get-GitHubGist -Gist '1169852' # octocat/test.cs |
| 100 | + } |
| 101 | + |
| 102 | + Context 'By parameters' { |
| 103 | + $gist = Copy-GitHubGist -Gist $originalGist.id |
| 104 | + It 'Should have been forked' { |
| 105 | + $gist.files.Count | Should -Be $originalGist.files.Count |
| 106 | + foreach ($file in $gist.files) |
| 107 | + { |
| 108 | + $originalFile = $originalGist.files | |
| 109 | + Where-Object { $_.filename -eq $file.filename } |
| 110 | + $file.filename | Should -Be $originalFile.filename |
| 111 | + $file.size | Should -Be $originalFile.size |
| 112 | + } |
100 | 113 | }
|
101 | 114 |
|
102 |
| - AfterAll { |
| 115 | + It 'Should have the expected additional type and properties' { |
| 116 | + $gist.PSObject.TypeNames[0] | Should -Be 'GitHub.Gist' |
| 117 | + $gist.GistId | Should -Be $gist.id |
| 118 | + $gist.owner.PSObject.TypeNames[0] | Should -Be 'GitHub.User' |
| 119 | + } |
| 120 | + |
| 121 | + It 'Should be removed' { |
| 122 | + { Remove-GitHubGist -Gist $gist.id -Force } | Should -Not -Throw |
103 | 123 | }
|
104 | 124 | }
|
105 |
| - } |
106 | 125 |
|
107 |
| - Describe 'Add/Remove/Test-GitHubGistStar' { |
108 |
| - Context 'By files' { |
109 |
| - BeforeAll { |
110 |
| - $gist = New-GitHubGist -Content 'Sample text' -Filename 'sample.txt' |
| 126 | + Context 'Gist on the pipeline' { |
| 127 | + $gist = $originalGist | Copy-GitHubGist |
| 128 | + It 'Should have been forked' { |
| 129 | + $gist.files.Count | Should -Be $originalGist.files.Count |
| 130 | + foreach ($file in $gist.files) |
| 131 | + { |
| 132 | + $originalFile = $originalGist.files | |
| 133 | + Where-Object { $_.filename -eq $file.filename } |
| 134 | + $file.filename | Should -Be $originalFile.filename |
| 135 | + $file.size | Should -Be $originalFile.size |
| 136 | + } |
111 | 137 | }
|
112 | 138 |
|
113 |
| - AfterAll { |
114 |
| - $gist | Remove-GitHubGist -Force |
| 139 | + It 'Should have the expected additional type and properties' { |
| 140 | + $gist.PSObject.TypeNames[0] | Should -Be 'GitHub.Gist' |
| 141 | + $gist.GistId | Should -Be $gist.id |
| 142 | + $gist.owner.PSObject.TypeNames[0] | Should -Be 'GitHub.User' |
115 | 143 | }
|
116 | 144 |
|
117 |
| - Context 'With parameters' { |
118 |
| - $starred = Test-GitHubGistStar -Gist $gist.id |
119 |
| - It 'Should not be starred yet' { |
120 |
| - $starred | Should -BeFalse |
121 |
| - } |
| 145 | + It 'Should be removed' { |
| 146 | + { $gist | Remove-GitHubGist -Force } | Should -Not -Throw |
| 147 | + } |
| 148 | + } |
| 149 | + } |
122 | 150 |
|
123 |
| - Add-GitHubGistStar -Gist $gist.id |
124 |
| - $starred = Test-GitHubGistStar -Gist $gist.id |
125 |
| - It 'Should now be starred yet' { |
126 |
| - $starred | Should -BeTrue |
127 |
| - } |
| 151 | + Describe 'Add/Remove/Test-GitHubGistStar' { |
| 152 | + BeforeAll { |
| 153 | + $gist = New-GitHubGist -Content 'Sample text' -Filename 'sample.txt' |
| 154 | + } |
128 | 155 |
|
129 |
| - $starred = Test-GitHubGistStar -Gist $gist.id |
130 |
| - It 'Should not be starred yet' { |
131 |
| - $starred | Should -BeTrue |
132 |
| - } |
| 156 | + AfterAll { |
| 157 | + $gist | Remove-GitHubGist -Force |
| 158 | + } |
133 | 159 |
|
134 |
| - Remove-GitHubGistStar -Gist $gist.id |
135 |
| - $starred = Test-GitHubGistStar -Gist $gist.id |
136 |
| - It 'Should no longer be starred yet' { |
137 |
| - $starred | Should -BeFalse |
138 |
| - } |
| 160 | + Context 'With parameters' { |
| 161 | + $starred = Test-GitHubGistStar -Gist $gist.id |
| 162 | + It 'Should not be starred yet' { |
| 163 | + $starred | Should -BeFalse |
139 | 164 | }
|
140 | 165 |
|
141 |
| - Context 'With the gist on the pipeline' { |
142 |
| - $starred = $gist | Test-GitHubGistStar |
143 |
| - It 'Should not be starred yet' { |
144 |
| - $starred | Should -BeFalse |
145 |
| - } |
| 166 | + Add-GitHubGistStar -Gist $gist.id |
| 167 | + $starred = Test-GitHubGistStar -Gist $gist.id |
| 168 | + It 'Should now be starred yet' { |
| 169 | + $starred | Should -BeTrue |
| 170 | + } |
146 | 171 |
|
147 |
| - $gist | Add-GitHubGistStar |
148 |
| - $starred = $gist | Test-GitHubGistStar |
149 |
| - It 'Should now be starred yet' { |
150 |
| - $starred | Should -BeTrue |
151 |
| - } |
| 172 | + $starred = Test-GitHubGistStar -Gist $gist.id |
| 173 | + It 'Should not be starred yet' { |
| 174 | + $starred | Should -BeTrue |
| 175 | + } |
152 | 176 |
|
153 |
| - $starred = $gist | Test-GitHubGistStar |
154 |
| - It 'Should not be starred yet' { |
155 |
| - $starred | Should -BeTrue |
156 |
| - } |
| 177 | + Remove-GitHubGistStar -Gist $gist.id |
| 178 | + $starred = Test-GitHubGistStar -Gist $gist.id |
| 179 | + It 'Should no longer be starred yet' { |
| 180 | + $starred | Should -BeFalse |
| 181 | + } |
| 182 | + } |
157 | 183 |
|
158 |
| - $gist | Remove-GitHubGistStar |
159 |
| - $starred = $gist | Test-GitHubGistStar |
160 |
| - It 'Should no longer be starred yet' { |
161 |
| - $starred | Should -BeFalse |
162 |
| - } |
| 184 | + Context 'With the gist on the pipeline' { |
| 185 | + $starred = $gist | Test-GitHubGistStar |
| 186 | + It 'Should not be starred yet' { |
| 187 | + $starred | Should -BeFalse |
| 188 | + } |
| 189 | + |
| 190 | + $gist | Add-GitHubGistStar |
| 191 | + $starred = $gist | Test-GitHubGistStar |
| 192 | + It 'Should now be starred yet' { |
| 193 | + $starred | Should -BeTrue |
| 194 | + } |
| 195 | + |
| 196 | + $starred = $gist | Test-GitHubGistStar |
| 197 | + It 'Should not be starred yet' { |
| 198 | + $starred | Should -BeTrue |
| 199 | + } |
| 200 | + |
| 201 | + $gist | Remove-GitHubGistStar |
| 202 | + $starred = $gist | Test-GitHubGistStar |
| 203 | + It 'Should no longer be starred yet' { |
| 204 | + $starred | Should -BeFalse |
163 | 205 | }
|
164 | 206 | }
|
165 | 207 | }
|
|
0 commit comments