Skip to content

Commit

Permalink
Group class methods in spec
Browse files Browse the repository at this point in the history
  • Loading branch information
dwaller committed Apr 2, 2015
1 parent 8adb324 commit c9b4621
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions spec/model_attributes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,23 @@ def initialize(attributes = {})
end

RSpec.describe "a class using ModelAttribute" do
describe ".attributes" do
it "returns an array of attribute names as symbols" do
expect(User.attributes).to eq([:id, :paid, :name, :created_at, :profile])
describe "class methods" do
describe ".attribute" do
context "passed an unrecognised type" do
it "raises an error" do
expect do
User.attribute :address, :custom_type
end.to raise_error(ModelAttribute::UnsupportedTypeError,
"Unsupported type :custom_type. " +
"Must be one of :integer, :boolean, :string, :time, :json.")
end
end
end
end

describe "defining an attribute with an invalid type" do
it "raises an error" do
expect do
User.attribute :address, :custom_type
end.to raise_error(ModelAttribute::UnsupportedTypeError,
"Unsupported type :custom_type. " +
"Must be one of :integer, :boolean, :string, :time, :json.")
describe ".attributes" do
it "returns an array of attribute names as symbols" do
expect(User.attributes).to eq([:id, :paid, :name, :created_at, :profile])
end
end
end

Expand Down Expand Up @@ -408,7 +412,7 @@ def initialize(attributes = {})
end
end

describe "id_changed?" do
describe "#id_changed?" do
context "with no changes" do
it "returns false" do
expect(user.id_changed?).to eq(false)
Expand Down

0 comments on commit c9b4621

Please sign in to comment.