Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add specs for future DiceParser class.

  • Loading branch information...
commit e2336835e7cc1d5117ddc7c80d97ef778bf5621e 1 parent 7c1b0e3
Sam Rose authored June 12, 2012
10  Gemfile
... ...
@@ -1,3 +1,11 @@
1 1
 source :rubygems
2 2
 
3  
-gem "Ruby-IRC"
  3
+gem 'Ruby-IRC'
  4
+
  5
+group :testing do
  6
+  gem 'rspec'
  7
+end
  8
+
  9
+group :development do
  10
+  gem 'rake'
  11
+end
12  Gemfile.lock
@@ -2,9 +2,21 @@ GEM
2 2
   remote: http://rubygems.org/
3 3
   specs:
4 4
     Ruby-IRC (1.0.13)
  5
+    diff-lcs (1.1.3)
  6
+    rake (0.9.2.2)
  7
+    rspec (2.10.0)
  8
+      rspec-core (~> 2.10.0)
  9
+      rspec-expectations (~> 2.10.0)
  10
+      rspec-mocks (~> 2.10.0)
  11
+    rspec-core (2.10.1)
  12
+    rspec-expectations (2.10.0)
  13
+      diff-lcs (~> 1.1.3)
  14
+    rspec-mocks (2.10.1)
5 15
 
6 16
 PLATFORMS
7 17
   ruby
8 18
 
9 19
 DEPENDENCIES
10 20
   Ruby-IRC
  21
+  rake
  22
+  rspec
8  Rakefile
... ...
@@ -0,0 +1,8 @@
  1
+require 'rspec/core/rake_task'
  2
+
  3
+task :default => [:test]
  4
+
  5
+desc "Run all tests"
  6
+RSpec::Core::RakeTask.new(:test) do |t|
  7
+  t.rspec_opts = '-cfs'
  8
+end
15  spec/parser_spec.rb
... ...
@@ -0,0 +1,15 @@
  1
+require 'spec_helper'
  2
+
  3
+describe "Dudley::DiceParser" do
  4
+  it "should correctly parse simply dice rolls" do
  5
+    result = Dudley::DiceParser.parse("1d6")
  6
+    result.should be >= 1
  7
+    result.should be <= 6
  8
+  end
  9
+
  10
+  it "should correctly parse simply dice rolls with modifier" do
  11
+    result = Dudley::DiceParser.parse("1d6 + 1")
  12
+    result.should be >= 2
  13
+    result.should be <= 7
  14
+  end
  15
+end
4  spec/spec_helper.rb
... ...
@@ -0,0 +1,4 @@
  1
+require File.dirname(__FILE__) + '/../lib/dudley'
  2
+
  3
+# Include support files
  4
+Dir[File.dirname(__FILE__) + '/support/*.rb'].each { |file| require file }

0 notes on commit e233683

Please sign in to comment.
Something went wrong with that request. Please try again.