Rafa_F
September 6, 2013, 10:43am
1
Hi,
I am having an issue with this code[1].
Testing in cucumber if there is no parameter :shot breaks. Somehow the
shout parameter it’s returning the whole params hash. This thing
happens everytime when the parameter has the same name as the
controller.
There are any conventions or something?
You can find my cucumber output at [2].
[1] https://github.com/otzy007/params-bug[1]
[2] http://showterm.io/ff7e3cdff6d69f4ab3308[2]
Andrei
On Sep 5, 2013, at 2:50 AM, Andrei G [email protected] wrote:
Andrei
So, looking at this error message:
Then the JSON response should have “errors” with the text “No shout
message” # cucumber-api-steps-0.10/lib/cucumber/api_st
eps.rb:48
expected [“Done”] to include “No shout message”
(RSpec::Expectations::ExpectationNotMetError)
features/shout.feature:25:in `Then the JSON response should have
“errors” with the text “No shout message”’
I don’t see why it would be looking for [“Done”] on the other hand, I
can’t see your step definitions.
On Sep 6, 2013, at 11:08 AM, Tamara T. [email protected]
wrote:
There are any conventions or something?
Then the JSON response should have “errors” with the text “No shout message” #
cucumber-api-steps-0.10/lib/cucumber/api_st
eps.rb:48
expected [“Done”] to include “No shout message”
(RSpec::Expectations::ExpectationNotMetError)
features/shout.feature:25:in `Then the JSON response should have “errors”
with the text “No shout message”’
I don’t see why it would be looking for [“Done”] on the other hand, I can’t
see your step definitions.
No, nevermind, I see what is happening. I can’t explain why, necessarily. I’m
digging deeper.
Gah. I can’t reproduce your problem:
log
12:08:04 - INFO - Running: spec/controllers/shout_controller_spec.rb
12:08:08 test_log.1 | Connecting to database specified by database.yml
12:08:09 guard.1 |
12:08:09 guard.1 | ShoutController
12:08:09 guard.1 | POST 'create'
12:08:09 test_log.1 | (0.3ms) begin transaction
12:08:09 test_log.1 | Processing by ShoutController#create as HTML
12:08:09 test_log.1 | Parameters: {"api_key"=>"aaa", "authentication_token"=>"bbbb", "shout"=>"GONZO!"}
12:08:09 test_log.1 | /Users/tamara/Projects/rubystuff/railsapps/my_newer_app/app/controllers/shout_controller.rb:3:in `create':
12:08:09 test_log.1 | Params: {"api_key"=>"aaa", "authentication_token"=>"bbbb", "shout"=>"GONZO!", "controller"=>"shout", "action"=>"create"}
This file has been truncated. show original
shout_controller.rb
class ShoutController < ApplicationController
def create
Rails.logger.debug [caller(0,1).first + ?:,
"Params: #{params}",
"Shout in params? #{params.key? :shout}",
"params[:shout] #{params[:shout]}"
].join("\n ")
unless params.key? :shout
Rails.logger.debug " we did not get the shout!"
render :json => { :errors => "we did not get the shout!", :params => params }, :status => :bad_request
This file has been truncated. show original
shout_controller_spec.rb
require 'spec_helper'
describe ShoutController do
describe "POST 'create'" do
it "should return successful with :shout" do
attr = {"api_key" => "aaa",
"authentication_token" => "bbbb",
"shout" => "GONZO!"}
post 'create', attr
This file has been truncated. show original
On Sep 6, 2013, at 10:49 AM, Tamara T. [email protected]
wrote:
[1] GitHub - otzy007/params-bug: ?????
features/shout.feature:25:in `Then the JSON response should have “errors”
with the text “No shout message”’
I don’t see why it would be looking for [“Done”] on the other hand, I can’t see
your step definitions.
No, nevermind, I see what is happening. I can’t explain why,
necessarily. I’m digging deeper.
On Friday 06 September 2013 12:22:08 Tamara T. wrote:
On Sep 6, 2013, at 11:08 AM, Tamara T. [email protected] wrote:
On Sep 6, 2013, at 10:49 AM, Tamara T. [email protected]
wrote:
[1] GitHub - otzy007/params-bug: ?????
(RSpec::Expectations::ExpectationNotMetError)
features/shout.feature:25:in `Then the JSON response should have
“errors” with the text “No shout message”'>>
I don’t see why it would be looking for [“Done”] on the other hand, I
can’t see your step definitions.>
No, nevermind, I see what is happening. I can’t explain why, necessarily.
I’m digging deeper.
Gah. I can’t reproduce your problem: Re: [Rails] Parameter with the same name as the controller returning the params hash instead of nil. I tried to reproduce the problem, but I am unable to. · GitHub
Your Rspec test works. Cucumber not
It might be a Cucumber bug?
On Sep 6, 2013, at 2:46 PM, Andrei G [email protected] wrote:
happens everytime when the parameter has the same name as the
Then the JSON response should have “errors” with the text "No shout
Gah. I can’t reproduce your problem: Re: [Rails] Parameter with the same name as the controller returning the params hash instead of nil. I tried to reproduce the problem, but I am unable to. · GitHub
Your Rspec test works. Cucumber not
It might be a Cucumber bug?
No idea - cuke is running the same stuff underneath. I didn’t see any
step definitions in your repo. Where are they defined?
On Friday 06 September 2013 18:57:02 Tamara T. wrote:
On Sep 6, 2013, at 2:46 PM, Andrei G [email protected] wrote:
On Friday 06 September 2013 12:22:08 Tamara T. wrote:
On Sep 6, 2013, at 11:08 AM, Tamara T. [email protected]
wrote:
controller. There are any conventions or something?
message" # cucumber-api-steps-0.10/lib/cucumber/api_st eps.rb:48
necessarily.
I’m digging deeper.
Gah. I can’t reproduce your problem:
Re: [Rails] Parameter with the same name as the controller returning the params hash instead of nil. I tried to reproduce the problem, but I am unable to. · GitHub >
Your Rspec test works. Cucumber not
It might be a Cucumber bug?
No idea - cuke is running the same stuff underneath. I didn’t see any step
definitions in your repo. Where are they defined?
I’m using cucumber-api-steps gem, but in the main app I’m not using them
and
still I have this problem.
api_steps.rb
Given /^I send and accept JSON$/ do
header 'Accept', 'application/json'
header 'Content-Type', 'application/json'
end
Given /the following API Keys exist/ do | keys |
keys.hashes.each do | k |
ApiKey.create! k
end
end
This file has been truncated. show original