diff --git a/.ruby-version b/.ruby-version index c043eea..be94e6f 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.2.1 +3.2.2 diff --git a/Gemfile b/Gemfile index 297d03d..0df4f02 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source "https://rubygems.org" gem "activerecord", "~> 4.1" gem "database_cleaner" -gem "factory_girl" +gem "factory_bot" gem "rspec", "~> 3.1" gem "rake" gem "sqlite3" diff --git a/Gemfile.lock b/Gemfile.lock index 68a34e8..81ac972 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,45 +1,48 @@ GEM remote: https://rubygems.org/ specs: - activemodel (4.1.8) - activesupport (= 4.1.8) + activemodel (4.2.11.3) + activesupport (= 4.2.11.3) builder (~> 3.1) - activerecord (4.1.8) - activemodel (= 4.1.8) - activesupport (= 4.1.8) - arel (~> 5.0.0) - activesupport (4.1.8) - i18n (~> 0.6, >= 0.6.9) - json (~> 1.7, >= 1.7.7) + activerecord (4.2.11.3) + activemodel (= 4.2.11.3) + activesupport (= 4.2.11.3) + arel (~> 6.0) + activesupport (4.2.11.3) + i18n (~> 0.7) minitest (~> 5.1) - thread_safe (~> 0.1) + thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - arel (5.0.1.20140414130214) - builder (3.2.2) - database_cleaner (1.3.0) - diff-lcs (1.2.5) - factory_girl (4.5.0) + arel (6.0.4) + builder (3.2.4) + concurrent-ruby (1.2.2) + database_cleaner (1.99.0) + diff-lcs (1.5.0) + factory_girl (4.9.0) activesupport (>= 3.0.0) - i18n (0.6.11) - json (1.8.1) - minitest (5.4.3) - rake (10.4.2) - rspec (3.1.0) - rspec-core (~> 3.1.0) - rspec-expectations (~> 3.1.0) - rspec-mocks (~> 3.1.0) - rspec-core (3.1.7) - rspec-support (~> 3.1.0) - rspec-expectations (3.1.2) + i18n (0.9.5) + concurrent-ruby (~> 1.0) + mini_portile2 (2.8.4) + minitest (5.19.0) + rake (13.0.6) + rspec (3.12.0) + rspec-core (~> 3.12.0) + rspec-expectations (~> 3.12.0) + rspec-mocks (~> 3.12.0) + rspec-core (3.12.2) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-mocks (3.12.6) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.1.0) - rspec-mocks (3.1.3) - rspec-support (~> 3.1.0) - rspec-support (3.1.2) - sqlite3 (1.3.10) - thread_safe (0.3.4) - timecop (0.7.1) - tzinfo (1.2.2) + rspec-support (~> 3.12.0) + rspec-support (3.12.1) + sqlite3 (1.6.4) + mini_portile2 (~> 2.8.0) + thread_safe (0.3.6) + timecop (0.9.8) + tzinfo (1.2.11) thread_safe (~> 0.1) PLATFORMS @@ -53,3 +56,6 @@ DEPENDENCIES rspec (~> 3.1) sqlite3 timecop + +BUNDLED WITH + 2.4.19 diff --git a/README.md b/README.md index 17dcb2a..45937c8 100644 --- a/README.md +++ b/README.md @@ -76,10 +76,15 @@ If you'd like to see a quick intro to test doubles, check out the related episod ## Instructions -To start, you'll want to clone and run the setup script for the repo +To start, you'll want to clone the repo git clone git@github.com:thoughtbot-upcase-exercises/simple-stubs.git cd simple-stubs + + +In the file `.ruby-version`, update the Ruby version according to the Ruby that runs on your machine, update the bundle, and then run the setup script for the repo. + + bundle update bin/setup After running `bin/setup`, edit `spec/dashboard_spec.rb` and look for test logic which is duplicated from `spec/post_spec.rb`. Use `double` and `allow` to create a stub for posts and eliminate this duplication. diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8ed8c03..7ee924e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,7 +1,7 @@ require "rspec" require "active_record" require "database_cleaner" -require "factory_girl" +require "factory_bot" require "timecop" PROJECT_ROOT = File.expand_path("../..", __FILE__) @@ -13,7 +13,7 @@ database: File.join(PROJECT_ROOT, "test.db") ) -class CreateSchema < ActiveRecord::Migration +class CreateSchema < ActiveRecord::Migration[7.0] def self.up create_table :posts, force: true do |table| table.string :title @@ -22,7 +22,7 @@ def self.up end end -FactoryGirl.define do +FactoryBot.define do sequence(:title) { |n| "title#{n}text" } factory :post do @@ -31,7 +31,7 @@ def self.up end RSpec.configure do |config| - config.include FactoryGirl::Syntax::Methods + config.include FactoryBot::Syntax::Methods config.before(:suite) do CreateSchema.suppress_messages { CreateSchema.migrate(:up) }