Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Commit

Permalink
add spec for be_ok matcher.
Browse files Browse the repository at this point in the history
  • Loading branch information
tinsep19 committed May 23, 2015
1 parent 18d387c commit 368652c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 9 deletions.
12 changes: 3 additions & 9 deletions lib/chibineko/rspec/matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,10 @@
end

description do
"should be complete."
"should be passed."
end

failure_message do |actual|
if actual.execute?
# NG
"expected that #{actual.item} should be completed."
else
# 未実施
"expected that #{actual.item} should be executed."
end
"expected that #{actual.item} should be passed."
end
end
42 changes: 42 additions & 0 deletions spec/chibineko/rspec/matcher_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
require 'spec_helper'
require 'securerandom'
RSpec.describe :be_ok do
subject { be_ok }

let(:passed) do
item = double('passed')
allow(item).to receive(:ok?) { true }
item
end

let(:failed) do
item = double('failed')
item_desc = SecureRandom.uuid
allow(item).to receive(:ok?) { false }
allow(item).to receive(:execute?) { true }
allow(item).to receive(:item) { item_desc }
item
end

let(:not_started) do
item = double('not_started')
item_desc = SecureRandom.uuid
allow(item).to receive(:ok?) {false}
allow(item).to receive(:execute?) {false}
allow(item).to receive(:item) { item_desc }
item
end

its(:description) { should eq "should be passed." }
describe "match" do
it { expect(subject.matches?(passed)).to be_truthy }
it { expect(subject.matches?(failed)).to be_falsy }
it { expect(subject.matches?(not_started)).to be_falsy }
end

it "failure_message include testitem.item" do
subject.matches?(not_started)
expect(subject.failure_message).to include(not_started.item)
end

end

0 comments on commit 368652c

Please sign in to comment.