RSpec - A JSON text must at least contain two octets










0














Two failing specs after upgrading rspec-rails (2.5.2 -> 3.8.1) and capybara (2.18.0 -> 3.10.1):



Not really sure what's going on here. Looks like text in the expectation is being truncated?!?



 let(:story_attributes) do

title: 'Edited title',
description: 'Edited location',
start_year: '2001',
start_month: 'December',
start_day: '5',
end_year: '2001',
end_month: 'October',
end_day: '10',
is_range: true,
cover_image:
url: 'http://placehold.it/edited.png'


end

...

within 'section.story-cover' do
expect(page).to have_text 'Edited title'
expect(page).to have_text 'Edited location'
expect(page).to have_text 'December 5th - October 10th, 2001'
end


In first failed example (below) "Edited location" is being truncated.



In second example expect(page).to have_text 'Edited title Edited location' where only "Edited titlenEdited locat" is found.



Then there's this "JSON text must at least contain two octets" issue which may or may not be related but this used to pass before upgrading rspec-rails & capybara.ds



Thoughts?



RSpec Failures:

1) Story editing published edit story
Failure/Error: JSON.parse(response.body)

JSON::ParserError:
A JSON text must at least contain two octets!
# ./app/services/converter/image_service.rb:36:in `post_to_filepicker'
# ./app/services/converter/image_service.rb:18:in `convert_format'
# ./app/services/converter/image_service.rb:11:in `block in convert'
# ./app/services/converter/image_service.rb:10:in `each'
# ./app/services/converter/image_service.rb:10:in `convert'
# ./app/models/images/image.rb:5:in `convert'
# ./app/models/images/image.rb:20:in `enqueue_conversion'
# ./app/services/story/updating_service.rb:14:in `update'
# ./app/controllers/stories_controller.rb:58:in `update'
# ------------------
# --- Caused by: ---
# Capybara::ExpectationNotMet:
# expected to find text "Edited location" in "Edited titlenLyla HoegerEditedDecember 5th - October 10th, 2001Download"
# ./spec/features/stories/editing_spec.rb:86:in `block (4 levels) in <top (required)>'

2) Story editing private private story should be read after editing
Failure/Error: JSON.parse(response.body)

JSON::ParserError:
A JSON text must at least contain two octets!
# ./app/services/converter/image_service.rb:36:in `post_to_filepicker'
# ./app/services/converter/image_service.rb:18:in `convert_format'
# ./app/services/converter/image_service.rb:11:in `block in convert'
# ./app/services/converter/image_service.rb:10:in `each'
# ./app/services/converter/image_service.rb:10:in `convert'
# ./app/models/images/image.rb:5:in `convert'
# ./app/models/images/image.rb:20:in `enqueue_conversion'
# ./app/services/story/updating_service.rb:14:in `update'
# ./app/controllers/stories_controller.rb:58:in `update'
# ------------------
# --- Caused by: ---
# Capybara::ExpectationNotMet:
# expected to find text "Edited title Edited location" in "Edited titlenEdited locat"
# ./spec/features/stories/editing_spec.rb:115:in `block (4 levels) in <top (required)>'









share|improve this question























  • Please provide your specs and the related code, not everyone is familiarized with changes so specific between versions. Thank you!
    – byrdEmmanuel
    Nov 9 at 21:21










  • I added some more details but the expectation is pretty vanilla, in my opinion. Something else is going on, I think?!?
    – Meltemi
    Nov 9 at 22:00















0














Two failing specs after upgrading rspec-rails (2.5.2 -> 3.8.1) and capybara (2.18.0 -> 3.10.1):



Not really sure what's going on here. Looks like text in the expectation is being truncated?!?



 let(:story_attributes) do

title: 'Edited title',
description: 'Edited location',
start_year: '2001',
start_month: 'December',
start_day: '5',
end_year: '2001',
end_month: 'October',
end_day: '10',
is_range: true,
cover_image:
url: 'http://placehold.it/edited.png'


end

...

within 'section.story-cover' do
expect(page).to have_text 'Edited title'
expect(page).to have_text 'Edited location'
expect(page).to have_text 'December 5th - October 10th, 2001'
end


In first failed example (below) "Edited location" is being truncated.



In second example expect(page).to have_text 'Edited title Edited location' where only "Edited titlenEdited locat" is found.



Then there's this "JSON text must at least contain two octets" issue which may or may not be related but this used to pass before upgrading rspec-rails & capybara.ds



Thoughts?



RSpec Failures:

1) Story editing published edit story
Failure/Error: JSON.parse(response.body)

JSON::ParserError:
A JSON text must at least contain two octets!
# ./app/services/converter/image_service.rb:36:in `post_to_filepicker'
# ./app/services/converter/image_service.rb:18:in `convert_format'
# ./app/services/converter/image_service.rb:11:in `block in convert'
# ./app/services/converter/image_service.rb:10:in `each'
# ./app/services/converter/image_service.rb:10:in `convert'
# ./app/models/images/image.rb:5:in `convert'
# ./app/models/images/image.rb:20:in `enqueue_conversion'
# ./app/services/story/updating_service.rb:14:in `update'
# ./app/controllers/stories_controller.rb:58:in `update'
# ------------------
# --- Caused by: ---
# Capybara::ExpectationNotMet:
# expected to find text "Edited location" in "Edited titlenLyla HoegerEditedDecember 5th - October 10th, 2001Download"
# ./spec/features/stories/editing_spec.rb:86:in `block (4 levels) in <top (required)>'

2) Story editing private private story should be read after editing
Failure/Error: JSON.parse(response.body)

JSON::ParserError:
A JSON text must at least contain two octets!
# ./app/services/converter/image_service.rb:36:in `post_to_filepicker'
# ./app/services/converter/image_service.rb:18:in `convert_format'
# ./app/services/converter/image_service.rb:11:in `block in convert'
# ./app/services/converter/image_service.rb:10:in `each'
# ./app/services/converter/image_service.rb:10:in `convert'
# ./app/models/images/image.rb:5:in `convert'
# ./app/models/images/image.rb:20:in `enqueue_conversion'
# ./app/services/story/updating_service.rb:14:in `update'
# ./app/controllers/stories_controller.rb:58:in `update'
# ------------------
# --- Caused by: ---
# Capybara::ExpectationNotMet:
# expected to find text "Edited title Edited location" in "Edited titlenEdited locat"
# ./spec/features/stories/editing_spec.rb:115:in `block (4 levels) in <top (required)>'









share|improve this question























  • Please provide your specs and the related code, not everyone is familiarized with changes so specific between versions. Thank you!
    – byrdEmmanuel
    Nov 9 at 21:21










  • I added some more details but the expectation is pretty vanilla, in my opinion. Something else is going on, I think?!?
    – Meltemi
    Nov 9 at 22:00













0












0








0







Two failing specs after upgrading rspec-rails (2.5.2 -> 3.8.1) and capybara (2.18.0 -> 3.10.1):



Not really sure what's going on here. Looks like text in the expectation is being truncated?!?



 let(:story_attributes) do

title: 'Edited title',
description: 'Edited location',
start_year: '2001',
start_month: 'December',
start_day: '5',
end_year: '2001',
end_month: 'October',
end_day: '10',
is_range: true,
cover_image:
url: 'http://placehold.it/edited.png'


end

...

within 'section.story-cover' do
expect(page).to have_text 'Edited title'
expect(page).to have_text 'Edited location'
expect(page).to have_text 'December 5th - October 10th, 2001'
end


In first failed example (below) "Edited location" is being truncated.



In second example expect(page).to have_text 'Edited title Edited location' where only "Edited titlenEdited locat" is found.



Then there's this "JSON text must at least contain two octets" issue which may or may not be related but this used to pass before upgrading rspec-rails & capybara.ds



Thoughts?



RSpec Failures:

1) Story editing published edit story
Failure/Error: JSON.parse(response.body)

JSON::ParserError:
A JSON text must at least contain two octets!
# ./app/services/converter/image_service.rb:36:in `post_to_filepicker'
# ./app/services/converter/image_service.rb:18:in `convert_format'
# ./app/services/converter/image_service.rb:11:in `block in convert'
# ./app/services/converter/image_service.rb:10:in `each'
# ./app/services/converter/image_service.rb:10:in `convert'
# ./app/models/images/image.rb:5:in `convert'
# ./app/models/images/image.rb:20:in `enqueue_conversion'
# ./app/services/story/updating_service.rb:14:in `update'
# ./app/controllers/stories_controller.rb:58:in `update'
# ------------------
# --- Caused by: ---
# Capybara::ExpectationNotMet:
# expected to find text "Edited location" in "Edited titlenLyla HoegerEditedDecember 5th - October 10th, 2001Download"
# ./spec/features/stories/editing_spec.rb:86:in `block (4 levels) in <top (required)>'

2) Story editing private private story should be read after editing
Failure/Error: JSON.parse(response.body)

JSON::ParserError:
A JSON text must at least contain two octets!
# ./app/services/converter/image_service.rb:36:in `post_to_filepicker'
# ./app/services/converter/image_service.rb:18:in `convert_format'
# ./app/services/converter/image_service.rb:11:in `block in convert'
# ./app/services/converter/image_service.rb:10:in `each'
# ./app/services/converter/image_service.rb:10:in `convert'
# ./app/models/images/image.rb:5:in `convert'
# ./app/models/images/image.rb:20:in `enqueue_conversion'
# ./app/services/story/updating_service.rb:14:in `update'
# ./app/controllers/stories_controller.rb:58:in `update'
# ------------------
# --- Caused by: ---
# Capybara::ExpectationNotMet:
# expected to find text "Edited title Edited location" in "Edited titlenEdited locat"
# ./spec/features/stories/editing_spec.rb:115:in `block (4 levels) in <top (required)>'









share|improve this question















Two failing specs after upgrading rspec-rails (2.5.2 -> 3.8.1) and capybara (2.18.0 -> 3.10.1):



Not really sure what's going on here. Looks like text in the expectation is being truncated?!?



 let(:story_attributes) do

title: 'Edited title',
description: 'Edited location',
start_year: '2001',
start_month: 'December',
start_day: '5',
end_year: '2001',
end_month: 'October',
end_day: '10',
is_range: true,
cover_image:
url: 'http://placehold.it/edited.png'


end

...

within 'section.story-cover' do
expect(page).to have_text 'Edited title'
expect(page).to have_text 'Edited location'
expect(page).to have_text 'December 5th - October 10th, 2001'
end


In first failed example (below) "Edited location" is being truncated.



In second example expect(page).to have_text 'Edited title Edited location' where only "Edited titlenEdited locat" is found.



Then there's this "JSON text must at least contain two octets" issue which may or may not be related but this used to pass before upgrading rspec-rails & capybara.ds



Thoughts?



RSpec Failures:

1) Story editing published edit story
Failure/Error: JSON.parse(response.body)

JSON::ParserError:
A JSON text must at least contain two octets!
# ./app/services/converter/image_service.rb:36:in `post_to_filepicker'
# ./app/services/converter/image_service.rb:18:in `convert_format'
# ./app/services/converter/image_service.rb:11:in `block in convert'
# ./app/services/converter/image_service.rb:10:in `each'
# ./app/services/converter/image_service.rb:10:in `convert'
# ./app/models/images/image.rb:5:in `convert'
# ./app/models/images/image.rb:20:in `enqueue_conversion'
# ./app/services/story/updating_service.rb:14:in `update'
# ./app/controllers/stories_controller.rb:58:in `update'
# ------------------
# --- Caused by: ---
# Capybara::ExpectationNotMet:
# expected to find text "Edited location" in "Edited titlenLyla HoegerEditedDecember 5th - October 10th, 2001Download"
# ./spec/features/stories/editing_spec.rb:86:in `block (4 levels) in <top (required)>'

2) Story editing private private story should be read after editing
Failure/Error: JSON.parse(response.body)

JSON::ParserError:
A JSON text must at least contain two octets!
# ./app/services/converter/image_service.rb:36:in `post_to_filepicker'
# ./app/services/converter/image_service.rb:18:in `convert_format'
# ./app/services/converter/image_service.rb:11:in `block in convert'
# ./app/services/converter/image_service.rb:10:in `each'
# ./app/services/converter/image_service.rb:10:in `convert'
# ./app/models/images/image.rb:5:in `convert'
# ./app/models/images/image.rb:20:in `enqueue_conversion'
# ./app/services/story/updating_service.rb:14:in `update'
# ./app/controllers/stories_controller.rb:58:in `update'
# ------------------
# --- Caused by: ---
# Capybara::ExpectationNotMet:
# expected to find text "Edited title Edited location" in "Edited titlenEdited locat"
# ./spec/features/stories/editing_spec.rb:115:in `block (4 levels) in <top (required)>'






ruby-on-rails json rspec capybara rspec-rails






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 9 at 21:52

























asked Nov 9 at 21:19









Meltemi

21k42169257




21k42169257











  • Please provide your specs and the related code, not everyone is familiarized with changes so specific between versions. Thank you!
    – byrdEmmanuel
    Nov 9 at 21:21










  • I added some more details but the expectation is pretty vanilla, in my opinion. Something else is going on, I think?!?
    – Meltemi
    Nov 9 at 22:00
















  • Please provide your specs and the related code, not everyone is familiarized with changes so specific between versions. Thank you!
    – byrdEmmanuel
    Nov 9 at 21:21










  • I added some more details but the expectation is pretty vanilla, in my opinion. Something else is going on, I think?!?
    – Meltemi
    Nov 9 at 22:00















Please provide your specs and the related code, not everyone is familiarized with changes so specific between versions. Thank you!
– byrdEmmanuel
Nov 9 at 21:21




Please provide your specs and the related code, not everyone is familiarized with changes so specific between versions. Thank you!
– byrdEmmanuel
Nov 9 at 21:21












I added some more details but the expectation is pretty vanilla, in my opinion. Something else is going on, I think?!?
– Meltemi
Nov 9 at 22:00




I added some more details but the expectation is pretty vanilla, in my opinion. Something else is going on, I think?!?
– Meltemi
Nov 9 at 22:00












1 Answer
1






active

oldest

votes


















1














One of the big changes between Capybara 2.x and 3.x was that in Capybara 3.x text is returned as closely to what is displayed as possible. This means that line feeds are now included in the returned text when they would display to the user - https://github.com/teamcapybara/capybara/blob/master/UPGRADING.md. You either need to change your expected text to "Edited titlenEdited location" at spec/features/stories/editing_spec.rb:115 or if you don't care about the linefeeds you can use the :normalize_ws option => expect(page).to have_text("Edited title Edited location", normalize_ws: true)






share|improve this answer




















  • This is great! Thanks! Where is the definitive source for documentation for using RSpec & Capybara? I never would have found normalize_ws in my searching for a solution to this problem.
    – Meltemi
    Nov 9 at 22:59







  • 1




    The docs - rubydoc.info/github/teamcapybara/capybara are the best source for info - and the History.md file for a list of the changes. There's a gitter page linked from the github for discussing things or just post here and someone will answer within a reasonable time.
    – Thomas Walpole
    Nov 9 at 23:53










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53233401%2frspec-a-json-text-must-at-least-contain-two-octets%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














One of the big changes between Capybara 2.x and 3.x was that in Capybara 3.x text is returned as closely to what is displayed as possible. This means that line feeds are now included in the returned text when they would display to the user - https://github.com/teamcapybara/capybara/blob/master/UPGRADING.md. You either need to change your expected text to "Edited titlenEdited location" at spec/features/stories/editing_spec.rb:115 or if you don't care about the linefeeds you can use the :normalize_ws option => expect(page).to have_text("Edited title Edited location", normalize_ws: true)






share|improve this answer




















  • This is great! Thanks! Where is the definitive source for documentation for using RSpec & Capybara? I never would have found normalize_ws in my searching for a solution to this problem.
    – Meltemi
    Nov 9 at 22:59







  • 1




    The docs - rubydoc.info/github/teamcapybara/capybara are the best source for info - and the History.md file for a list of the changes. There's a gitter page linked from the github for discussing things or just post here and someone will answer within a reasonable time.
    – Thomas Walpole
    Nov 9 at 23:53















1














One of the big changes between Capybara 2.x and 3.x was that in Capybara 3.x text is returned as closely to what is displayed as possible. This means that line feeds are now included in the returned text when they would display to the user - https://github.com/teamcapybara/capybara/blob/master/UPGRADING.md. You either need to change your expected text to "Edited titlenEdited location" at spec/features/stories/editing_spec.rb:115 or if you don't care about the linefeeds you can use the :normalize_ws option => expect(page).to have_text("Edited title Edited location", normalize_ws: true)






share|improve this answer




















  • This is great! Thanks! Where is the definitive source for documentation for using RSpec & Capybara? I never would have found normalize_ws in my searching for a solution to this problem.
    – Meltemi
    Nov 9 at 22:59







  • 1




    The docs - rubydoc.info/github/teamcapybara/capybara are the best source for info - and the History.md file for a list of the changes. There's a gitter page linked from the github for discussing things or just post here and someone will answer within a reasonable time.
    – Thomas Walpole
    Nov 9 at 23:53













1












1








1






One of the big changes between Capybara 2.x and 3.x was that in Capybara 3.x text is returned as closely to what is displayed as possible. This means that line feeds are now included in the returned text when they would display to the user - https://github.com/teamcapybara/capybara/blob/master/UPGRADING.md. You either need to change your expected text to "Edited titlenEdited location" at spec/features/stories/editing_spec.rb:115 or if you don't care about the linefeeds you can use the :normalize_ws option => expect(page).to have_text("Edited title Edited location", normalize_ws: true)






share|improve this answer












One of the big changes between Capybara 2.x and 3.x was that in Capybara 3.x text is returned as closely to what is displayed as possible. This means that line feeds are now included in the returned text when they would display to the user - https://github.com/teamcapybara/capybara/blob/master/UPGRADING.md. You either need to change your expected text to "Edited titlenEdited location" at spec/features/stories/editing_spec.rb:115 or if you don't care about the linefeeds you can use the :normalize_ws option => expect(page).to have_text("Edited title Edited location", normalize_ws: true)







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 9 at 22:42









Thomas Walpole

29.8k32647




29.8k32647











  • This is great! Thanks! Where is the definitive source for documentation for using RSpec & Capybara? I never would have found normalize_ws in my searching for a solution to this problem.
    – Meltemi
    Nov 9 at 22:59







  • 1




    The docs - rubydoc.info/github/teamcapybara/capybara are the best source for info - and the History.md file for a list of the changes. There's a gitter page linked from the github for discussing things or just post here and someone will answer within a reasonable time.
    – Thomas Walpole
    Nov 9 at 23:53
















  • This is great! Thanks! Where is the definitive source for documentation for using RSpec & Capybara? I never would have found normalize_ws in my searching for a solution to this problem.
    – Meltemi
    Nov 9 at 22:59







  • 1




    The docs - rubydoc.info/github/teamcapybara/capybara are the best source for info - and the History.md file for a list of the changes. There's a gitter page linked from the github for discussing things or just post here and someone will answer within a reasonable time.
    – Thomas Walpole
    Nov 9 at 23:53















This is great! Thanks! Where is the definitive source for documentation for using RSpec & Capybara? I never would have found normalize_ws in my searching for a solution to this problem.
– Meltemi
Nov 9 at 22:59





This is great! Thanks! Where is the definitive source for documentation for using RSpec & Capybara? I never would have found normalize_ws in my searching for a solution to this problem.
– Meltemi
Nov 9 at 22:59





1




1




The docs - rubydoc.info/github/teamcapybara/capybara are the best source for info - and the History.md file for a list of the changes. There's a gitter page linked from the github for discussing things or just post here and someone will answer within a reasonable time.
– Thomas Walpole
Nov 9 at 23:53




The docs - rubydoc.info/github/teamcapybara/capybara are the best source for info - and the History.md file for a list of the changes. There's a gitter page linked from the github for discussing things or just post here and someone will answer within a reasonable time.
– Thomas Walpole
Nov 9 at 23:53

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53233401%2frspec-a-json-text-must-at-least-contain-two-octets%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)