Sha256: 2e1ef26197e73d9bd293a67506db0d7d228ff4166755bea6fc6ddc940220df05
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
require 'spec_helper' describe WhowishWordController do it "adds a word correctly" do word_id = "test" content = "Hello#{Time.now}" post :change_word, { :word_id => word_id, :content => content } body = expect_json_response body['ok'].should be_true I18n.t(word_id.to_sym).should == content end context 'with successful set' do before do WhowishWord.backend.any_instance.should_receive(:set).and_return(true) end it 'returns ok: true' do post :change_word, { :word_id => 'hi1', :content => 'hi2' } response.body.should == '{"ok":true}' end end context 'with unsuccessful set' do before do WhowishWord.backend.any_instance.should_receive(:set).and_return(false) end it 'returns ok: false' do post :change_word, { :word_id => 'hi', :content => 'hi' } response.body.should == '{"ok":false}' end it 'returns status :unprocessable_entity' do post :change_word, { :word_id => 'hi', :content => 'hi' } response.status.should == 422 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
whowish_word-1.0.0 | rails/spec/controllers/whowish_word_controller_spec.rb |