Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yasuhiro Asaka
authored and
Yasuhiro Asaka
committed
Aug 26, 2013
1 parent
dcc9fc6
commit c0c879c
Showing
4 changed files
with
162 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
*~ | ||
*# | ||
.ruby-version | ||
.bundle | ||
ausgabe.csv | ||
mechanize/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# encoding : utf-8 | ||
|
||
require "spec_helper" | ||
load File.expand_path("../../bin/brand2csv", __FILE__) | ||
|
||
describe Brand2csv do | ||
describe "#validates_timespan" do | ||
subject { validates_timespan(arg) } | ||
|
||
context "when timespan is a single date" do | ||
context "when invalid last day of month in a date is given" do | ||
let(:arg) { "29.02.2010" } | ||
it { should eql [false, "Did you mean 28.02.2010 ?"] } | ||
end | ||
|
||
context "when invalid month in a date is given" do | ||
let(:arg) { "28.13.2010" } | ||
it { should eql [false, "Timespan is invalid"] } | ||
end | ||
|
||
context "when a valid date is given" do | ||
let(:arg) { "31.12.2010" } | ||
it { should eql [true, nil] } | ||
end | ||
end | ||
|
||
context "when timespan is term" do | ||
context "when invalid last day of month in start date is given" do | ||
let(:arg) { "29.02.2010-31.03.2010" } | ||
it { should eql [false, "Did you mean 28.02.2010-31.03.2010 ?"] } | ||
end | ||
|
||
context "when invalid last day of month in end date is given" do | ||
let(:arg) { "28.04.2010-99.03.2010" } | ||
it { should eql [false, "Did you mean 28.04.2010-31.03.2010 ?"] } | ||
end | ||
|
||
context "when invalid last day of month in both dates is given" do | ||
let(:arg) { "32.01.2010-99.05.2010" } | ||
it { should eql [false, "Did you mean 31.01.2010-31.05.2010 ?"] } | ||
end | ||
|
||
context "when invalid month in start date is given" do | ||
let(:arg) { "31.99.2010-31.05.2010" } | ||
it { should eql [false, "Timespan is invalid"] } | ||
end | ||
|
||
context "when invalid month in end date is given" do | ||
let(:arg) { "31.01.2010-31.20.2010" } | ||
it { should eql [false, "Timespan is invalid"] } | ||
end | ||
|
||
context "when invalid month in both dates is given" do | ||
let(:arg) { "31.30.2010-31.20.2010" } | ||
it { should eql [false, "Timespan is invalid"] } | ||
end | ||
|
||
context "when valid term is given" do | ||
let(:arg) { "28.02.2010-31.05.2010" } | ||
it { should eql [true, nil] } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# encoding: utf-8 | ||
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib') | ||
$:.unshift File.dirname(__FILE__) | ||
|
||
require 'bundler/setup' | ||
Bundler.require | ||
|
||
require 'rspec' | ||
require 'brand2csv' | ||
|
||
Dir[File.join(File.dirname(__FILE__), "spec/support/**/*.rb")].each { |f| require f } | ||
|
||
RSpec.configure do |config| | ||
config.treat_symbols_as_metadata_keys_with_true_values = true | ||
config.run_all_when_everything_filtered = true | ||
config.filter_run :focus | ||
config.filter_run_excluding :slow | ||
#config.exclusion_filter = {:slow => true} | ||
|
||
# Run specs in random order to surface order dependencies. If you find an | ||
# order dependency and want to debug it, you can fix the order by providing | ||
# the seed, which is printed after each run. | ||
# --seed 1234 | ||
config.order = 'random' | ||
end |