Guest User

Untitled

a guest
Feb 28th, 2018
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.98 KB | None | 0 0
  1. diff --git a/test/helpers/fixtures.rb b/test/helpers/fixtures.rb
  2. index f8b9254..54e9850 100644
  3. --- a/test/helpers/fixtures.rb
  4. +++ b/test/helpers/fixtures.rb
  5. @@ -58,6 +58,15 @@ Integrity::Project.fixture(:my_test_project) do
  6. :building => false }
  7. end
  8.  
  9. +Integrity::Commit.fixture do
  10. + {
  11. + :identifier => Digest::SHA1.hexdigest(/[:paragraph:]/.gen),
  12. + :message => /[:paragraph:]/,
  13. + :author => /\w+ \w+/,
  14. + :committed_at => unique {|i| Time.mktime(2009, 12, 15, 18, (59 - i) % 60) }
  15. + }
  16. +end
  17. +
  18. Integrity::Build.fixture do
  19. { :output => /[:paragraph:]/.gen,
  20. :successful => true,
  21. diff --git a/test/unit/build_test.rb b/test/unit/build_test.rb
  22. index b98c120..1b6db24 100644
  23. --- a/test/unit/build_test.rb
  24. +++ b/test/unit/build_test.rb
  25. @@ -42,31 +42,5 @@ class BuildTest < Test::Unit::TestCase
  26. Build.gen(:successful => true).human_readable_status.should == "Build Successful"
  27. Build.gen(:successful => false).human_readable_status.should == "Build Failed"
  28. end
  29. -
  30. - it "has a commit identifier" do
  31. - @build.commit_identifier.should be("658ba96cb0235e82ee720510c049883955200fa9")
  32. - end
  33. -
  34. - it "has a short commit identifier" do
  35. - @build.short_commit_identifier.should == "658ba96"
  36. - Build.gen(:commit_identifier => "402").short_commit_identifier.should == "402"
  37. - end
  38. -
  39. - it "has a commit author" do
  40. - build = Build.gen(:commit_metadata => { :author => "Nicolás Sanguinetti <contacto@nicolassanguinetti.info>" })
  41. - build.commit_author.name.should == "Nicolás Sanguinetti"
  42. - build.commit_author.email.should == "contacto@nicolassanguinetti.info"
  43. - build.commit_author.full.should == "Nicolás Sanguinetti <contacto@nicolassanguinetti.info>"
  44. - end
  45. -
  46. - it "has a commit message" do
  47. - build = Build.gen(:commit_metadata => { :message => "This commit rocks" })
  48. - build.commit_message.should == "This commit rocks"
  49. - end
  50. -
  51. - it "has a commit date" do
  52. - build = Build.gen(:commit_metadata => { :date => Time.utc(2008, 10, 12, 14, 18, 20) })
  53. - build.commited_at.to_s.should == "Sun Oct 12 14:18:20 UTC 2008"
  54. - end
  55. end
  56. end
  57. diff --git a/test/unit/commit_test.rb b/test/unit/commit_test.rb
  58. new file mode 100644
  59. index 0000000..9198061
  60. --- /dev/null
  61. +++ b/test/unit/commit_test.rb
  62. @@ -0,0 +1,50 @@
  63. +require File.dirname(__FILE__) + '/../helpers'
  64. +
  65. +class CommitTest < Test::Unit::TestCase
  66. + before(:each) do
  67. + RR.reset
  68. + setup_and_reset_database!
  69. + end
  70. +
  71. + specify "fixture is valid and can be saved" do
  72. + lambda do
  73. + Commit.generate.tap do |commit|
  74. + commit.should be_valid
  75. + commit.save
  76. + end
  77. + end.should change(Commit, :count).by(1)
  78. + end
  79. +
  80. + describe "Properties" do
  81. + before(:each) do
  82. + @commit = Commit.generate(:identifier => "658ba96cb0235e82ee720510c049883955200fa9")
  83. + end
  84. +
  85. + it "has a commit identifier" do
  86. + @commit.identifier.should be("658ba96cb0235e82ee720510c049883955200fa9")
  87. + end
  88. +
  89. + it "has a short commit identifier" do
  90. + @commit.short_commit_identifier.should == "658ba96"
  91. +# Build.gen(:commit_identifier => "402").short_commit_identifier.should == "402"
  92. + end
  93. +
  94. +# it "has a commit author" do
  95. +# pending
  96. +# commit = Commit.gen(:author => "Nicolás Sanguinetti <contacto@nicolassanguinetti.info>")
  97. +# commit.author.name.should == "Nicolás Sanguinetti"
  98. +# commit.author.email.should == "contacto@nicolassanguinetti.info"
  99. +# commit.author.full.should == "Nicolás Sanguinetti <contacto@nicolassanguinetti.info>"
  100. +# end
  101. +
  102. + it "has a commit message" do
  103. + commit = Commit.gen(:message => "This commit rocks")
  104. + commit.message.should == "This commit rocks"
  105. + end
  106. +
  107. + it "has a commit date" do
  108. + commit = Commit.gen(:committed_at => Time.utc(2008, 10, 12, 14, 18, 20))
  109. + commit.committed_at.to_s.should == "2008-10-12T14:18:20+00:00"
  110. + end
  111. + end
  112. +end
Add Comment
Please, Sign In to add comment