impostor 0.2.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/.gitignore +1 -0
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +47 -0
- data/History.txt +8 -0
- data/Manifest.txt +87 -55
- data/README.txt +11 -11
- data/Rakefile +16 -20
- data/lib/impostor/auth.rb +103 -0
- data/lib/impostor/config.rb +171 -0
- data/lib/impostor/errors.rb +67 -0
- data/lib/impostor/phpbb2.rb +202 -0
- data/lib/impostor/phpbb3.rb +199 -0
- data/lib/impostor/post.rb +111 -0
- data/lib/impostor/topic.rb +115 -0
- data/lib/impostor/wwf79.rb +186 -0
- data/lib/impostor/wwf80.rb +190 -0
- data/lib/impostor.rb +108 -5
- data/spec/auth_spec.rb +148 -0
- data/spec/base_spec_helper.rb +12 -0
- data/{test/test_helper.rb → spec/caged_net_http.rb} +8 -17
- data/spec/config_spec.rb +136 -0
- data/spec/fixtures/junk.html +1 -0
- data/{test → spec}/fixtures/phpbb2-get-new_topic-form-good-response.html +0 -0
- data/{test → spec}/fixtures/phpbb2-get-viewtopic-for-new-topic-good-response.html +11 -11
- data/{test → spec}/fixtures/phpbb2-get-viewtopic-for-new-topic-malformed-response.html +0 -0
- data/{test → spec}/fixtures/phpbb2-index.html +0 -0
- data/{test → spec}/fixtures/phpbb2-logged-in.html +0 -0
- data/{test → spec}/fixtures/phpbb2-login.html +0 -0
- data/{test → spec}/fixtures/phpbb2-not-logged-in.html +0 -0
- data/{test → spec}/fixtures/phpbb2-post-new_topic-good-response.html +0 -0
- data/{test → spec}/fixtures/phpbb2-post-reply-good-response.html +0 -0
- data/{test → spec}/fixtures/phpbb2-post-reply-throttled-response.html +0 -0
- data/{test → spec}/fixtures/phpbb2-too-many-posts.html +0 -0
- data/{test → spec}/fixtures/phpbb3-get-new-topic-form-good-response.html +0 -0
- data/{test → spec}/fixtures/phpbb3-get-reply-form-good-response.html +0 -0
- data/{test → spec}/fixtures/phpbb3-logged-in.html +0 -0
- data/{test → spec}/fixtures/phpbb3-login.html +0 -0
- data/{test → spec}/fixtures/phpbb3-not-logged-in.html +0 -0
- data/{test → spec}/fixtures/phpbb3-post-new_topic-good-response.html +0 -0
- data/{test → spec}/fixtures/phpbb3-post-reply-good-response.html +0 -0
- data/spec/fixtures/vcr_cassettes/phpbb2-should-be-overlimit-creating-topic.yml +1308 -0
- data/spec/fixtures/vcr_cassettes/phpbb2-should-create-topic.yml +923 -0
- data/spec/fixtures/vcr_cassettes/phpbb2-should-login.yml +360 -0
- data/spec/fixtures/vcr_cassettes/phpbb2-should-not-create-new-topic.yml +497 -0
- data/spec/fixtures/vcr_cassettes/phpbb2-should-not-login.yml +287 -0
- data/spec/fixtures/vcr_cassettes/phpbb2-should-not-post.yml +497 -0
- data/spec/fixtures/vcr_cassettes/phpbb2-should-overlimit-error-post.yml +1140 -0
- data/spec/fixtures/vcr_cassettes/phpbb2-should-post.yml +751 -0
- data/spec/fixtures/vcr_cassettes/phpbb3-should-be-overlimit-creating-topic.yml +995 -0
- data/spec/fixtures/vcr_cassettes/phpbb3-should-create-topic.yml +675 -0
- data/spec/fixtures/vcr_cassettes/phpbb3-should-login.yml +245 -0
- data/spec/fixtures/vcr_cassettes/phpbb3-should-not-create-new-topic.yml +350 -0
- data/spec/fixtures/vcr_cassettes/phpbb3-should-not-login.yml +253 -0
- data/spec/fixtures/vcr_cassettes/phpbb3-should-not-post.yml +350 -0
- data/spec/fixtures/vcr_cassettes/phpbb3-should-overlimit-error-post.yml +1046 -0
- data/spec/fixtures/vcr_cassettes/phpbb3-should-post.yml +605 -0
- data/{test → spec}/fixtures/wwf79-forum_posts.html +0 -0
- data/{test → spec}/fixtures/wwf79-general-new-topic-error.html +0 -0
- data/{test → spec}/fixtures/wwf79-general-posting-error.html +0 -0
- data/{test → spec}/fixtures/wwf79-good-post-forum_posts.html +1 -1
- data/{test → spec}/fixtures/wwf79-index.html +0 -0
- data/{test → spec}/fixtures/wwf79-logged-in.html +0 -0
- data/{test → spec}/fixtures/wwf79-login.html +0 -0
- data/{test → spec}/fixtures/wwf79-new-topic-forum_posts-response.html +0 -0
- data/{test → spec}/fixtures/wwf79-new-topic-post_message_form.html +0 -0
- data/{test → spec}/fixtures/wwf79-not-logged-in.html +0 -0
- data/{test → spec}/fixtures/wwf79-too-many-posts.html +0 -0
- data/{test → spec}/fixtures/wwf79-too-many-topics.html +0 -0
- data/{test → spec}/fixtures/wwf80-general-posting-error.html +0 -0
- data/{test → spec}/fixtures/wwf80-get-new_topic-form-good-response.html +0 -0
- data/{test → spec}/fixtures/wwf80-get-viewtopic-for-new-topic-good-response.html +0 -0
- data/{test → spec}/fixtures/wwf80-index.html +0 -0
- data/{test → spec}/fixtures/wwf80-logged-in.html +0 -0
- data/{test → spec}/fixtures/wwf80-login.html +0 -0
- data/{test → spec}/fixtures/wwf80-new_reply_form.html +0 -0
- data/{test → spec}/fixtures/wwf80-not-logged-in.html +0 -0
- data/{test → spec}/fixtures/wwf80-post-new_topic-good-response.html +1 -1
- data/{test → spec}/fixtures/wwf80-post-reply-good-response.html +0 -0
- data/{test → spec}/fixtures/wwf80-too-many-posts.html +0 -0
- data/spec/impostor_spec_helper.rb +162 -0
- data/spec/integration/phpbb2_spec.rb +111 -0
- data/spec/integration/phpbb3_spec.rb +109 -0
- data/spec/integration_spec_helper.rb +7 -0
- data/spec/phpbb2_spec.rb +346 -0
- data/spec/phpbb3_spec.rb +332 -0
- data/spec/post_spec.rb +134 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/test_impostor.rb +12 -0
- data/spec/topic_spec.rb +143 -0
- data/spec/wwf79_spec.rb +342 -0
- data/spec/wwf80_spec.rb +339 -0
- metadata +156 -87
- data/lib/www/impostor/phpbb2.rb +0 -258
- data/lib/www/impostor/phpbb3.rb +0 -236
- data/lib/www/impostor/wwf79.rb +0 -254
- data/lib/www/impostor/wwf80.rb +0 -264
- data/lib/www/impostor.rb +0 -269
- data/test/test_github.rb +0 -12
- data/test/test_www_impostor.rb +0 -165
- data/test/test_www_impostor_phpbb2.rb +0 -536
- data/test/test_www_impostor_phpbb3.rb +0 -483
- data/test/test_www_impostor_wwf79.rb +0 -535
- data/test/test_www_impostor_wwf80.rb +0 -535
- data/vendor/plugins/impostor/lib/autotest/discover.rb +0 -3
- data/vendor/plugins/impostor/lib/autotest/impostor.rb +0 -49
File without changes
|
File without changes
|
@@ -0,0 +1,162 @@
|
|
1
|
+
module ImpostorSpecHelper
|
2
|
+
|
3
|
+
def sample_phpbb3_config_params(config = {})
|
4
|
+
{ :type => :phpbb3,
|
5
|
+
:app_root => 'http://example.com/forum/',
|
6
|
+
:login_page => 'ucp.php?mode=login',
|
7
|
+
:posting_page => 'posting.php',
|
8
|
+
:user_agent => 'Windows IE 7',
|
9
|
+
:username => 'tester',
|
10
|
+
:password => 'password' }.merge(config)
|
11
|
+
end
|
12
|
+
|
13
|
+
def sample_phpbb2_config_params(config = {})
|
14
|
+
{ :type => :phpbb2,
|
15
|
+
:app_root => 'http://example.com/forum/',
|
16
|
+
:login_page => 'login.php',
|
17
|
+
:posting_page => 'posting.php',
|
18
|
+
:user_agent => 'Windows IE 7',
|
19
|
+
:username => 'tester',
|
20
|
+
:password => 'password' }.merge(config)
|
21
|
+
end
|
22
|
+
|
23
|
+
def sample_wwf80_config_params
|
24
|
+
{ :type => :wwf80,
|
25
|
+
:app_root => 'http://example.com/forum/',
|
26
|
+
:login_page => 'login_user.asp',
|
27
|
+
:new_reply_page => 'new_reply_form.asp',
|
28
|
+
:new_topic_page => 'new_topic_form.asp',
|
29
|
+
:user_agent => 'Windows IE 7',
|
30
|
+
:username => 'tester',
|
31
|
+
:password => 'password' }
|
32
|
+
end
|
33
|
+
|
34
|
+
def sample_wwf79_config_params
|
35
|
+
{ :type => :wwf79,
|
36
|
+
:app_root => 'http://example.com/forum/',
|
37
|
+
:login_page => 'login_user.asp',
|
38
|
+
:forum_posts_page => 'forum_posts.asp',
|
39
|
+
:post_message_page => 'post_message_form.asp',
|
40
|
+
:user_agent => 'Windows IE 7',
|
41
|
+
:username => 'tester',
|
42
|
+
:password => 'password' }
|
43
|
+
end
|
44
|
+
|
45
|
+
def sample_config_params
|
46
|
+
{ :type => :test,
|
47
|
+
:username => "user",
|
48
|
+
:password => "password",
|
49
|
+
:app_root => "http://example.com",
|
50
|
+
:login_page => "/login" }
|
51
|
+
end
|
52
|
+
|
53
|
+
def wwf80_auth
|
54
|
+
config = self.config(sample_wwf80_config_params)
|
55
|
+
auth = self.auth(config)
|
56
|
+
auth
|
57
|
+
end
|
58
|
+
|
59
|
+
def phpbb3_auth(config = {})
|
60
|
+
config = self.config(sample_phpbb3_config_params(config))
|
61
|
+
auth = self.auth(config)
|
62
|
+
auth
|
63
|
+
end
|
64
|
+
|
65
|
+
def wwf79_auth
|
66
|
+
config = self.config(sample_wwf79_config_params)
|
67
|
+
auth = self.auth(config)
|
68
|
+
auth
|
69
|
+
end
|
70
|
+
|
71
|
+
def phpbb2_auth
|
72
|
+
config = self.config(sample_phpbb2_config_params)
|
73
|
+
auth = self.auth(config)
|
74
|
+
auth
|
75
|
+
end
|
76
|
+
|
77
|
+
def wwf80_post
|
78
|
+
config = self.config(sample_wwf80_config_params)
|
79
|
+
auth = self.auth(config)
|
80
|
+
self.post(config, auth)
|
81
|
+
end
|
82
|
+
|
83
|
+
def wwf79_post
|
84
|
+
config = self.config(sample_wwf79_config_params)
|
85
|
+
auth = self.auth(config)
|
86
|
+
self.post(config, auth)
|
87
|
+
end
|
88
|
+
|
89
|
+
def phpbb3_post
|
90
|
+
config = self.config(sample_phpbb3_config_params)
|
91
|
+
auth = self.auth(config)
|
92
|
+
self.post(config, auth)
|
93
|
+
end
|
94
|
+
|
95
|
+
def phpbb2_post
|
96
|
+
config = self.config(sample_phpbb2_config_params)
|
97
|
+
auth = self.auth(config)
|
98
|
+
self.post(config, auth)
|
99
|
+
end
|
100
|
+
|
101
|
+
def wwf80_topic
|
102
|
+
config = self.config(sample_wwf80_config_params)
|
103
|
+
auth = self.auth(config)
|
104
|
+
self.topic(config, auth)
|
105
|
+
end
|
106
|
+
|
107
|
+
def phpbb3_topic
|
108
|
+
config = self.config(sample_phpbb3_config_params)
|
109
|
+
auth = self.auth(config)
|
110
|
+
self.topic(config, auth)
|
111
|
+
end
|
112
|
+
|
113
|
+
def wwf79_topic
|
114
|
+
config = self.config(sample_wwf79_config_params)
|
115
|
+
auth = self.auth(config)
|
116
|
+
self.topic(config, auth)
|
117
|
+
end
|
118
|
+
|
119
|
+
def phpbb2_topic
|
120
|
+
config = self.config(sample_phpbb2_config_params)
|
121
|
+
auth = self.auth(config)
|
122
|
+
self.topic(config, auth)
|
123
|
+
end
|
124
|
+
|
125
|
+
def impostor(config = {})
|
126
|
+
Impostor.new(sample_config_params.merge(config))
|
127
|
+
end
|
128
|
+
|
129
|
+
def config(config = {})
|
130
|
+
Impostor::Config.new(sample_config_params.merge(config))
|
131
|
+
end
|
132
|
+
|
133
|
+
def auth(config = nil)
|
134
|
+
config ||= self.config
|
135
|
+
auth = Impostor::Auth.new(config)
|
136
|
+
auth
|
137
|
+
end
|
138
|
+
|
139
|
+
def post(config = nil, auth = nil)
|
140
|
+
config ||= self.config
|
141
|
+
auth ||= self.auth
|
142
|
+
post = Impostor::Post.new(config, auth)
|
143
|
+
post
|
144
|
+
end
|
145
|
+
|
146
|
+
def topic(config = nil, auth = nil)
|
147
|
+
config ||= self.config
|
148
|
+
auth ||= self.auth
|
149
|
+
topic = Impostor::Topic.new(config, auth)
|
150
|
+
topic
|
151
|
+
end
|
152
|
+
|
153
|
+
def load_fixture_page(fixture, uri, code=200, agent=nil)
|
154
|
+
uri = URI.parse(uri) if uri.is_a?(String)
|
155
|
+
file = File.expand_path("#{File.dirname(__FILE__)}/fixtures/#{fixture}")
|
156
|
+
body = open(file).read
|
157
|
+
response = {'content-type' => 'text/html'}
|
158
|
+
|
159
|
+
Mechanize::Page.new(uri, response, body, code, agent)
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'integration_spec_helper')
|
2
|
+
|
3
|
+
describe "a phpbb2 impostor" do
|
4
|
+
|
5
|
+
it "should login" do
|
6
|
+
VCR.use_cassette('phpbb2-should-login', :record => :new_episodes) do
|
7
|
+
conf = self.sample_phpbb2_config_params(
|
8
|
+
:app_root => 'http://localhost/phpbb2/',
|
9
|
+
:sleep_before_post => 1
|
10
|
+
)
|
11
|
+
config = Impostor::Config.new(conf)
|
12
|
+
auth = Impostor::Auth.new(config)
|
13
|
+
auth.login.should be_true
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should fail login" do
|
18
|
+
VCR.use_cassette('phpbb2-should-not-login', :record => :new_episodes) do
|
19
|
+
conf = self.sample_phpbb2_config_params(
|
20
|
+
:app_root => 'http://localhost/phpbb2/',
|
21
|
+
:sleep_before_post => 1,
|
22
|
+
:password => 'junk'
|
23
|
+
)
|
24
|
+
config = Impostor::Config.new(conf)
|
25
|
+
auth = Impostor::Auth.new(config)
|
26
|
+
auth.login.should_not be_true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should post a message" do
|
31
|
+
VCR.use_cassette('phpbb2-should-post', :record => :new_episodes) do
|
32
|
+
conf = self.sample_phpbb2_config_params(
|
33
|
+
:app_root => 'http://localhost/phpbb2/',
|
34
|
+
:sleep_before_post => 1
|
35
|
+
)
|
36
|
+
impostor = Impostor.new(conf)
|
37
|
+
impostor.post(forum=1, topic=2, message='Hello World').should == {
|
38
|
+
:forum => 1, :topic => 2, :post => 6, :message => "Hello World", :result => true
|
39
|
+
}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should fail posting a message" do
|
44
|
+
VCR.use_cassette('phpbb2-should-not-post', :record => :new_episodes) do
|
45
|
+
conf = self.sample_phpbb2_config_params(
|
46
|
+
:app_root => 'http://localhost/phpbb2/',
|
47
|
+
:sleep_before_post => 1
|
48
|
+
)
|
49
|
+
impostor = Impostor.new(conf)
|
50
|
+
lambda {
|
51
|
+
impostor.post(forum=99, topic=99, message='Hello World')
|
52
|
+
}.should raise_error( Impostor::PostError )
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should fail posting a message because of over limit" do
|
57
|
+
VCR.use_cassette('phpbb2-should-overlimit-error-post', :record => :new_episodes) do
|
58
|
+
conf = self.sample_phpbb2_config_params(
|
59
|
+
:app_root => 'http://localhost/phpbb2/',
|
60
|
+
:sleep_before_post => 1
|
61
|
+
)
|
62
|
+
impostor = Impostor.new(conf)
|
63
|
+
lambda {
|
64
|
+
impostor.post(forum=1, topic=2, message='one')
|
65
|
+
impostor.post(forum=1, topic=2, message='two')
|
66
|
+
}.should raise_error( Impostor::ThrottledError )
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should create a new topic and message" do
|
71
|
+
VCR.use_cassette('phpbb2-should-create-topic', :record => :new_episodes) do
|
72
|
+
conf = self.sample_phpbb2_config_params(
|
73
|
+
:app_root => 'http://localhost/phpbb2/',
|
74
|
+
:sleep_before_post => 1
|
75
|
+
)
|
76
|
+
impostor = Impostor.new(conf)
|
77
|
+
impostor.new_topic(forum=1, subject='Teapots', message='Hello World').should == {
|
78
|
+
:forum => 1, :topic => 6, :subject => 'Teapots', :message => "Hello World", :result => true
|
79
|
+
}
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should fail creating a topic" do
|
84
|
+
VCR.use_cassette('phpbb2-should-not-create-new-topic', :record => :new_episodes) do
|
85
|
+
conf = self.sample_phpbb2_config_params(
|
86
|
+
:app_root => 'http://localhost/phpbb2/',
|
87
|
+
:sleep_before_post => 1
|
88
|
+
)
|
89
|
+
impostor = Impostor.new(conf)
|
90
|
+
lambda {
|
91
|
+
impostor.new_topic(forum=99, subject='Break Dance', message='Should not create new topic')
|
92
|
+
}.should raise_error( Impostor::TopicError )
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should fail create topic because of over limit" do
|
97
|
+
VCR.use_cassette('phpbb2-should-be-overlimit-creating-topic', :record => :new_episodes) do
|
98
|
+
conf = self.sample_phpbb2_config_params(
|
99
|
+
:app_root => 'http://localhost/phpbb2/',
|
100
|
+
:sleep_before_post => 1
|
101
|
+
)
|
102
|
+
impostor = Impostor.new(conf)
|
103
|
+
lambda {
|
104
|
+
impostor.new_topic(forum=1, subject='First', message='a message')
|
105
|
+
impostor.new_topic(forum=1, subject='Second', message='should fail')
|
106
|
+
}.should raise_error( Impostor::ThrottledError )
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'integration_spec_helper')
|
2
|
+
|
3
|
+
describe "a phpbb3 impostor" do
|
4
|
+
|
5
|
+
it "should login" do
|
6
|
+
VCR.use_cassette('phpbb3-should-login', :record => :new_episodes) do
|
7
|
+
conf = self.sample_phpbb3_config_params(
|
8
|
+
:app_root => 'http://localhost/phpbb3/'
|
9
|
+
)
|
10
|
+
config = Impostor::Config.new(conf)
|
11
|
+
auth = Impostor::Auth.new(config)
|
12
|
+
auth.login.should be_true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should fail login" do
|
17
|
+
VCR.use_cassette('phpbb3-should-not-login', :record => :new_episodes) do
|
18
|
+
conf = self.sample_phpbb3_config_params(
|
19
|
+
:app_root => 'http://localhost/phpbb3/',
|
20
|
+
:password => 'junk'
|
21
|
+
)
|
22
|
+
config = Impostor::Config.new(conf)
|
23
|
+
auth = Impostor::Auth.new(config)
|
24
|
+
auth.login.should_not be_true
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should post a message" do
|
29
|
+
VCR.use_cassette('phpbb3-should-post', :record => :new_episodes) do
|
30
|
+
conf = self.sample_phpbb3_config_params(
|
31
|
+
:app_root => 'http://localhost/phpbb3/',
|
32
|
+
:sleep_before_post => 1
|
33
|
+
)
|
34
|
+
impostor = Impostor.new(conf)
|
35
|
+
impostor.post(forum=2, topic=3, message='Hello World Again').should == {
|
36
|
+
:forum => 2, :topic => 3, :post => 17, :message => "Hello World Again", :result => true
|
37
|
+
}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should fail posting a message" do
|
42
|
+
VCR.use_cassette('phpbb3-should-not-post', :record => :new_episodes) do
|
43
|
+
conf = self.sample_phpbb3_config_params(
|
44
|
+
:app_root => 'http://localhost/phpbb3/',
|
45
|
+
:sleep_before_post => 1
|
46
|
+
)
|
47
|
+
impostor = Impostor.new(conf)
|
48
|
+
lambda {
|
49
|
+
impostor.post(forum=99, topic=99, message='Hello World')
|
50
|
+
}.should raise_error( Impostor::PostError )
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should fail posting a message because of over limit" do
|
55
|
+
VCR.use_cassette('phpbb3-should-overlimit-error-post', :record => :new_episodes) do
|
56
|
+
conf = self.sample_phpbb3_config_params(
|
57
|
+
:app_root => 'http://localhost/phpbb3/',
|
58
|
+
:sleep_before_post => 1
|
59
|
+
)
|
60
|
+
impostor = Impostor.new(conf)
|
61
|
+
lambda {
|
62
|
+
impostor.post(forum=2, topic=3, message='one')
|
63
|
+
impostor.post(forum=2, topic=3, message='two')
|
64
|
+
}.should raise_error( Impostor::ThrottledError )
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should create a new topic and message" do
|
69
|
+
VCR.use_cassette('phpbb3-should-create-topic', :record => :new_episodes) do
|
70
|
+
conf = self.sample_phpbb3_config_params(
|
71
|
+
:app_root => 'http://localhost/phpbb3/',
|
72
|
+
:sleep_before_post => 1
|
73
|
+
)
|
74
|
+
impostor = Impostor.new(conf)
|
75
|
+
impostor.new_topic(forum=2, subject='A Special Message', message='Hello World').should == {
|
76
|
+
:forum => 2, :topic => 8, :subject => 'A Special Message', :message => "Hello World", :result => true
|
77
|
+
}
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should fail creating a topic" do
|
82
|
+
VCR.use_cassette('phpbb3-should-not-create-new-topic', :record => :new_episodes) do
|
83
|
+
conf = self.sample_phpbb3_config_params(
|
84
|
+
:app_root => 'http://localhost/phpbb3/',
|
85
|
+
:sleep_before_post => 1
|
86
|
+
)
|
87
|
+
impostor = Impostor.new(conf)
|
88
|
+
lambda {
|
89
|
+
impostor.new_topic(forum=99, subject='Break Dance', message='Should not create new topic')
|
90
|
+
}.should raise_error( Impostor::TopicError )
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should fail create topic because of over limit" do
|
95
|
+
VCR.use_cassette('phpbb3-should-be-overlimit-creating-topic', :record => :new_episodes) do
|
96
|
+
conf = self.sample_phpbb3_config_params(
|
97
|
+
:app_root => 'http://localhost/phpbb3/',
|
98
|
+
:sleep_before_post => 1
|
99
|
+
)
|
100
|
+
impostor = Impostor.new(conf)
|
101
|
+
lambda {
|
102
|
+
impostor.new_topic(forum=2, subject='First', message='a message')
|
103
|
+
impostor.new_topic(forum=2, subject='Second', message='should fail')
|
104
|
+
}.should raise_error( Impostor::ThrottledError )
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|