Giter Club home page Giter Club logo

minitest_cookbook_source's People

Contributors

chriskottom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

minitest_cookbook_source's Issues

Use instance variables instead of local variables in CommentsHelper test

I wonder if the following code in Testing Helpers section works. I think commnet1-3 should be @comment1-3.

describe CommentsHelper do
  let(:post)  { posts(:with_comments) }

  before do
    comment1 = post.comments.build(text: "Comment 1",
                                   user: "[email protected]")
    comment2 = post.comments.build(text: "Comment 2",
                                   user: "[email protected]")
    comment3 = post.comments.build(text: "Comment 3",
                                   user: "[email protected]")
  end

  describe "#comments_for" do
    it "renders each top-level comment" do
      render_comments_for(post)
      [comment1, comment2, comment3].each do |comment|
        assert_template partial: "_comment", locals: { comment: comment }
      end
    end
  end
end

ActiveRecord::StatementInvalid: SQLite3::BusyException: database is locked: commit transaction

minishop test fails like this:

➜  minishop git:(master) bundle exec rake test
Run options: --seed 58825

# Running:

.................E......................................

Fabulous run in 9.343703s, 5.9933 runs/s, 20.6556 assertions/s.

  1) Error:
Shopping Feature Test#test_0001_add several items to the cart and check out:
ActiveRecord::StatementInvalid: SQLite3::BusyException: database is locked: commit transaction
    app/controllers/line_items_controller.rb:12:in `block in create'
    app/controllers/line_items_controller.rb:11:in `create'

56 runs, 193 assertions, 0 failures, 1 errors, 0 skips

So I changed test_helper.rb like this:

ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'minitest/rails'
require 'minitest/pride'

require 'minitest/rails/capybara'
Capybara.default_wait_time = 1

require 'capybara/poltergeist'
Capybara.javascript_driver = :poltergeist

# Capybara.javascript_driver = :webkit

require "support/session_helpers"
require "support/shopping_helpers"

class ActiveSupport::TestCase
  include SessionHelpers

  fixtures :all
end

class ActiveRecord::Base
  mattr_accessor :shared_connection
  @@shared_connection = nil
  def self.connection
    @@shared_connection || retrieve_connection
  end
end
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection

I think it is worth mentioning in the book.

FizzBuzz Setup Suggestion

Page 48 says;

“It's not doing much of anything, but what we have here is, in fact, a full-fledged test case. We could execute our test suite right now, and the framework would run it.”

It took me some back and forth to previous recipe to get my test suite to run without an error. Since these first few are targeting beginners and it’s not much code what do you think about showing a code summary of what is needed to type rake and there be no issues?

My commit to get it setup

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.