solid_assert 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,15 +2,15 @@
2
2
 
3
3
  *solid_assert* is a simple implementation of an `assert` utility in Ruby. It let you code tests for your assumptions inside your code itself.
4
4
 
5
- Notice that assertions shouldn't be used for handling error situations. Use Ruby built-in exception handling for that. Assertions are meant to test conditions about the integrity of your code. You should use them for testing assumptions like the following:
5
+ Assertions are meant to test conditions about the integrity of your code. You should use them for testing assumptions like the following:
6
6
 
7
- - If it reaches here, then this variable has to have this value.
7
+ - If the flow reaches here, then this variable has to have this value.
8
8
  - This line of code should never be executed.
9
9
  - At this point, this list should contain one entry for all the keys in this hash.
10
10
 
11
- The practice of using assertions makes your code more solid, since it is the computer who systematically verifies your code integrity.
11
+ Notice that assertions shouldn't be used for handling error situations. Use Ruby built-in exception handling for that.
12
12
 
13
- Assertions should be used in development mode. You can disable them in production for performance reasons.
13
+ Assertions are typically used in development mode. You might want to disable them in production for performance reasons.
14
14
 
15
15
  # Installation
16
16
 
@@ -29,7 +29,7 @@ Assertions are disabled by default.
29
29
  Use `assert` for testing conditions. You can optionally provide a message
30
30
 
31
31
  assert some_string != "some value"
32
- assert clients.list?, "Isn't the clients list empty?"
32
+ assert clients_list.empty?, "Isn't the clients list empty?"
33
33
 
34
34
  Use `invariant` for testing blocks of code. This comes handy when testing your assumptions requires several lines of code. You can provide an optional message if you want
35
35
 
@@ -48,7 +48,7 @@ Use `invariant` for testing blocks of code. This comes handy when testing your a
48
48
  ## References
49
49
 
50
50
  - [Programming with assertions](http://download.oracle.com/javase/1.4.2/docs/guide/lang/assert.html). A great article on assertions. It is about the Java language, but the concepts it explains apply to any programming language.
51
- - [Writing Solid Code](http://www.amazon.com/Writing-Solid-Code-Microsoft-Programming/dp/1556155514). A great book on good coding design practices. Again, it is related to C, but the practices it talks about apply to coding in any programming language.
51
+ - [Writing Solid Code](http://www.amazon.com/Writing-Solid-Code-Microsoft-Programming/dp/1556155514). A great book on good coding design practices. Again, it based in C, but the practices it talks about apply to coding in any programming language.
52
52
 
53
53
 
54
54
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.0
1
+ 0.7.1
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{solid_assert}
8
- s.version = "0.7.0"
8
+ s.version = "0.7.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Jorge Manrubia}]
@@ -6,29 +6,29 @@ describe SolidAssert::Assert do
6
6
  describe "#assert" do
7
7
  describe "without assertion message" do
8
8
  it "should fail when condition is false" do
9
- lambda { assert false }.should raise_error SolidAssert::AssertionFailedError
9
+ expect { assert false }.to raise_error SolidAssert::AssertionFailedError
10
10
  end
11
11
 
12
12
  it "should fail when condition evaluates to false" do
13
- lambda { assert nil }.should raise_error SolidAssert::AssertionFailedError
13
+ expect { assert nil }.to raise_error SolidAssert::AssertionFailedError
14
14
  end
15
15
 
16
16
  it "should not fail when condition is true" do
17
- lambda { assert true }.should_not raise_error SolidAssert::AssertionFailedError
17
+ expect { assert true }.to_not raise_error SolidAssert::AssertionFailedError
18
18
  end
19
19
 
20
20
  it "should not fail when condition evaluates to true" do
21
- lambda { assert "This evaluates to true" }.should_not raise_error SolidAssert::AssertionFailedError
21
+ expect { assert "This evaluates to true" }.to_not raise_error SolidAssert::AssertionFailedError
22
22
  end
23
23
  end
24
24
 
25
25
  describe "with assertion message" do
26
26
  it "should raise error with specified message when condition evaluates to false" do
27
- lambda { assert nil, "The error message" }.should raise_error(SolidAssert::AssertionFailedError, "The error message")
27
+ expect { assert nil, "The error message" }.to raise_error(SolidAssert::AssertionFailedError, "The error message")
28
28
  end
29
29
 
30
30
  it "should not raise any error when condition doesn't evaluate to false'" do
31
- lambda { assert 'This evaluates to true', "The error message" }.should_not raise_error(SolidAssert::AssertionFailedError)
31
+ expect { assert 'This evaluates to true', "The error message" }.to_not raise_error(SolidAssert::AssertionFailedError)
32
32
  end
33
33
  end
34
34
  end
@@ -1,6 +1,14 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe SolidAssert::Assert do
4
+ it "should enable the empty assert method by default" do
5
+ assert false
6
+ end
7
+
8
+ it "should enable the empty invariant method by default" do
9
+ invariant{false}
10
+ end
11
+
4
12
  describe ".enable_assertions" do
5
13
  it "should make the Object class to include the Assertions module" do
6
14
  Object.should_receive(:include).with(SolidAssert::Assert)
@@ -9,7 +17,7 @@ describe SolidAssert::Assert do
9
17
 
10
18
  it "should turn on the assertions" do
11
19
  SolidAssert.enable_assertions
12
- lambda{assert false}.should raise_error(SolidAssert::AssertionFailedError)
20
+ expect {assert false}.to raise_error(SolidAssert::AssertionFailedError)
13
21
  end
14
22
  end
15
23
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solid_assert
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 0
10
- version: 0.7.0
9
+ - 1
10
+ version: 0.7.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jorge Manrubia