ibham 0.1.0 → 0.1.1.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - 1.9.3
6
+ env:
7
+ - DB=postgresql
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ ## V0.1.0
2
+
3
+ * Initial release
4
+
5
+ ## V0.1.1.rc1
6
+
7
+ * Save the vote when calling cast_vote method
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Ibham
1
+ # Ibham [![Build Status](https://secure.travis-ci.org/bloc40/ibham.png)](http://travis-ci.org/bloc40/ibham)
2
2
 
3
3
  TODO: Write a gem description
4
4
 
data/Rakefile CHANGED
@@ -1,10 +1,9 @@
1
1
  require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
2
+ require 'rake/testtask'
3
3
 
4
4
  desc 'Default: run specs.'
5
- task :default => :rspec
5
+ task default: :test
6
6
 
7
- RSpec::Core::RakeTask.new(:rspec) do |test|
8
- test.rspec_opts = ['--color']
7
+ Rake::TestTask.new do |test|
9
8
  test.pattern = './spec/**/*_spec.rb'
10
9
  end
data/ibham.gemspec CHANGED
@@ -19,7 +19,6 @@ Gem::Specification.new do |gem|
19
19
 
20
20
  gem.add_development_dependency 'activerecord'
21
21
  gem.add_development_dependency 'rake'
22
- gem.add_development_dependency 'rspec'
23
22
  gem.add_development_dependency 'database_cleaner'
24
23
  gem.add_development_dependency 'sqlite3'
25
24
  end
@@ -30,7 +30,7 @@ module Ibham
30
30
  end
31
31
 
32
32
  def cast_vote(voteable, value)
33
- votes.build(voteable: voteable, value: value)
33
+ votes.create(voteable: voteable, value: value)
34
34
  end
35
35
  end
36
36
  end
data/lib/ibham/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ibham
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1.rc1'
3
3
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require_relative '../spec_helper'
2
2
 
3
3
  describe Vote do
4
4
  let(:user) { User.create!(email: 'foo@example.com') }
@@ -7,24 +7,24 @@ describe Vote do
7
7
  describe 'Validations' do
8
8
  it 'should be valid if the value is 1' do
9
9
  vote = Vote.new(value: 1)
10
- vote.should be_valid
10
+ vote.valid?.must_equal true
11
11
  end
12
12
 
13
13
  it 'should be valid if the value is -1' do
14
14
  vote = Vote.new(value: -1)
15
- vote.should be_valid
15
+ vote.valid?.must_equal true
16
16
  end
17
17
 
18
18
  it 'should fail if the value is other than 1 or -1' do
19
19
  vote = Vote.new(value: 2)
20
- vote.should_not be_valid
20
+ vote.valid?.must_equal false
21
21
  end
22
22
 
23
23
  it 'should validate uniqueness of vote for voter and voteable' do
24
24
  user.vote_up(item)
25
- expect {
26
- user.vote_up(item)
27
- }.to change(Vote, :count).by(0)
25
+ Vote.count.must_equal 1
26
+ user.vote_up(item)
27
+ Vote.count.must_equal 1
28
28
  end
29
29
  end
30
30
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require_relative '../spec_helper'
2
2
 
3
3
  describe 'ActsAsVoteable' do
4
4
  let(:user1) { User.create! }
@@ -16,33 +16,33 @@ describe 'ActsAsVoteable' do
16
16
 
17
17
  describe '#up_votes' do
18
18
  it 'should return the number of positive votes for voteable' do
19
- item.up_votes.should == 2
19
+ item.up_votes.must_equal 2
20
20
  end
21
21
  end
22
22
 
23
23
  describe '#down_votes' do
24
24
  it 'should return the number of negative votes for voteable' do
25
- item.down_votes.should == 1
25
+ item.down_votes.must_equal 1
26
26
  end
27
27
  end
28
28
 
29
29
  describe '#up_percentage' do
30
30
  it 'should return the percentage of positive votes' do
31
- item.up_percentage.should be_within(0.1).of(66.6)
31
+ item.up_percentage.must_be_close_to 66.6, 0.1
32
32
  end
33
33
  end
34
34
 
35
35
  describe '#down_percentage' do
36
36
  it 'should return the percentage of negative votes' do
37
- item.down_percentage.should be_within(0.1).of(33.3)
37
+ item.down_percentage.must_be_close_to 33.3, 0.1
38
38
  end
39
39
 
40
40
  it 'should return 100% if the item has 1 negative vote' do
41
- item2.down_percentage.should == 100
41
+ item2.down_percentage.must_equal 100
42
42
  end
43
43
 
44
44
  it 'should return 0 if the item has 0 positive vote' do
45
- item2.up_percentage.should == 0
45
+ item2.up_percentage.must_equal 0
46
46
  end
47
47
  end
48
48
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require_relative '../spec_helper'
2
2
 
3
3
  describe 'ActsAsVoter' do
4
4
  let(:user) { User.create!(email: 'foo@example.com') }
@@ -6,46 +6,46 @@ describe 'ActsAsVoter' do
6
6
 
7
7
  describe '#can_vote_for?' do
8
8
  it 'should return true if the voter can vote for an item' do
9
- user.can_vote_for?(item).should be_true
9
+ user.can_vote_for?(item).must_equal true
10
10
  end
11
11
 
12
12
  it 'should return false if the voter can not vote for an item' do
13
13
  user.vote_down(item)
14
- user.can_vote_for?(item).should be_false
14
+ user.can_vote_for?(item).must_equal false
15
15
  end
16
16
  end
17
17
 
18
18
  describe '#vote_up' do
19
19
  it 'should create a positive vote' do
20
- expect { user.vote_up(item) }.to change { Vote.count }.by(1)
21
- Vote.last.value.should == 1
20
+ vote_count = Vote.count
21
+ user.vote_up(item)
22
+ Vote.count.must_equal vote_count + 1
23
+ Vote.last.value.must_equal 1
22
24
  end
23
25
  end
24
26
 
25
27
  describe '#vote_down' do
26
28
  it 'should create a positive vote' do
27
- expect { user.vote_down(item) }.to change { Vote.count }.by(1)
28
- Vote.last.value.should == -1
29
+ vote_count = Vote.count
30
+ user.vote_down(item)
31
+ Vote.count.must_equal vote_count + 1
32
+ Vote.last.value.must_equal -1
29
33
  end
30
34
  end
31
35
 
32
36
  describe '#cast_vote' do
33
37
  it 'should create a positive vote' do
34
- Vote.count.should == 0
35
- expect do
36
- vote = user.cast_vote(item, 1)
37
- vote.save
38
- end.to change { Vote.count }.by(1)
39
- Vote.last.value.should == 1
38
+ vote_count = Vote.count
39
+ vote = user.cast_vote(item, 1)
40
+ Vote.count.must_equal vote_count + 1
41
+ Vote.last.value.must_equal 1
40
42
  end
41
43
 
42
44
  it 'should create a negative vote' do
43
- Vote.count.should == 0
44
- expect do
45
- vote = user.cast_vote(item, -1)
46
- vote.save
47
- end.to change { Vote.count }.by(1)
48
- Vote.last.value.should == -1
45
+ vote_count = Vote.count
46
+ vote = user.cast_vote(item, -1)
47
+ Vote.count.must_equal vote_count + 1
48
+ Vote.last.value.must_equal -1
49
49
  end
50
50
  end
51
51
  end
data/spec/spec_helper.rb CHANGED
@@ -2,6 +2,7 @@ require 'active_record'
2
2
  require 'database_cleaner'
3
3
  require 'sqlite3'
4
4
  require 'ibham'
5
+ require 'minitest/autorun'
5
6
 
6
7
  db_config = {
7
8
  :adapter => 'sqlite3',
@@ -12,9 +13,9 @@ ActiveRecord::Base.establish_connection(db_config)
12
13
 
13
14
  ActiveRecord::Migration.verbose = false
14
15
 
15
- RSpec.configure do |config|
16
- config.before(:each) { DatabaseCleaner.start }
17
- config.after(:each) { DatabaseCleaner.clean }
16
+ class MiniTest::Spec
17
+ before(:each) { DatabaseCleaner.start }
18
+ after(:each) { DatabaseCleaner.clean }
18
19
  end
19
20
 
20
21
  ActiveRecord::Schema.define do
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ibham
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.1.1.rc1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jamal El Milahi
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-04 00:00:00.000000000 Z
12
+ date: 2012-10-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &70263820298980 !ruby/object:Gem::Requirement
16
+ requirement: &70226356473360 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70263820298980
24
+ version_requirements: *70226356473360
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70263820298200 !ruby/object:Gem::Requirement
27
+ requirement: &70226356471720 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,21 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70263820298200
36
- - !ruby/object:Gem::Dependency
37
- name: rspec
38
- requirement: &70263820313380 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ! '>='
42
- - !ruby/object:Gem::Version
43
- version: '0'
44
- type: :development
45
- prerelease: false
46
- version_requirements: *70263820313380
35
+ version_requirements: *70226356471720
47
36
  - !ruby/object:Gem::Dependency
48
37
  name: database_cleaner
49
- requirement: &70263820312720 !ruby/object:Gem::Requirement
38
+ requirement: &70226356469800 !ruby/object:Gem::Requirement
50
39
  none: false
51
40
  requirements:
52
41
  - - ! '>='
@@ -54,10 +43,10 @@ dependencies:
54
43
  version: '0'
55
44
  type: :development
56
45
  prerelease: false
57
- version_requirements: *70263820312720
46
+ version_requirements: *70226356469800
58
47
  - !ruby/object:Gem::Dependency
59
48
  name: sqlite3
60
- requirement: &70263820312040 !ruby/object:Gem::Requirement
49
+ requirement: &70226356468640 !ruby/object:Gem::Requirement
61
50
  none: false
62
51
  requirements:
63
52
  - - ! '>='
@@ -65,7 +54,7 @@ dependencies:
65
54
  version: '0'
66
55
  type: :development
67
56
  prerelease: false
68
- version_requirements: *70263820312040
57
+ version_requirements: *70226356468640
69
58
  description: Voting System for Rails applications
70
59
  email:
71
60
  - jamal@elmilahi.com
@@ -74,6 +63,8 @@ extensions: []
74
63
  extra_rdoc_files: []
75
64
  files:
76
65
  - .gitignore
66
+ - .travis.yml
67
+ - CHANGELOG.md
77
68
  - Gemfile
78
69
  - LICENSE.txt
79
70
  - README.md
@@ -105,9 +96,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
105
96
  required_rubygems_version: !ruby/object:Gem::Requirement
106
97
  none: false
107
98
  requirements:
108
- - - ! '>='
99
+ - - ! '>'
109
100
  - !ruby/object:Gem::Version
110
- version: '0'
101
+ version: 1.3.1
111
102
  requirements: []
112
103
  rubyforge_project:
113
104
  rubygems_version: 1.8.17