Created
September 18, 2012 23:29
-
-
Save oestrich/3746709 to your computer and use it in GitHub Desktop.
Failing OAuth2 feature for rspec_api_documentation pr #51
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: Use OAuth2 MAC client as a test client | |
Background: | |
Given a file named "app_spec.rb" with: | |
""" | |
require "rspec_api_documentation" | |
require "rspec_api_documentation/dsl" | |
require "rack/builder" | |
RspecApiDocumentation.configure do |config| | |
config.app = Rack::Builder.new do | |
map "/oauth2/token" do | |
app = lambda do |env| | |
headers = {"Pragma"=>"no-cache", "Content-Type"=>"application/json", "Content-Length"=>"274", "Cache-Control"=>"no-store"} | |
body = ["{\"mac_algorithm\":\"hmac-sha-256\",\"expires_in\":29,\"access_token\":\"HfIBIMe/hxNKSMogD33OJmLN+i9x3d2iM7WLzrN1RQvINOFz+QT8hiMiY+avbp2mc8IpzrxoupHyy0DeKuB05Q==\",\"token_type\":\"mac\",\"mac_key\":\"jb59zUztvDIC0AeaNZz+BptWvmFd4C41JyZS1DfWqKCkZTErxSMfkdjkePUcpE9/joqFt0ELyV/oIsFAf0V1ew==\"}"] | |
[200, headers, body] | |
end | |
run app | |
end | |
map "/" do | |
app = lambda do |env| | |
if env["HTTP_AUTHORIZATION"].blank? | |
return [401, {"Content-Type" => "text/plain"}, [""]] | |
end | |
request = Rack::Request.new(env) | |
response = Rack::Response.new | |
response["Content-Type"] = "text/plain" | |
response.write("hello #{request.params["target"]}") | |
response.finish | |
end | |
run app | |
end | |
map "/multiple" do | |
app = lambda do |env| | |
if env["HTTP_AUTHORIZATION"].blank? | |
return [401, {"Content-Type" => "text/plain"}, [""]] | |
end | |
request = Rack::Request.new(env) | |
response = Rack::Response.new | |
response["Content-Type"] = "text/plain" | |
response.write("hello #{request.params["targets"].join(", ")}") | |
response.finish | |
end | |
run app | |
end | |
end | |
end | |
resource "Greetings" do | |
let(:client) { RspecApiDocumentation::OAuth2MACClient.new(self, {:identifier => "1", :secret => "secret"}) } | |
get "/" do | |
parameter :target, "The thing you want to greet" | |
example "Greeting your favorite gem" do | |
do_request :target => "rspec_api_documentation" | |
response_headers["Content-Type"].should eq("text/plain") | |
status.should eq(200) | |
response_body.should eq('hello rspec_api_documentation') | |
end | |
end | |
get "/multiple" do | |
parameter :targets, "The people you want to greet" | |
let(:targets) { ["eric", "sam"] } | |
example "Greeting your favorite people" do | |
do_request | |
response_headers["Content-Type"].should eq("text/plain") | |
status.should eq(200) | |
response_body.should eq("hello eric, sam") | |
end | |
end | |
end | |
""" | |
When I run `rspec app_spec.rb --format RspecApiDocumentation::ApiFormatter` | |
Scenario: Output should contain | |
Then the output should contain: | |
""" | |
Generating API Docs | |
Greetings | |
GET / | |
* Greeting your favorite gem | |
""" | |
And the output should contain "1 example, 0 failures" | |
And the exit status should be 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: Use OAuth2 MAC client as a test client | |
Background: # features/oauth2_mac_client.feature:2 | |
Given a file named "app_spec.rb" with: # aruba-0.4.11/lib/aruba/cucumber.rb:15 | |
""" | |
require "rspec_api_documentation" | |
require "rspec_api_documentation/dsl" | |
require "rack/builder" | |
RspecApiDocumentation.configure do |config| | |
config.app = Rack::Builder.new do | |
map "/oauth2/token" do | |
app = lambda do |env| | |
headers = {"Pragma"=>"no-cache", "Content-Type"=>"application/json", "Content-Length"=>"274", "Cache-Control"=>"no-store"} | |
body = ["{\"mac_algorithm\":\"hmac-sha-256\",\"expires_in\":29,\"access_token\":\"HfIBIMe/hxNKSMogD33OJmLN+i9x3d2iM7WLzrN1RQvINOFz+QT8hiMiY+avbp2mc8IpzrxoupHyy0DeKuB05Q==\",\"token_type\":\"mac\",\"mac_key\":\"jb59zUztvDIC0AeaNZz+BptWvmFd4C41JyZS1DfWqKCkZTErxSMfkdjkePUcpE9/joqFt0ELyV/oIsFAf0V1ew==\"}"] | |
[200, headers, body] | |
end | |
run app | |
end | |
map "/" do | |
app = lambda do |env| | |
if env["HTTP_AUTHORIZATION"].blank? | |
return [401, {"Content-Type" => "text/plain"}, [""]] | |
end | |
request = Rack::Request.new(env) | |
response = Rack::Response.new | |
response["Content-Type"] = "text/plain" | |
response.write("hello #{request.params["target"]}") | |
response.finish | |
end | |
run app | |
end | |
map "/multiple" do | |
app = lambda do |env| | |
if env["HTTP_AUTHORIZATION"].blank? | |
return [401, {"Content-Type" => "text/plain"}, [""]] | |
end | |
request = Rack::Request.new(env) | |
response = Rack::Response.new | |
response["Content-Type"] = "text/plain" | |
response.write("hello #{request.params["targets"].join(", ")}") | |
response.finish | |
end | |
run app | |
end | |
end | |
end | |
resource "Greetings" do | |
let(:client) { RspecApiDocumentation::OAuth2MACClient.new(self, {:identifier => "1", :secret => "secret"}) } | |
get "/" do | |
parameter :target, "The thing you want to greet" | |
example "Greeting your favorite gem" do | |
do_request :target => "rspec_api_documentation" | |
response_headers["Content-Type"].should eq("text/plain") | |
status.should eq(200) | |
response_body.should eq('hello rspec_api_documentation') | |
end | |
end | |
get "/multiple" do | |
parameter :targets, "The people you want to greet" | |
let(:targets) { ["eric", "sam"] } | |
example "Greeting your favorite people" do | |
do_request | |
response_headers["Content-Type"].should eq("text/plain") | |
status.should eq(200) | |
response_body.should eq("hello eric, sam") | |
end | |
end | |
end | |
""" | |
When I run `rspec app_spec.rb --format RspecApiDocumentation::ApiFormatter` # aruba-0.4.11/lib/aruba/cucumber.rb:56 | |
Scenario: Output should contain # features/oauth2_mac_client.feature:87 | |
Then the output should contain: # aruba-0.4.11/lib/aruba/cucumber.rb:98 | |
""" | |
Generating API Docs | |
Greetings | |
GET / | |
* Greeting your favorite gem | |
""" | |
And the output should contain "1 example, 0 failures" # aruba-0.4.11/lib/aruba/cucumber.rb:82 | |
expected "Generating API Docs\n Greetings\n GET /\n * Greeting your favorite gem\n GET /multiple\n ! Greeting your favorite people (FAILED)\n\nFailures:\n\n 1) Greetings GET /multiple Greeting your favorite people\n Failure/Error: response.write(\"hello \#{request.params[\"targets\"].join(\", \")}\")\n NoMethodError:\n undefined method `join' for {\"0\"=>\"eric\", \"1\"=>\"sam\"}:Hash\n # ./app_spec.rb:42:in `block (4 levels) in <top (required)>'\n # /Users/eric/prog/src/rspec_api_documentation/lib/rspec_api_documentation/oauth2_mac_client.rb:52:in `call'\n # /Users/eric/prog/src/rspec_api_documentation/lib/rspec_api_documentation/oauth2_mac_client.rb:46:in `do_request'\n # /Users/eric/prog/src/rspec_api_documentation/lib/rspec_api_documentation/client_base.rb:31:in `process'\n # /Users/eric/prog/src/rspec_api_documentation/lib/rspec_api_documentation/client_base.rb:9:in `get'\n # /Users/eric/prog/src/rspec_api_documentation/lib/rspec_api_documentation/dsl/endpoint.rb:47:in `do_request'\n # ./app_spec.rb:72:in `block (3 levels) in <top (required)>'\n\nFinished in 0.3437 seconds\n2 examples, 1 failure\n\nFailed examples:\n\nrspec ./app_spec.rb:71 # Greetings GET /multiple Greeting your favorite people\n" to include "1 example, 0 failures" | |
Diff: | |
@@ -1,2 +1,28 @@ | |
-1 example, 0 failures | |
+Generating API Docs | |
+ Greetings | |
+ GET / | |
+ * Greeting your favorite gem | |
+ GET /multiple | |
+ ! Greeting your favorite people (FAILED) | |
+ | |
+Failures: | |
+ | |
+ 1) Greetings GET /multiple Greeting your favorite people | |
+ Failure/Error: response.write("hello #{request.params["targets"].join(", ")}") | |
+ NoMethodError: | |
+ undefined method `join' for {"0"=>"eric", "1"=>"sam"}:Hash | |
+ # ./app_spec.rb:42:in `block (4 levels) in <top (required)>' | |
+ # /Users/eric/prog/src/rspec_api_documentation/lib/rspec_api_documentation/oauth2_mac_client.rb:52:in `call' | |
+ # /Users/eric/prog/src/rspec_api_documentation/lib/rspec_api_documentation/oauth2_mac_client.rb:46:in `do_request' | |
+ # /Users/eric/prog/src/rspec_api_documentation/lib/rspec_api_documentation/client_base.rb:31:in `process' | |
+ # /Users/eric/prog/src/rspec_api_documentation/lib/rspec_api_documentation/client_base.rb:9:in `get' | |
+ # /Users/eric/prog/src/rspec_api_documentation/lib/rspec_api_documentation/dsl/endpoint.rb:47:in `do_request' | |
+ # ./app_spec.rb:72:in `block (3 levels) in <top (required)>' | |
+ | |
+Finished in 0.3437 seconds | |
+2 examples, 1 failure | |
+ | |
+Failed examples: | |
+ | |
+rspec ./app_spec.rb:71 # Greetings GET /multiple Greeting your favorite people | |
(RSpec::Expectations::ExpectationNotMetError) | |
features/oauth2_mac_client.feature:95:in `And the output should contain "1 example, 0 failures"' | |
And the exit status should be 0 # aruba-0.4.11/lib/aruba/cucumber.rb:126 | |
Failing Scenarios: | |
cucumber features/oauth2_mac_client.feature:87 # Scenario: Output should contain | |
1 scenario (1 failed) | |
5 steps (1 failed, 1 skipped, 3 passed) | |
0m0.931s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment