GithubHelp home page GithubHelp logo

Comments (8)

gabebw avatar gabebw commented on May 19, 2024

Hi, what's your subject set to in this spec?

from shoulda-matchers.

andreapavoni avatar andreapavoni commented on May 19, 2024

At first, I tried with implicit subject, then I've used:

describe Newsletter do
  let(:newsletter) { Factory :newsletter }
  subject { newsletter } # explicit subject

  # ...

  it { should serialize(:event_ids).as(Array) }

  # ...
end

In both cases, it didn't work. Other tests worked with implicit subject.

from shoulda-matchers.

gabebw avatar gabebw commented on May 19, 2024

What about this?

context "validations" do
  subject { Newsletter.new }
  it { should serialize(:event_ids).as(Array) }
end

You can also do this:

describe Newsletter do
  it "serializes event_ids as an Array" do
    Newsletter.new.should serialize(:event_ids).as(Array)
  end
end

from shoulda-matchers.

andreapavoni avatar andreapavoni commented on May 19, 2024

same error :-/

from shoulda-matchers.

gabebw avatar gabebw commented on May 19, 2024

Do other matchers work? Like it { should have_many(:whatevers) }?

from shoulda-matchers.

andreapavoni avatar andreapavoni commented on May 19, 2024

yes, I have a bunch of these in same file:

describe "associations" do
  it { should belong_to(:banner) }
end

describe "number" do
  it { should validate_presence_of(:number) }
  it { should validate_numericality_of(:number) }
end # number

they all work as expected.

from shoulda-matchers.

danielstockton avatar danielstockton commented on May 19, 2024

I also have this issue (shoulda 3.0.1)

from shoulda-matchers.

halogenandtoast avatar halogenandtoast commented on May 19, 2024

This is because the serialize matcher isn't currently in shoulda-matchers 1.0.0 which is the last one released as a gem. If you want to use the serialize matcher now you can do this:

group :test do
  gem 'rspec-rails'
  gem 'shoulda-matchers', git: "https://github.com/thoughtbot/shoulda-matchers"
  gem 'shoulda', '3.0.1'
end

Or wait until we cut the next release of shoulda which should be using the latest shoulda-matchers

from shoulda-matchers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.