README.md in with_model-1.1.0 vs README.md in with_model-1.2.0

- old
+ new

@@ -1,20 +1,20 @@ # [with_model](https://github.com/Casecommons/with_model) -[![Build Status](https://secure.travis-ci.org/Casecommons/with_model.png?branch=master)](https://travis-ci.org/Casecommons/with_model) -[![Code Climate](https://codeclimate.com/github/Casecommons/with_model.png)](https://codeclimate.com/github/Casecommons/with_model) -[![Coverage Status](https://coveralls.io/repos/Casecommons/with_model/badge.png?branch=master)](https://coveralls.io/r/Casecommons/with_model) -[![Gem Version](https://badge.fury.io/rb/with_model.png)](https://rubygems.org/gems/with_model) -[![Dependency Status](https://gemnasium.com/Casecommons/with_model.png)](https://gemnasium.com/Casecommons/with_model) +[![Build Status](https://secure.travis-ci.org/Casecommons/with_model.svg?branch=master)](https://travis-ci.org/Casecommons/with_model) +[![Code Climate](https://img.shields.io/codeclimate/github/Casecommons/with_model.svg)](https://codeclimate.com/github/Casecommons/with_model) +[![Coverage Status](https://img.shields.io/coveralls/Casecommons/with_model/master.svg)](https://coveralls.io/r/Casecommons/with_model) +[![Gem Version](https://badge.fury.io/rb/with_model.svg)](https://rubygems.org/gems/with_model) +[![Dependency Status](https://gemnasium.com/Casecommons/with_model.svg)](https://gemnasium.com/Casecommons/with_model) `with_model` dynamically builds an ActiveRecord model (with table) before each test in a group and destroys it afterwards. ## Installation Install as usual: `gem install with_model` or add `gem 'with_model'` to your Gemfile. See `.travis.yml` for supported (tested) Ruby versions. -## RSpec +### RSpec Extend `WithModel` into RSpec: ```ruby require 'with_model' @@ -22,11 +22,11 @@ RSpec.configure do |config| config.extend WithModel end ``` -## minitest/spec +### minitest/spec Extend `WithModel` into minitest/spec: ```ruby require 'with_model' @@ -91,11 +91,11 @@ it "can be accessed as a constant" do expect(BlogPost).to be end it "has the module" do - expect(BlogPost.include?(SomeModule)).to be_true + expect(BlogPost.include?(SomeModule)).to eq true end it "has the class method" do expect(BlogPost.some_class_method).to eq 'chunky' end @@ -107,11 +107,11 @@ it "can do all the things a regular model can" do record = BlogPost.new expect(record).to_not be_valid record.title = "foo" expect(record).to be_valid - expect(record.save).to be_true + expect(record.save).to eq true expect(record.reload).to eq record record.comments.create!(:text => "Lorem ipsum") expect(record.comments.count).to eq 1 end @@ -122,16 +122,32 @@ with_model :Ford, superclass: Car do end it "has a specified superclass" do - expect(Ford < Car).to be_true + expect(Ford < Car).to eq true end end +describe "with_model can be run within RSpec :all hook" do + with_model :BlogPost, scope: :all do + table do |t| + t.string :title + end + end + + before :all do + BlogPost.create # without scope: :all these will fail + end + + it "has been initialized within before(:all)" do + expect(BlogPost.count).to eq 1 + end +end + describe "another example group" do it "does not have the constant anymore" do - expect(defined?(BlogPost)).to be_false + expect(defined?(BlogPost)).to be_falsy end end describe "with table options" do with_model :WithOptions do