neutral 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6aaf880268538c5e572b0635e0d6d1a0298fb058
4
- data.tar.gz: df6a732d8a833ef2d02a3c59d8f71cf06bd38db5
3
+ metadata.gz: 28bba1188ad74ced81d86d0eb403f409096a47fa
4
+ data.tar.gz: c8f8894572d72f30ebfb941e8d94762d5779f5da
5
5
  SHA512:
6
- metadata.gz: 136f7fcb7713b4a85a2b94787834b57a729f323e2422060c44e4a8b633d843e23e92a405ed66aa292637880d8f18d66818d052473f835f8dbd6a79b782cd38f7
7
- data.tar.gz: 0c839982f3abccc87b357d2b41716e4f89e11d67c9a3dcd1f7aae6d1dcc7ed5a4d22c6a942265abda6ff1628eb23152e72cd7cebc5d4fc1862d57312bb0210fc
6
+ metadata.gz: fc745f228aad30bd887a3e4d821f2eae223165bb4186c3ed6bcd6c149976a954fe07dbe89f475abe3d253c058924352196c38761ec136fa13c7a239c68c62dfc
7
+ data.tar.gz: 317ec623838b2d8e8c15a7dcad67515667280e25b65ae7050fbbd57f3803f8a08c9ed674a544d2ab6896818e8ca1946ab0fca025f39bdbb4bea2706545f52b26
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- neutral (0.0.2)
4
+ neutral (0.0.3)
5
5
  font-awesome-rails (~> 4.0.3.1)
6
6
  jquery-rails
7
7
  rails (~> 4.0.0)
@@ -29,11 +29,11 @@ div.neutral span {
29
29
  display: inline;
30
30
  }
31
31
 
32
- div.neutral span#positive, div.neutral span.positive {
32
+ div.neutral span.positive {
33
33
  color: green;
34
34
  }
35
35
 
36
- div.neutral span#negative, div.neutral span.negative {
36
+ div.neutral span.negative {
37
37
  color: red;
38
38
  }
39
39
 
@@ -2,11 +2,11 @@ $(document).ready(function() {
2
2
 
3
3
  neutral = $("div.neutral").find("<%= by_url %>").parent();
4
4
 
5
- neutral.find("span#positive").html("<%= voting.positive.nonzero? %>");
6
- neutral.find("span#negative").html("<%= voting.negative.nonzero? %>");
7
- neutral.find("span#difference").html("<%= voting.difference.nonzero?.try(:abs) %>");
5
+ neutral.find("span.positive").html("<%= voting.positive.nonzero? %>");
6
+ neutral.find("span.negative").html("<%= voting.negative.nonzero? %>");
7
+ neutral.find("span.difference").html("<%= voting.difference.nonzero?.try(:abs) %>");
8
8
 
9
- neutral.find("span#difference").attr("class", "<%= voting.difference > 0 ? 'positive' : 'negative' %>");
9
+ neutral.find("span.difference").attr("class", "<%= "difference #{voting.difference > 0 ? 'positive' : 'negative'}" %>");
10
10
 
11
11
  <% if vote.voter_id && Neutral.config.can_change %>
12
12
 
@@ -7,11 +7,11 @@ $(document).ready(function() {
7
7
  neutral.find("a.positive").attr('href', '<%= votes_path(1) %>');
8
8
  neutral.find("a.negative").attr('href', '<%= votes_path(0) %>');
9
9
 
10
- neutral.find("span#positive").html("<%= voting.positive.nonzero? %>");
11
- neutral.find("span#negative").html("<%= voting.negative.nonzero? %>");
12
- neutral.find("span#difference").html("<%= voting.difference.nonzero?.try(:abs) %>");
10
+ neutral.find("span.positive").html("<%= voting.positive.nonzero? %>");
11
+ neutral.find("span.negative").html("<%= voting.negative.nonzero? %>");
12
+ neutral.find("span.difference").html("<%= voting.difference.nonzero?.try(:abs) %>");
13
13
 
14
- neutral.find("span#difference").attr("class", "<%= voting.difference > 0 ? 'positive' : 'negative' %>");
14
+ neutral.find("span.difference").attr("class", "<%= "difference #{voting.difference > 0 ? 'positive' : 'negative'}" %>");
15
15
 
16
16
  neutral.find("a.remove").remove();
17
17
 
@@ -2,10 +2,10 @@ $(document).ready(function() {
2
2
 
3
3
  neutral = $("div.neutral").find("<%= by_url %>").parent();
4
4
 
5
- neutral.find("span#positive").html("<%= voting.positive.nonzero? %>");
6
- neutral.find("span#negative").html("<%= voting.negative.nonzero? %>");
7
- neutral.find("span#difference").html("<%= voting.difference.nonzero?.try(:abs) %>");
5
+ neutral.find("span.positive").html("<%= voting.positive.nonzero? %>");
6
+ neutral.find("span.negative").html("<%= voting.negative.nonzero? %>");
7
+ neutral.find("span.difference").html("<%= voting.difference.nonzero?.try(:abs) %>");
8
8
 
9
- neutral.find("span#difference").attr("class", "<%= voting.difference > 0 ? 'positive' : 'negative' %>");
9
+ neutral.find("span.difference").attr("class", "<%= "difference #{voting.difference > 0 ? 'positive' : 'negative'}" %>");
10
10
 
11
11
  });
@@ -1,3 +1,3 @@
1
1
  module Neutral
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -15,19 +15,19 @@ module Neutral
15
15
 
16
16
  class Positive < Span
17
17
  def to_s
18
- content_tag :span, total, id: 'positive'
18
+ content_tag :span, total, class: 'positive'
19
19
  end
20
20
  end
21
21
 
22
22
  class Negative < Span
23
23
  def to_s
24
- content_tag :span, total, id: 'negative'
24
+ content_tag :span, total, class: 'negative'
25
25
  end
26
26
  end
27
27
 
28
28
  class Difference < Span
29
29
  def to_s
30
- content_tag :span, total.try(:abs), class: color, id: 'difference'
30
+ content_tag :span, total.try(:abs), class: "difference #{color}"
31
31
  end
32
32
 
33
33
  private
data/neutral.gemspec CHANGED
@@ -15,8 +15,8 @@ Gem::Specification.new do |s|
15
15
  s.test_files = `git ls-files -- spec/**/*`.split("\n")
16
16
 
17
17
  s.add_dependency "rails", "~> 4.0.0"
18
- s.add_dependency "font-awesome-rails", "~> 4.0.3.1"
19
- s.add_dependency "jquery-rails"
18
+ s.add_dependency "font-awesome-rails", "~> 4.0.3.1"
19
+ s.add_dependency "jquery-rails"
20
20
 
21
21
  s.add_development_dependency "sqlite3"
22
22
  s.add_development_dependency "simplecov"
@@ -9,18 +9,16 @@ describe Neutral::VotingBuilder::Builder, type: :feature do
9
9
  subject { Neutral::VotingBuilder::Builder.new(voteable, {}).build }
10
10
 
11
11
  it { should have_selector "div.neutral" }
12
- it { should have_selector "span#positive" }
12
+ it { should have_selector "span.positive" }
13
13
  it { should have_selector "a.positive" }
14
14
  it { should have_selector "a.negative" }
15
- it { should have_selector "span#negative" }
15
+ it { should have_selector "span.negative" }
16
16
  end
17
17
 
18
18
  context "with difference" do
19
19
  subject { Neutral::VotingBuilder::Builder.new(voteable, difference: true).build }
20
20
 
21
- it { should have_selector "span#difference" }
22
- it { should_not have_selector "span#positive" }
23
- it { should_not have_selector "span#negative" }
21
+ it { should have_selector "span.difference" }
24
22
  end
25
23
 
26
24
  describe "remove link" do
@@ -7,10 +7,11 @@ describe Span, type: :feature do
7
7
  describe span do
8
8
  describe "#to_s" do
9
9
  let(:total) { rand(100) + 1 }
10
+ let(:klass) { span.to_s.demodulize.downcase }
10
11
 
11
12
  subject { Capybara.string span.new(total).to_s }
12
13
 
13
- it { should have_selector("span##{span.to_s.demodulize.downcase}") }
14
+ it { should have_selector("span.#{klass}") }
14
15
 
15
16
  it "has value of given total" do
16
17
  subject.find("span").text.should == total.to_s
@@ -24,20 +25,24 @@ describe Span, type: :feature do
24
25
  end
25
26
 
26
27
  describe Span::Difference do
28
+ def difference_element(total)
29
+ Capybara.string(Span::Difference.new(total).to_s).find("span")
30
+ end
31
+
27
32
  describe "#to_s" do
28
33
  let(:positive) { rand(100) + 1 }
29
34
  let(:negative) { -(rand(100) + 1) }
30
35
 
31
36
  it "has absolute value of total" do
32
- Capybara.string(Span::Difference.new(negative).to_s).find("span").text.to_i.should > 0
37
+ difference_element(negative).text.to_i.should > 0
33
38
  end
34
39
 
35
40
  it "has 'positive' class when positive value of total is passed" do
36
- Capybara.string(Span::Difference.new(positive).to_s).find("span")[:class].should == "positive"
41
+ difference_element(positive)[:class].should include("positive")
37
42
  end
38
43
 
39
44
  it "has 'negative' class when negative value of total is passed" do
40
- Capybara.string(Span::Difference.new(negative).to_s).find("span")[:class].should == "negative"
45
+ difference_element(negative)[:class].should include("negative")
41
46
  end
42
47
  end
43
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neutral
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Tóth