lib/policy/cli/spec.erb in policy-1.2.0 vs lib/policy/cli/spec.erb in policy-2.0.0
- old
+ new
@@ -5,26 +5,46 @@
# The specification checks whether the policy object is valid or not,
# depending on values of its attributes.
# default attributes for a valid policy
<% attributes.each do |item| -%>
- # let(:<%= item %>) { @todo }
+ # let(:<%= item.name %>) { @todo }
<% end -%>
- subject { described_class.new <%= attributes.join(", ") %> }
+ subject do
+ described_class.new(
+<% attributes.each do |item| -%>
+ <%= item.name %>: <%= item.name %>,
+<% end -%>
+ )
+ end
+<% attributes.each do |item| -%>
- context "when @todo: describe the context" do
+ describe "#<%= item.name %>" do
- it { is_expected.to be_valid }
+ it "is initialized" do
+ expect(subject.<%= item.name %>).to eq <%= item.name %>
+ end
- end # context
-<% attributes.each do |item| -%>
+ end # describe #<%= item.name %>
+<% end -%>
- context "when <%= item %> @todo" do
+ describe "#valid?" do
- # let(:<%= item %>) { @todo }
- it { is_expected.not_to be_valid }
+ context "when @todo: describe the context" do
- end # context
-<% end -%>
+ it { is_expected.to be_valid }
+
+ end # context
+ <% attributes.each do |item| -%>
+
+ context "when the #<%= item.name %> is @todo" do
+
+ # before { allow(subject).to receive(:<%= item.name %>) { @todo } }
+ it { is_expected.to be_invalid }
+
+ end # context
+ <% end -%>
+
+ end # describe #valid?
end # describe <%= policy.type %>