Skip to content

(Feature request) Make mocked model to_s more elegant #30

@Looooong

Description

@Looooong

Current behaviour:

m = mock_model(Transaction)
m.to_s # Returns something like Transaction_#<RSpec::ExampleGroups::0x00564be9720728>

I would like to_s to also show what is stubbed inside that model, so that the spec is easier to read. For example:

m = mock_model(Transaction, type: :transfer)
m.to_s # Transaction(type: :transfer) #<RSpec::ExampleGroups::0x00564be9720728>

it { is_expected.to be_able_to(:read, mock_model(Transaction, type: :transfer)) }
# Output: It should be able to read Transaction(type: :transfer) #<RSpec::ExampleGroups::0x00564be9720728>

It will look similar to what ActiveRecord does. What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions