This repository has been archived by the owner on Sep 1, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chronicles module describes the API of the gem. == Addons * Chronicles#chronicles * Chronicles#start_chronicles * Chronicles#stop_chronicles
- Loading branch information
Showing
2 changed files
with
266 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
# encoding: utf-8 | ||
|
||
describe Chronicles do | ||
|
||
let(:test_class) do | ||
Class.new do | ||
include Chronicles | ||
|
||
attr_reader :foo | ||
|
||
protected | ||
|
||
attr_reader :bar | ||
|
||
private | ||
|
||
attr_reader :baz | ||
end | ||
end | ||
|
||
subject { test_class.new } | ||
|
||
describe "#chronicles" do | ||
|
||
it "returns an empty array" do | ||
expect(subject.chronicles).to eq [] | ||
end | ||
|
||
end # describe #chronicles | ||
|
||
describe "#start_chronicles" do | ||
|
||
context "by default" do | ||
|
||
before do | ||
subject.start_chronicles | ||
%i(foo bar baz foo).each(&subject.method(:send)) | ||
end | ||
|
||
it "starts looking for all methods" do | ||
expect(subject.chronicles).to eq %i(foo bar baz foo) | ||
end | ||
|
||
end # context | ||
|
||
context "public: false" do | ||
|
||
before do | ||
subject.start_chronicles public: false | ||
%i(foo bar baz foo).each(&subject.method(:send)) | ||
end | ||
|
||
it "starts looking for proper methods" do | ||
expect(subject.chronicles).to eq %i(bar baz) | ||
end | ||
|
||
end # context | ||
|
||
context "protected: false" do | ||
|
||
before do | ||
subject.start_chronicles protected: false | ||
%i(foo bar baz foo).each(&subject.method(:send)) | ||
end | ||
|
||
it "starts looking for proper methods" do | ||
expect(subject.chronicles).to eq %i(foo baz foo) | ||
end | ||
|
||
end # context | ||
|
||
context "private: false" do | ||
|
||
before do | ||
subject.start_chronicles private: false | ||
%i(foo bar baz foo).each(&subject.method(:send)) | ||
end | ||
|
||
it "starts looking for proper methods" do | ||
expect(subject.chronicles).to eq %i(foo bar foo) | ||
end | ||
|
||
end # context | ||
|
||
context "except: foo" do | ||
|
||
before do | ||
subject.start_chronicles except: :foo | ||
%i(foo bar baz foo).each(&subject.method(:send)) | ||
end | ||
|
||
it "starts looking for proper methods" do | ||
expect(subject.chronicles).to eq %i(bar baz) | ||
end | ||
|
||
end # context | ||
|
||
context "only: foo" do | ||
|
||
before do | ||
subject.start_chronicles only: :foo | ||
%i(foo bar baz foo).each(&subject.method(:send)) | ||
end | ||
|
||
it "starts looking for proper methods" do | ||
expect(subject.chronicles).to eq %i(foo foo) | ||
end | ||
|
||
end # context | ||
|
||
end # describe #start_chronicles | ||
|
||
describe "#stop_chronicles" do | ||
|
||
before { subject.start_chronicles } | ||
|
||
context "by default" do | ||
|
||
before do | ||
subject.stop_chronicles | ||
%i(foo bar baz foo).each(&subject.method(:send)) | ||
end | ||
|
||
it "stops looking for all methods" do | ||
expect(subject.chronicles).to eq [] | ||
end | ||
|
||
end # context | ||
|
||
context "public: false" do | ||
|
||
before do | ||
subject.stop_chronicles public: false | ||
%i(foo bar baz foo).each(&subject.method(:send)) | ||
end | ||
|
||
it "stops looking for proper methods" do | ||
expect(subject.chronicles).to eq %i(foo foo) | ||
end | ||
|
||
end # context | ||
|
||
context "protected: false" do | ||
|
||
before do | ||
subject.stop_chronicles protected: false | ||
%i(foo bar baz foo).each(&subject.method(:send)) | ||
end | ||
|
||
it "stops looking for proper methods" do | ||
expect(subject.chronicles).to eq %i(bar) | ||
end | ||
|
||
end # context | ||
|
||
context "private: false" do | ||
|
||
before do | ||
subject.stop_chronicles private: false | ||
%i(foo bar baz foo).each(&subject.method(:send)) | ||
end | ||
|
||
it "stops looking for proper methods" do | ||
expect(subject.chronicles).to eq %i(baz) | ||
end | ||
|
||
end # context | ||
|
||
context "except: foo" do | ||
|
||
before do | ||
subject.stop_chronicles except: :foo | ||
%i(foo bar baz foo).each(&subject.method(:send)) | ||
end | ||
|
||
it "stops looking for proper methods" do | ||
expect(subject.chronicles).to eq %i(foo foo) | ||
end | ||
|
||
end # context | ||
|
||
context "only: foo" do | ||
|
||
before do | ||
subject.stop_chronicles only: :foo | ||
%i(foo bar baz foo).each(&subject.method(:send)) | ||
end | ||
|
||
it "stops looking for proper methods" do | ||
expect(subject.chronicles).to eq %i(bar baz) | ||
end | ||
|
||
end # context | ||
|
||
end # describe #stop_chronicles | ||
|
||
end # describe Chronicles |