singem 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'date'
5
5
  require 'spec/rake/spectask'
6
6
 
7
7
  GEM = "singem"
8
- GEM_VERSION = "0.0.3"
8
+ GEM_VERSION = "0.0.4"
9
9
  AUTHOR = "Corey Donohoe"
10
10
  EMAIL = "atmos@atmos.org"
11
11
  HOMEPAGE = "http://github.com/atmos/singem"
@@ -26,7 +26,7 @@ spec = Gem::Specification.new do |s|
26
26
  s.add_dependency "rubigen", ">= 1.5.2"
27
27
  s.add_dependency "rack-test", "~>0.1.0"
28
28
  s.add_dependency "webrat", "~>0.4.3"
29
- s.add_dependency "fakeweb", "~>1.2.0"
29
+ s.add_dependency "fakeweb", "~>1.2.4"
30
30
  s.add_dependency 'haml', "~>2.0.9"
31
31
 
32
32
  s.require_path = 'lib'
@@ -6,50 +6,7 @@ require 'dm-sweatshop'
6
6
  require 'pp'
7
7
 
8
8
  require File.dirname(__FILE__)+'/../../lib/<%= name %>'
9
-
10
- module <%= name.camelize %>::AppHelpers
11
- def app
12
- @app = Rack::Builder.new do
13
- run <%= name.camelize %>::App
14
- end
15
- end
16
-
17
- def login_quentin
18
- response = Net::HTTPSuccess.new('1.0', 200, nil)
19
- response.body = "{\"description\":\"lulz\",\"profile_background_image_url\":\"http:\\/\\/static.twitter.com\\/images\\/themes\\/theme3\\/bg.gif\",\"utc_offset\":-25200,\"friends_count\":157,\"profile_background_color\":\"EDECE9\",\"profile_text_color\":\"634047\",\"url\":\"http:\\/\\/example.org\",\"name\":\"Quentin Blake\",\"favourites_count\":6,\"profile_link_color\":\"088253\",\"protected\":false,\"status\":{\"truncated\":false,\"in_reply_to_status_id\":null,\"text\":\"stu stu studio\",\"in_reply_to_user_id\":null,\"favorited\":false,\"created_at\":\"Tue Mar 31 19:02:12 +0000 2009\",\"id\":1426242614,\"source\":\"<a href=\\\"http:\\/\\/iconfactory.com\\/software\\/twitterrific\\\">twitterrific<\\/a>\"},\"created_at\":\"Sun Mar 18 20:07:13 +0000 2007\",\"statuses_count\":2560,\"profile_background_tile\":false,\"time_zone\":\"Mountain Time (US & Canada)\",\"profile_sidebar_fill_color\":\"E3E2DE\",\"profile_image_url\":\"http:\\/\\/static.twitter.com\\/images\\/default_profile_normal.png\",\"notifications\":false,\"profile_sidebar_border_color\":\"D3D2CF\",\"location\":\"Boulder, Colorado\",\"id\":1484261,\"following\":false,\"followers_count\":368,\"screen_name\":\"caboose\"}"
20
- login(response)
21
- end
22
-
23
- def unauthorized_quentin
24
- response = Net::HTTPUnauthorized.new('1.0', 401, nil)
25
- response.body = "Unauthorized"
26
- lambda { login(response) }.should raise_error(ArgumentError)
27
- end
28
-
29
- def login(response)
30
- token = 'oU5W1XD2TTZhWT6Snfii9JbVBUkJOurCKhWQHz98765'
31
-
32
- consumer = mock('Consumer', {:request => response})
33
- request_token = mock('RequestToken', {:get_access_token => mock('AccessToken', {:token => 'foo', :secret => 'bar'})})
34
-
35
- OAuth::Consumer.stub!(:new).and_return(consumer)
36
- OAuth::RequestToken.stub!(:new).and_return(request_token)
37
-
38
- visit "/callback?oauth_token=#{token}"
39
- end
40
- end
41
-
42
- Webrat.configure do |config|
43
- config.mode = :rack_test
44
- config.application_port = 4567
45
- end
46
-
47
- class Net::HTTPResponse
48
- def body=(content)
49
- @body = content
50
- @read = true
51
- end
52
- end
9
+ require File.dirname(__FILE__)+'/../../spec/helpers'
53
10
 
54
11
  World(Rack::Test::Methods)
55
12
  World(Spec::Mocks::ExampleMethods)
@@ -0,0 +1,43 @@
1
+ class Net::HTTPResponse
2
+ def body=(content)
3
+ @body = content
4
+ @read = true
5
+ end
6
+ end
7
+
8
+ Webrat.configure do |config|
9
+ config.mode = :rack_test
10
+ config.application_port = 4567
11
+ end
12
+
13
+ module <%= name.camelize %>::AppHelpers
14
+ def app
15
+ @app = Rack::Builder.new do
16
+ run <%= name.camelize %>::App
17
+ end
18
+ end
19
+
20
+ def login_quentin
21
+ response = Net::HTTPSuccess.new('1.0', 200, nil)
22
+ response.body = "{\"description\":\"lulz\",\"profile_background_image_url\":\"http:\\/\\/static.twitter.com\\/images\\/themes\\/theme3\\/bg.gif\",\"utc_offset\":-25200,\"friends_count\":157,\"profile_background_color\":\"EDECE9\",\"profile_text_color\":\"634047\",\"url\":\"http:\\/\\/example.org\",\"name\":\"Quentin Blake\",\"favourites_count\":6,\"profile_link_color\":\"088253\",\"protected\":false,\"status\":{\"truncated\":false,\"in_reply_to_status_id\":null,\"text\":\"stu stu studio\",\"in_reply_to_user_id\":null,\"favorited\":false,\"created_at\":\"Tue Mar 31 19:02:12 +0000 2009\",\"id\":1426242614,\"source\":\"<a href=\\\"http:\\/\\/iconfactory.com\\/software\\/twitterrific\\\">twitterrific<\\/a>\"},\"created_at\":\"Sun Mar 18 20:07:13 +0000 2007\",\"statuses_count\":2560,\"profile_background_tile\":false,\"time_zone\":\"Mountain Time (US & Canada)\",\"profile_sidebar_fill_color\":\"E3E2DE\",\"profile_image_url\":\"http:\\/\\/static.twitter.com\\/images\\/default_profile_normal.png\",\"notifications\":false,\"profile_sidebar_border_color\":\"D3D2CF\",\"location\":\"Boulder, Colorado\",\"id\":1484261,\"following\":false,\"followers_count\":368,\"screen_name\":\"caboose\"}"
23
+ login(response)
24
+ end
25
+
26
+ def unauthorized_quentin
27
+ response = Net::HTTPUnauthorized.new('1.0', 401, nil)
28
+ response.body = "Unauthorized"
29
+ lambda { login(response) }.should raise_error(ArgumentError)
30
+ end
31
+
32
+ def login(response)
33
+ token = 'oU5W1XD2TTZhWT6Snfii9JbVBUkJOurCKhWQHz98765'
34
+
35
+ consumer = mock('Consumer', {:request => response})
36
+ request_token = mock('RequestToken', {:get_access_token => mock('AccessToken', {:token => 'foo', :secret => 'bar'})})
37
+
38
+ OAuth::Consumer.stub!(:new).and_return(consumer)
39
+ OAuth::RequestToken.stub!(:new).and_return(request_token)
40
+
41
+ visit "/callback?oauth_token=#{token}"
42
+ end
43
+ end
@@ -3,10 +3,10 @@ $:.push File.join(File.dirname(__FILE__), '..', 'lib')
3
3
  require 'rubygems'
4
4
  require 'randexp'
5
5
  require '<%= name %>'
6
- require 'dm-core'
7
6
  require 'rack/test'
8
7
  require 'webrat'
9
8
  require 'dm-sweatshop'
9
+ gem 'fakeweb', '~>1.2.4'
10
10
  require 'fakeweb'
11
11
  require 'pp'
12
12
 
@@ -15,61 +15,24 @@ ENV['<%= name.upcase %>_READKEY'] = /\w{18}/.gen
15
15
  ENV['<%= name.upcase %>_READSECRET'] = /\w{18}/.gen
16
16
 
17
17
  require File.dirname(__FILE__)+'/fixtures'
18
+ require File.dirname(__FILE__)+'/helpers'
18
19
 
19
20
  DataMapper.setup(:default, 'sqlite3::memory:')
20
21
 
21
- class Net::HTTPResponse
22
- def body=(content)
23
- @body = content
24
- @read = true
25
- end
26
- end
27
-
28
22
  Spec::Runner.configure do |config|
29
23
  config.include(Rack::Test::Methods)
30
24
  config.include(Webrat::Methods)
31
25
  config.include(Webrat::Matchers)
26
+ config.include(<%= name.camelize %>::AppHelpers)
32
27
 
33
28
  config.before(:each) do
34
29
  ::<%= name.camelize %>::App.environment = :development
35
30
  DataMapper.auto_migrate!
36
31
  FakeWeb.clean_registry
37
32
  FakeWeb.register_uri(:post, "http://twitter.com:80/oauth/request_token",
38
- [{:string => "oauth_token=requestkey&oauth_token_secret=requestsecret", :status => ["200", "OK"]},
39
- {:string => "", :status => ["401", "Unauthorized"]},
40
- {:string => "", :status => ["403", "Forbidden"]},
41
- {:string => "Bad Gateway", :status => ["502", "Bad Gateway"]} ])
42
- end
43
-
44
- def app
45
- @app = Rack::Builder.new do
46
- run <%= name.camelize %>::App
47
- end
48
- end
49
-
50
- def login_quentin
51
- response = Net::HTTPSuccess.new('1.0', 200, nil)
52
- response.body = "{\"description\":\"lulz\",\"profile_background_image_url\":\"http:\\/\\/static.twitter.com\\/images\\/themes\\/theme3\\/bg.gif\",\"utc_offset\":-25200,\"friends_count\":157,\"profile_background_color\":\"EDECE9\",\"profile_text_color\":\"634047\",\"url\":\"http:\\/\\/example.org\",\"name\":\"Quentin Blake\",\"favourites_count\":6,\"profile_link_color\":\"088253\",\"protected\":false,\"status\":{\"truncated\":false,\"in_reply_to_status_id\":null,\"text\":\"stu stu studio\",\"in_reply_to_user_id\":null,\"favorited\":false,\"created_at\":\"Tue Mar 31 19:02:12 +0000 2009\",\"id\":1426242614,\"source\":\"<a href=\\\"http:\\/\\/iconfactory.com\\/software\\/twitterrific\\\">twitterrific<\\/a>\"},\"created_at\":\"Sun Mar 18 20:07:13 +0000 2007\",\"statuses_count\":2560,\"profile_background_tile\":false,\"time_zone\":\"Mountain Time (US & Canada)\",\"profile_sidebar_fill_color\":\"E3E2DE\",\"profile_image_url\":\"http:\\/\\/static.twitter.com\\/images\\/default_profile_normal.png\",\"notifications\":false,\"profile_sidebar_border_color\":\"D3D2CF\",\"location\":\"Boulder, Colorado\",\"id\":1484261,\"following\":false,\"followers_count\":368,\"screen_name\":\"caboose\"}"
53
- login(response)
54
- last_response.headers['Location'].should eql('/')
55
- end
56
-
57
- def unauthorized_quentin
58
- response = Net::HTTPUnauthorized.new('1.0', 401, nil)
59
- response.body = "Unauthorized"
60
- lambda { login(response) }.should raise_error(ArgumentError)
61
- end
62
-
63
- def login(response)
64
- token = 'oU5W1XD2TTZhWT6Snfii9JbVBUkJOurCKhWQHz98765'
65
-
66
- consumer = mock('Consumer', {:request => response})
67
- request_token = mock('RequestToken', {:get_access_token => mock('AccessToken', {:token => 'foo', :secret => 'bar'})})
68
-
69
- OAuth::Consumer.stub!(:new).and_return(consumer)
70
- OAuth::RequestToken.stub!(:new).and_return(request_token)
71
-
72
- get '/callback', :oauth_token => token
73
- last_response
33
+ [{:body => "oauth_token=requestkey&oauth_token_secret=requestsecret", :status => ["200", "OK"]},
34
+ {:body => "", :status => ["401", "Unauthorized"]},
35
+ {:body => "", :status => ["403", "Forbidden"]},
36
+ {:body => "Bad Gateway", :status => ["502", "Bad Gateway"]} ])
74
37
  end
75
38
  end
@@ -38,6 +38,7 @@ class TwitterGenerator < RubiGen::Base
38
38
 
39
39
  # rspec stubs
40
40
  m.template "spec/spec_helper.rb.erb", "spec/spec_helper.rb"
41
+ m.template "spec/helpers.rb.erb", "spec/helpers.rb"
41
42
  m.template "spec/templates_spec.rb.erb", "spec/#{name}_spec.rb"
42
43
  m.template "spec/fixtures.rb.erb", "spec/fixtures.rb"
43
44
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: singem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corey Donohoe
@@ -110,7 +110,6 @@ files:
110
110
  - lib/generators/cucumber/templates/spec/templates_spec.rb.erb
111
111
  - lib/generators/cucumber/templates/TODO
112
112
  - lib/generators/cucumber/USAGE
113
- - lib/generators/foo.txt
114
113
  - lib/generators/singem
115
114
  - lib/generators/singem/singem_generator.rb
116
115
  - lib/generators/singem/templates
@@ -157,6 +156,7 @@ files:
157
156
  - lib/generators/twitter/templates/README.md
158
157
  - lib/generators/twitter/templates/spec
159
158
  - lib/generators/twitter/templates/spec/fixtures.rb.erb
159
+ - lib/generators/twitter/templates/spec/helpers.rb.erb
160
160
  - lib/generators/twitter/templates/spec/spec_helper.rb.erb
161
161
  - lib/generators/twitter/templates/spec/templates_spec.rb.erb
162
162
  - lib/generators/twitter/templates/TODO
@@ -1,284 +0,0 @@
1
- diff -ur twitter/USAGE cucumber/USAGE
2
- --- twitter/USAGE 2009-05-06 23:36:10.000000000 -0600
3
- +++ cucumber/USAGE 2009-05-20 01:51:20.000000000 -0600
4
- @@ -1,5 +1,5 @@
5
- Description:
6
- -
7
- -
8
- +
9
- +
10
- Usage:
11
- -
12
- +
13
- Only in cucumber: cucumber_generator.rb
14
- diff -ur twitter/templates/README.md cucumber/templates/README.md
15
- --- twitter/templates/README.md 2009-05-06 23:36:10.000000000 -0600
16
- +++ cucumber/templates/README.md 2009-05-22 21:12:13.000000000 -0600
17
- @@ -1,4 +1,4 @@
18
- <%= name %>
19
- <%= "=" * name.size %>
20
-
21
- -A gem that provides...
22
- +A sinatra app the provides a gem that...
23
- diff -ur twitter/templates/Rakefile cucumber/templates/Rakefile
24
- --- twitter/templates/Rakefile 2009-05-22 21:11:36.000000000 -0600
25
- +++ cucumber/templates/Rakefile 2009-05-22 21:33:17.000000000 -0600
26
- @@ -3,6 +3,7 @@
27
- require 'rubygems/specification'
28
- require 'date'
29
- require 'spec/rake/spectask'
30
- +require 'cucumber/rake/task'
31
-
32
- GEM = "<%= name %>"
33
- GEM_VERSION = "0.0.1"
34
- @@ -32,7 +33,7 @@
35
-
36
- s.require_path = 'lib'
37
- s.autorequire = GEM
38
- - s.files = %w(LICENSE README.md Rakefile TODO) + Dir.glob("{lib,spec}/**/*")
39
- + s.files = %w(LICENSE README.md Rakefile TODO) + Dir.glob("{lib,features}/**/*")
40
- end
41
-
42
- Rake::GemPackageTask.new(spec) do |pkg|
43
- @@ -51,7 +52,13 @@
44
- end
45
- end
46
-
47
- -task :default => :spec
48
- +task :default => :features
49
- +
50
- +desc "Run cucumber"
51
- +Cucumber::Rake::Task.new do |t|
52
- + t.cucumber_opts = %w{--format pretty}
53
- +end
54
- +
55
-
56
- desc "Run specs"
57
- Spec::Rake::SpecTask.new do |t|
58
- diff -ur twitter/templates/config.ru.erb cucumber/templates/config.ru.erb
59
- --- twitter/templates/config.ru.erb 2009-05-20 01:59:02.000000000 -0600
60
- +++ cucumber/templates/config.ru.erb 2009-07-05 13:03:25.000000000 -0600
61
- @@ -1,9 +1,6 @@
62
- require 'rubygems'
63
- require '<%= name %>'
64
-
65
- -ENV['<%= name.upcase %>_READKEY'] = /\w{18}/.gen # this should really be what twitter gives you
66
- -ENV['<%= name.upcase %>_READSECRET'] = /\w{24}/.gen # this should really be what twitter gives you
67
- -
68
- #DataMapper.setup(:default, "mysql://atmos:fail@localhost/<%= name.capitalize %>_production")
69
-
70
- class <%= name.camelize %>Site < <%= name.camelize %>::App
71
- Only in cucumber/templates: features
72
- Only in cucumber/templates/lib/templates: app.rb.erb
73
- Only in twitter/templates/lib/templates: models
74
- Only in twitter/templates/lib/templates: sinatra
75
- Only in twitter/templates/lib/templates: views
76
- diff -ur twitter/templates/lib/templates.rb.erb cucumber/templates/lib/templates.rb.erb
77
- --- twitter/templates/lib/templates.rb.erb 2009-05-06 23:36:10.000000000 -0600
78
- +++ cucumber/templates/lib/templates.rb.erb 2009-05-20 01:51:20.000000000 -0600
79
- @@ -1,58 +1,9 @@
80
- -gem 'oauth'
81
- -require 'oauth'
82
- -gem 'json'
83
- -require 'json'
84
- -gem 'haml', '~>2.0.9'
85
- +require 'rubygems'
86
- +require 'sinatra/base'
87
- require 'haml/util'
88
- require 'haml/engine'
89
- -gem 'chronic'
90
- -require 'chronic'
91
- -gem 'curb'
92
- -require 'curb'
93
- -require 'logger'
94
- -
95
- -gem 'data_objects', '~>0.9.11'
96
- -gem 'dm-core', '~>0.9.10'
97
- -gem 'dm-types', '~>0.9.10'
98
- -gem 'dm-validations', '~>0.9.10'
99
- -gem 'dm-timestamps', '~>0.9.10'
100
- -require 'dm-core'
101
- -require 'dm-types'
102
- -require 'dm-validations'
103
- -require 'dm-timestamps'
104
- -require 'sinatra/base'
105
-
106
- module <%= name.camelize %>
107
- - module Log
108
- - def self.logger
109
- - if @logger.nil?
110
- - @logger = Logger.new("<%= name %>.log")
111
- - @logger.level = Logger::INFO
112
- - end
113
- - @logger
114
- - end
115
- - end
116
- -
117
- - module OAuth
118
- - def self.consumer
119
- - ::OAuth::Consumer.new(ENV['<%= name.upcase %>_READKEY'],
120
- - ENV['<%= name.upcase %>_READSECRET'],
121
- - {:site => 'http://twitter.com'})
122
- - end
123
- - end
124
- -
125
- - def self.retryable(options = {}, &block)
126
- - opts = { :tries => 1, :on => StandardError }.merge(options)
127
- - retry_exception, retries = opts[:on], opts[:tries]
128
- -
129
- - begin
130
- - return yield
131
- - rescue retry_exception
132
- - retry if (retries -= 1) > 0
133
- - end
134
- - yield
135
- - end
136
- end
137
-
138
- -require File.dirname(__FILE__)+'/<%= name %>/models/user'
139
- -require File.dirname(__FILE__)+'/<%= name %>/sinatra/app'
140
- +require File.dirname(__FILE__)+'/<%= name %>/app'
141
- diff -ur twitter/templates/spec/spec_helper.rb.erb cucumber/templates/spec/spec_helper.rb.erb
142
- --- twitter/templates/spec/spec_helper.rb.erb 2009-05-22 21:29:00.000000000 -0600
143
- +++ cucumber/templates/spec/spec_helper.rb.erb 2009-05-20 01:51:20.000000000 -0600
144
- @@ -3,20 +3,17 @@
145
- require 'rubygems'
146
- require 'randexp'
147
- require '<%= name %>'
148
- -require 'dm-core'
149
- +#require 'dm-core'
150
- require 'rack/test'
151
- -require 'webrat'
152
- -require 'dm-sweatshop'
153
- +require 'webrat/sinatra'
154
- +#require 'dm-sweatshop'
155
- require 'fakeweb'
156
- require 'pp'
157
-
158
- FakeWeb.allow_net_connect = false
159
- -ENV['<%= name.upcase %>_READKEY'] = /\w{18}/.gen
160
- -ENV['<%= name.upcase %>_READSECRET'] = /\w{18}/.gen
161
-
162
- -require File.dirname(__FILE__)+'/fixtures'
163
- -
164
- -DataMapper.setup(:default, 'sqlite3::memory:')
165
- +#require File.dirname(__FILE__)+'/fixtures'
166
- +#DataMapper.setup(:default, 'sqlite3::memory:')
167
-
168
- class Net::HTTPResponse
169
- def body=(content)
170
- @@ -31,14 +28,8 @@
171
- config.include(Webrat::Matchers)
172
-
173
- config.before(:each) do
174
- - ::<%= name.camelize %>::App.environment = :development
175
- - DataMapper.auto_migrate!
176
- + #DataMapper.auto_migrate!
177
- FakeWeb.clean_registry
178
- - FakeWeb.register_uri(:post, "http://twitter.com:80/oauth/request_token",
179
- - [{:string => "oauth_token=requestkey&oauth_token_secret=requestsecret", :status => ["200", "OK"]},
180
- - {:string => "", :status => ["401", "Unauthorized"]},
181
- - {:string => "", :status => ["403", "Forbidden"]},
182
- - {:string => "Bad Gateway", :status => ["502", "Bad Gateway"]} ])
183
- end
184
-
185
- def app
186
- @@ -46,30 +37,4 @@
187
- run <%= name.camelize %>::App
188
- end
189
- end
190
- -
191
- - def login_quentin
192
- - response = Net::HTTPSuccess.new('1.0', 200, nil)
193
- - response.body = "{\"description\":\"lulz\",\"profile_background_image_url\":\"http:\\/\\/static.twitter.com\\/images\\/themes\\/theme3\\/bg.gif\",\"utc_offset\":-25200,\"friends_count\":157,\"profile_background_color\":\"EDECE9\",\"profile_text_color\":\"634047\",\"url\":\"http:\\/\\/example.org\",\"name\":\"Quentin Blake\",\"favourites_count\":6,\"profile_link_color\":\"088253\",\"protected\":false,\"status\":{\"truncated\":false,\"in_reply_to_status_id\":null,\"text\":\"stu stu studio\",\"in_reply_to_user_id\":null,\"favorited\":false,\"created_at\":\"Tue Mar 31 19:02:12 +0000 2009\",\"id\":1426242614,\"source\":\"<a href=\\\"http:\\/\\/iconfactory.com\\/software\\/twitterrific\\\">twitterrific<\\/a>\"},\"created_at\":\"Sun Mar 18 20:07:13 +0000 2007\",\"statuses_count\":2560,\"profile_background_tile\":false,\"time_zone\":\"Mountain Time (US & Canada)\",\"profile_sidebar_fill_color\":\"E3E2DE\",\"profile_image_url\":\"http:\\/\\/static.twitter.com\\/images\\/default_profile_normal.png\",\"notifications\":false,\"profile_sidebar_border_color\":\"D3D2CF\",\"location\":\"Boulder, Colorado\",\"id\":1484261,\"following\":false,\"followers_count\":368,\"screen_name\":\"caboose\"}"
194
- - login(response)
195
- - last_response.headers['Location'].should eql('/')
196
- - end
197
- -
198
- - def unauthorized_quentin
199
- - response = Net::HTTPUnauthorized.new('1.0', 401, nil)
200
- - response.body = "Unauthorized"
201
- - lambda { login(response) }.should raise_error(ArgumentError)
202
- - end
203
- -
204
- - def login(response)
205
- - token = 'oU5W1XD2TTZhWT6Snfii9JbVBUkJOurCKhWQHz98765'
206
- -
207
- - consumer = mock('Consumer', {:request => response})
208
- - request_token = mock('RequestToken', {:get_access_token => mock('AccessToken', {:token => 'foo', :secret => 'bar'})})
209
- -
210
- - OAuth::Consumer.stub!(:new).and_return(consumer)
211
- - OAuth::RequestToken.stub!(:new).and_return(request_token)
212
- -
213
- - get '/callback', :oauth_token => token
214
- - last_response
215
- - end
216
- end
217
- diff -ur twitter/templates/spec/templates_spec.rb.erb cucumber/templates/spec/templates_spec.rb.erb
218
- --- twitter/templates/spec/templates_spec.rb.erb 2009-05-06 23:36:10.000000000 -0600
219
- +++ cucumber/templates/spec/templates_spec.rb.erb 2009-05-20 01:51:20.000000000 -0600
220
- @@ -1,59 +1,8 @@
221
- require File.dirname(__FILE__) + '/spec_helper'
222
-
223
- -describe "visiting /" do
224
- - describe "when unauthenticated" do
225
- - it "should display the about page" do
226
- - get '/'
227
- - last_response.should have_selector("h2:contains('Do you use twitter?')")
228
- - end
229
- - end
230
- - describe "when unauthorized" do
231
- - it "should raise an error" do
232
- - lambda { unauthorized_quentin }.should raise_error
233
- - end
234
- - end
235
- - describe "when authenticated" do
236
- - it "should display a greeting" do
237
- - login_quentin
238
- - get '/'
239
- - last_response.should have_selector("h2:contains('Hello There, you little twitterer!')")
240
- - end
241
- - end
242
- -end
243
- -
244
- -describe "visiting /peace" do
245
- - describe "when authenticated" do
246
- - it "should clear the session and redirect to the home page" do
247
- - login_quentin
248
- - get '/peace'
249
- - last_response.headers['Location'].should eql('/')
250
- -
251
- - get last_response.headers['Location']
252
- - last_response.should have_selector("h2:contains('Do you use twitter?')")
253
- - end
254
- - end
255
- -end
256
- -
257
- -describe "triggering a 404" do
258
- - it "should display the failed page" do
259
- - pending
260
- - get '/lost'
261
- - last_response.should have_selector("p:contains('Something went wonky.')")
262
- - end
263
- -end
264
- -
265
- -describe "visiting /authenticate" do
266
- - it "should redirect to twitter for authentication" do
267
- - get '/authenticate'
268
- - last_response.headers['Location'].should eql('http://twitter.com/oauth/authorize?oauth_token=requestkey')
269
- - end
270
- -end
271
- -
272
- -describe "<%= name.camelize %>::User" do
273
- - it "can create users from twitter ids that exist" do
274
- - lambda { <%= name.camelize %>::User.create_twitter_user('atmos') }.should_not raise_error
275
- - end
276
- - it "can't create users from twitter ids that do not exist" do
277
- - lambda { <%= name.camelize %>::User.create_twitter_user(/\w{18}/.gen) }.should raise_error(<%= name.camelize %>::User::UserCreationError)
278
- +describe "<%= name.camelize %>" do
279
- + it "should do nothing" do
280
- + get '/'
281
- + last_response.should have_selector("h2:contains('Hello There, buddy!')")
282
- end
283
- end
284
- Only in twitter: twitter_generator.rb