|
1 | 1 | require_relative 'spec_helper'
|
2 | 2 |
|
| 3 | +describe Object do |
| 4 | + describe "#marked_fixme?" do |
| 5 | + subject { Object.new.marked_fixme? } |
| 6 | + it { should be_false } |
| 7 | + end |
| 8 | + |
| 9 | + describe "#append!" do |
| 10 | + before { @object = Object.new.append!("somestring") } |
| 11 | + subject { @object } |
| 12 | + it { should eq @object } |
| 13 | + end |
| 14 | + |
| 15 | + describe "#mark_fixme!" do |
| 16 | + before { @object = Object.new.mark_fixme! } |
| 17 | + subject { @object } |
| 18 | + it { should eq @object } |
| 19 | + end |
| 20 | +end |
| 21 | + |
3 | 22 | describe Array do
|
4 |
| - it "extracts options" do |
5 |
| - a = [1, 2, 3, 4, { option: true, option2: false }] |
6 |
| - a.extract_options!.should eql({ option: true, option2: false }) |
7 |
| - a.should eql([1,2,3,4]) |
| 23 | + describe "#extract_options!" do |
| 24 | + subject { [1, 2, 3, 4, options].extract_options! } |
| 25 | + |
| 26 | + context "when contains options" do |
| 27 | + let(:options) { { option: true, option2: false } } |
| 28 | + it { should eq options } |
| 29 | + end |
| 30 | + |
| 31 | + context "when contains no options" do |
| 32 | + let(:options) { nil } |
| 33 | + it { should be_empty } |
| 34 | + end |
| 35 | + end |
| 36 | + |
| 37 | + describe "#append!" do |
| 38 | + subject { ["hello", "world"].append!("appended_string") } |
| 39 | + it { should eq ["helloappended_string", "worldappended_string"] } |
| 40 | + end |
| 41 | + |
| 42 | + describe "#mark_fixme!" do |
| 43 | + subject { ["Hello", 1, 2, 3, "String"].mark_fixme! } |
| 44 | + it { should eq ["Hello g FIXME", 1, 2, 3, "String g FIXME"] } |
| 45 | + end |
| 46 | +end |
| 47 | + |
| 48 | +describe String do |
| 49 | + describe "#marked_fixme?" do |
| 50 | + subject { "Hello#{suffix}".marked_fixme? } |
| 51 | + |
| 52 | + context "when marked fixme" do |
| 53 | + let(:suffix) { "g FIXME" } |
| 54 | + it { should be_true } |
| 55 | + end |
8 | 56 |
|
9 |
| - a.extract_options!.should eql({}) |
10 |
| - a.should eql([1,2,3,4]) |
| 57 | + context "when not marked fixme" do |
| 58 | + let(:suffix) { "" } |
| 59 | + it { should be_false } |
| 60 | + end |
11 | 61 | end
|
12 | 62 |
|
13 |
| - it "appends" do |
14 |
| - a = ["hello", "world"] |
| 63 | + describe "#mark_fixme!" do |
| 64 | + subject { "Hello #{suffix}".mark_fixme! } |
| 65 | + |
| 66 | + context "already marked fixme" do |
| 67 | + let(:suffix) { "g FIXME" } |
| 68 | + it { should eq "Hello g FIXME" } |
| 69 | + end |
| 70 | + |
| 71 | + context "not marked yet" do |
| 72 | + let(:suffix) { "" } |
| 73 | + it { should eq "Hello g FIXME" } |
| 74 | + end |
| 75 | + end |
15 | 76 |
|
16 |
| - a.append!("appended_string") |
| 77 | + describe "#append!" do |
| 78 | + subject { "#{string}".append!("hello") } |
| 79 | + context "empty" do |
| 80 | + let(:string) { "" } |
| 81 | + it { should be_empty } |
| 82 | + end |
17 | 83 |
|
18 |
| - a.should eql(["helloappended_string", "worldappended_string"]) |
| 84 | + context "any other string" do |
| 85 | + let(:string) { "helloworld" } |
| 86 | + it { should eq "helloworldhello" } |
| 87 | + end |
19 | 88 | end
|
20 | 89 | end
|
21 | 90 |
|
|
152 | 221 |
|
153 | 222 | hash2.deep_delete_unused!(hash1).should eql(hash1)
|
154 | 223 | end
|
155 |
| - |
156 |
| - describe String do |
157 |
| - it "marks fixme" do |
158 |
| - "Hello".mark_fixme!.should eql("Hello g FIXME") |
159 |
| - |
160 |
| - "Hello g FIXME".mark_fixme!.should eql("Hello g FIXME") |
161 |
| - end |
162 |
| - end |
163 | 224 | end
|
0 commit comments