kookaburra 0.18.3 → 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -1
- data/README.markdown +114 -135
- data/VERSION +1 -1
- data/kookaburra.gemspec +8 -10
- data/lib/kookaburra.rb +22 -31
- data/lib/kookaburra/api_driver.rb +95 -11
- data/lib/kookaburra/given_driver.rb +32 -16
- data/lib/kookaburra/json_api_driver.rb +43 -70
- data/lib/kookaburra/{test_data.rb → mental_model.rb} +15 -9
- data/lib/kookaburra/null_browser.rb +4 -0
- data/lib/kookaburra/test_helpers.rb +2 -4
- data/lib/kookaburra/ui_driver.rb +15 -11
- data/lib/kookaburra/ui_driver/ui_component.rb +22 -5
- data/spec/integration/test_a_rack_application_spec.rb +171 -137
- data/spec/kookaburra/api_driver_spec.rb +126 -0
- data/spec/kookaburra/json_api_driver_spec.rb +85 -30
- data/spec/kookaburra/{test_data_spec.rb → mental_model_spec.rb} +6 -6
- data/spec/kookaburra/ui_driver_spec.rb +5 -3
- data/spec/kookaburra_spec.rb +9 -41
- metadata +9 -11
- data/lib/kookaburra/rack_driver.rb +0 -109
- data/lib/kookaburra/utils/active_record_shared_connection.rb +0 -14
- data/spec/kookaburra/rack_driver_spec.rb +0 -42
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'active_record'
|
2
|
-
|
3
|
-
class ActiveRecord::Base
|
4
|
-
mattr_accessor :shared_connection
|
5
|
-
@@shared_connection = nil
|
6
|
-
|
7
|
-
def self.connection
|
8
|
-
@@shared_connection || retrieve_connection
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
# Forces all threads to share the same connection. This works on
|
13
|
-
# Capybara because it starts the web server in a thread.
|
14
|
-
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'kookaburra/rack_driver'
|
2
|
-
|
3
|
-
describe Kookaburra::RackDriver do
|
4
|
-
it 'has Rack::Test::Methods' do
|
5
|
-
Kookaburra::RackDriver.should include(Rack::Test::Methods)
|
6
|
-
end
|
7
|
-
|
8
|
-
{
|
9
|
-
'post' => {:success => 201, :unexpected => 200},
|
10
|
-
'put' => {:success => 200, :unexpected => 404},
|
11
|
-
'get' => {:success => 200, :unexpected => 404}
|
12
|
-
}.each_pair do |method, codes|
|
13
|
-
describe "##{method}" do
|
14
|
-
it 'returns the response body' do
|
15
|
-
app = stub('Rack App', :call => [codes[:success], {}, 'response body'])
|
16
|
-
driver = Kookaburra::RackDriver.new(app)
|
17
|
-
driver.send(method.to_sym, '/foo', 'req body').should == 'response body'
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'sets the specified headers on the request' do
|
21
|
-
app = mock('Rack App')
|
22
|
-
driver = Kookaburra::RackDriver.new(app)
|
23
|
-
app.should_receive(:call) do |env|
|
24
|
-
env['HTTP_HEADER_A'].should == 'foo'
|
25
|
-
env['HTTP_HEADER_B'].should == 'bar'
|
26
|
-
[codes[:success], {}, 'foo']
|
27
|
-
end
|
28
|
-
driver.send(method.to_sym, '/foo', 'req body', 'header-a' => 'foo', 'header-b' => 'bar')
|
29
|
-
end
|
30
|
-
|
31
|
-
it "raises a Kookabura::UnexpectedResponse if response status is not #{codes[:success]}" do
|
32
|
-
app_response = [codes[:unexpected], {'Content-Type' => 'application/json'}, 'Here is the response body']
|
33
|
-
app = stub('Rack App', :call => app_response)
|
34
|
-
driver = Kookaburra::RackDriver.new(app)
|
35
|
-
lambda { driver.send(method, '/foo', {:bar => :baz}) } \
|
36
|
-
.should raise_error(Kookaburra::UnexpectedResponse,
|
37
|
-
"#{method} to /foo unexpectedly responded with an HTTP status of #{codes[:unexpected]}:\n" \
|
38
|
-
+ 'Here is the response body')
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|