yutokyokutyo / rebuild_sample_app

https://railstutorial.jp/chapters/static_pages?version=5.0#cha-static_pages
https://rebuildsampleapp.herokuapp.com/
5 stars 0 forks source link

4章 #2

Closed yutokyokutyo closed 7 years ago

yutokyokutyo commented 7 years ago

@kurotaky

4.4.5

example_user.rb

class User
  attr_accessor :first_name, :last_name

  def initialize(attributes = {})
    @first_name  = attributes[:first_name]
    @last_name  = attributes[:last_name]
  end

  def full_name
    "#{@first_name} #{@last_name}"
  end

  def alphabetical_name
    "#{@first_name}, #{@last_name}"
  end
end
>> require './example_user.rb'
=> true
>> user = User.new(first_name: "Yuto", last_name:"Kondo")
=> #<User:0x007fd9844a5b18 @first_name="Yuto", @last_name="Kondo">
>> user.full_name
=> "Yuto Kondo"
>> user.alphabetical_name
=> "Yuto, Kondo"
>> user.full_name.split
=> ["Yuto", "Kondo"]
>> user.alphabetical_name.split
=> ["Yuto,", "Kondo"]
>> user.full_name.split == user.alphabetical_name
=> false
yutokyokutyo commented 7 years ago

テストが通らない

refs: https://railstutorial.jp/chapters/rails_flavored_ruby?version=5.0#sec-custom_helpers

時間がかかってしまうので一旦後回し。

app/views/static_pages/home.html.erb で provide を外しているのだから | Ruby on Rails Tutorial Sample App にはならないと思うのだけれど...。

% rails t                                                                                                                   (git)-[filling-in-layout]
Running via Spring preloader in process 85981
/Users/y.kondo/workspace/rebuild_sample_app/db/schema.rb doesn't exist yet. Run `rails db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter /Users/y.kondo/workspace/rebuild_sample_app/config/application.rb to limit the frameworks that will be loaded.
Started with run options --seed 61590

 FAIL["test_should_get_home", StaticPagesControllerTest, 0.9458428690049914]
 test_should_get_home#StaticPagesControllerTest (0.95s)
        <Ruby on Rails Tutorial Sample App> expected but was
        <| Ruby on Rails Tutorial Sample App>..
        Expected 0 to be >= 1.
        test/controllers/static_pages_controller_test.rb:16:in `block in <class:StaticPagesControllerTest>'

  5/5: [=========================================================================================================] 100% Time: 00:00:01, Time: 00:00:01

Finished in 1.03150s
5 tests, 9 assertions, 1 failures, 0 errors, 0 skips
yutokyokutyo commented 7 years ago

68a4208 で解決。

% rails t                                                                                                                                                            (git)-[sign-up]
Running via Spring preloader in process 78473
Started with run options --seed 16595

 FAIL["test_should_get_contact", StaticPagesControllerTest, 0.6751159999985248]
 test_should_get_contact#StaticPagesControllerTest (0.68s)
        <Contact | > expected but was
        <Contact | Ruby on Rails Tutorial Sample App>..
        Expected 0 to be >= 1.
        test/controllers/static_pages_controller_test.rb:30:in `block in <class:StaticPagesControllerTest>'

 FAIL["test_should_get_help", StaticPagesControllerTest, 0.7480279998853803]
 test_should_get_help#StaticPagesControllerTest (0.75s)
        <Help | > expected but was
        <Help | Ruby on Rails Tutorial Sample App>..
        Expected 0 to be >= 1.
        test/controllers/static_pages_controller_test.rb:18:in `block in <class:StaticPagesControllerTest>'

 FAIL["test_should_get_home", StaticPagesControllerTest, 0.7844579999800771]
 test_should_get_home#StaticPagesControllerTest (0.78s)
        <> expected but was
        <| Ruby on Rails Tutorial Sample App>..
        Expected 0 to be >= 1.
        test/controllers/static_pages_controller_test.rb:12:in `block in <class:StaticPagesControllerTest>'

 FAIL["test_full_title_helper", ApplicationHelperTest, 1.0718869999982417]
 test_full_title_helper#ApplicationHelperTest (1.07s)
        --- expected
        +++ actual
        @@ -1 +1 @@
        -"Ruby on Rails Tutorial Sample App"
        +" | Ruby on Rails Tutorial Sample App"
        test/helpers/application_helper_test.rb:5:in `block in <class:ApplicationHelperTest>'

  18/18: [======================================================================================================================================] 100% Time: 00:00:01, Time: 00:00:01

Finished in 1.11146s
18 tests, 37 assertions, 4 failures, 0 errors, 0 skips

e3532fd で解決。

% rails t                                                                                                                                                            (git)-[sign-up]
Running via Spring preloader in process 78763
Started with run options --seed 4314

 FAIL["test_full_title_helper", ApplicationHelperTest, 0.04476800002157688]
 test_full_title_helper#ApplicationHelperTest (0.04s)
        --- expected
        +++ actual
        @@ -1 +1 @@
        -"Ruby on Rails Tutorial Sample App"
        +" | Ruby on Rails Tutorial Sample App"
        test/helpers/application_helper_test.rb:5:in `block in <class:ApplicationHelperTest>'

 FAIL["test_should_get_home", StaticPagesControllerTest, 0.7655799998901784]
 test_should_get_home#StaticPagesControllerTest (0.77s)
        <Ruby on Rails Tutorial Sample App> expected but was
        <| Ruby on Rails Tutorial Sample App>..
        Expected 0 to be >= 1.
        test/controllers/static_pages_controller_test.rb:13:in `block in <class:StaticPagesControllerTest>'

  18/18: [======================================================================================================================================] 100% Time: 00:00:01, Time: 00:00:01

Finished in 1.04219s
18 tests, 37 assertions, 2 failures, 0 errors, 0 skips
yutokyokutyo commented 7 years ago

テストが通ったので close します!ありがとうございました!

kurotaky commented 7 years ago

👍