Sha256: 5589c7d6fac79a79fbf81721e451ab84a63898894f79ba8ea109e5f01cc5c106
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
# encoding: utf-8 require "spec_helper" module Okei describe Word do describe "#synonym=" do subject(:word) { Word.new } it "sets #synonym" do value = "МЕТР" expect { word.synonym = value }.to change { word.synonym }.to value end end describe "#text=" do subject(:word) { Word.new } it "sets #text" do value = "М" expect { word.text = value }.to change { word.text }.to value end end describe "#valid?" do subject(:word) { build :word } before { expect(word).to be_valid } it "fails when #synonym is absent" do word.synonym = "" expect(word).not_to be_valid end it "fails when #synonym is taken" do create :word, synonym: word.synonym expect(word).not_to be_valid end it "fails when #text is absent" do word.text = "" expect(word).not_to be_valid end it "passes when #text is taken" do create :word, text: word.text expect(word).to be_valid end end describe ".translate" do let!(:line) { "ТЕКСТ" } context "when word exists" do let!(:word) { create :word, synonym: line } it "translates line" do expect(Word.translate line).to eq word.text end end context "when word is absent" do it "returns the source" do expect(Word.translate line).to eq line end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
okei-0.0.2 | spec/models/okei/word_spec.rb |