quick_shoulda 0.0.7 → 0.0.8

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,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.2"
4
+ - "1.9.3"
5
+ # uncomment this line if your project needs to run something other than `rake`:
6
+ script: bundle exec rspec spec
data/README.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- = QuickShoulda
1
+ = QuickShoulda {<img src="https://badge.fury.io/rb/quick_shoulda.png" alt="Gem Version" />}[http://badge.fury.io/rb/quick_shoulda]{<img src="https://travis-ci.org/nqtien310/quick_shoulda.png?branch=master" alt="Build Status" />}[https://travis-ci.org/nqtien310/quick_shoulda]
2
2
 
3
3
  A Rails generator which automatically generates Shoulda test cases ,
4
4
 
@@ -0,0 +1,31 @@
1
+ module QuickShoulda
2
+ module RandomString
3
+ module Data
4
+ StoredStrings = {
5
+ :Emails => ['us@gmail.com', 'us.vn@gmail.com', 'us_vn@gmail.com', 'us_vn@gmail.com.vn'],
6
+ :Urls => ['www.domain.com', 'www.domain.subdomain.com', 'http://www.domain.com', 'http://www.domain.subdomain.com',
7
+ 'http://www.domain.com/path/1', 'https://www.domain.com', 'https://www.domain.subdomain.com', 'domain.subdomain.com',
8
+ 'domain.com/path/1', 'subdomain.domain.com/path/1'],
9
+ :IPS => ['192.168.1.1', '192.168.1.2'],
10
+ :Sex => ['male', 'female', 'gay', 'les', 'other'],
11
+ :Zips => ['10001', '10002', '10003'],
12
+ :Phones => ['732-757-2923', '1732-757-2923', '+84 121731845', '84 121731845', '(84) 121731845'],
13
+ :Datetimes => ['1999-01-01', '99-01-01', '1999/01/01', '99/01/01', '01/01/99', '03/10/1986', '01-01-1999', '01-01-99', 'January 07, 2013',
14
+ 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday',
15
+ 'january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december',
16
+ 'am', 'pm'],
17
+ :Countries => ['Vietnam', 'America', 'England', 'Vietnamese', 'American', 'English'],
18
+ :Cities => ['New York', 'London', 'Ho Chi Minh'],
19
+ :Statuses => ['married', 'single', 'available', 'complicated'],
20
+ :Files => ['filename.txt', 'filename.jpg', 'filename.png', 'filename.jpeg'],
21
+ :Extensions => ['txt', 'jpg', 'png', 'jpeg', 'mp4', 'mp3', 'wmv'],
22
+ :Videos => ['filename.wmv', 'filename.mp4', 'filename.flv'],
23
+ :CCNumbers => ['4111 1111 1111 1111', '5500 0000 0000 0004', '3400 0000 0000 009', '3000 0000 0000 04'],
24
+ :CCodes => ['84', '1', '39'],
25
+ :ISOCCodes => ['US', 'USA', 'VN', 'VNM'],
26
+ :Services => ['yahoo', 'google', 'facebook', 'amazone', 'youtube', 'paypal', 'alchemy'],
27
+ :Marks => ['excellent', 'good', 'bad']
28
+ }
29
+ end
30
+ end
31
+ end
@@ -1,5 +1,7 @@
1
+ require 'quick_shoulda/random_string/data'
2
+
1
3
  module QuickShoulda
2
- class RandomString
4
+ module RandomString
3
5
  class << self
4
6
  Size = 3
5
7
  LowerCaseChars = ('a'..'z').to_a
@@ -10,8 +12,8 @@ module QuickShoulda
10
12
  stored_strings + random_digits_strings + random_chars_strings
11
13
  end
12
14
 
13
- def stored_strings
14
- @stored_strings ||= YAML.load File.new(File.join(File.dirname(__FILE__),'..','..','data','stored_strings.yml'))
15
+ def stored_strings
16
+ @stored_strings ||= Data::StoredStrings.values.flatten
15
17
  end
16
18
 
17
19
  def random_digits_strings
@@ -1,3 +1,3 @@
1
1
  module QuickShoulda
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -65,13 +65,14 @@ describe 'QuickShoulda::FileWriter' do
65
65
  end
66
66
 
67
67
  let(:file_path) { 'spec/fixtures/user_spec.rb' }
68
-
69
68
  [:association, :validation].each do |block_name|
69
+
70
70
  it "should clear the whole #{block_name} block" do
71
71
  block = block_describe_header(block_name)
72
- ( IO.read(file_path) =~ /#{block}\n.+\n.+\n\tend/ ).should_not be_nil
72
+ block_regex = /#{block}\n.+\n\tend/
73
+ ( IO.read(file_path) =~ block_regex ).should_not be_nil
73
74
  clear_block(block)
74
- ( IO.read(file_path) =~ /#{block}\n.+\n.+\n\tend/ ).should be_nil
75
+ ( IO.read(file_path) =~ block_regex ).should be_nil
75
76
  end
76
77
  end
77
78
  end
@@ -1,11 +1,9 @@
1
1
  describe 'User', :test => true do
2
2
  describe '#Associations' do
3
- it { should have_many(:attr1) }
4
- it { should have_many(:attr2) }
3
+ #There's nothing here
5
4
  end
6
5
 
7
6
  describe '#Validations' do
8
- it { should validate_presence_of(:user) }
9
- it { should validate_presence_of(:password) }
7
+ #There's nothing here also
10
8
  end
11
9
  end
@@ -6,6 +6,7 @@ describe "QuickShoulda::RandomString" do
6
6
  describe ".stored_strings" do
7
7
  it 'should return an array of string' do
8
8
  subject.stored_strings.should be_an Array
9
+ subject.stored_strings.should_not be_empty
9
10
  end
10
11
  end
11
12
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quick_shoulda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -56,11 +56,11 @@ files:
56
56
  - .rdebugrc
57
57
  - .rspec
58
58
  - .rvmrc
59
+ - .travis.yml
59
60
  - Gemfile
60
61
  - LICENSE.txt
61
62
  - README.rdoc
62
63
  - Rakefile
63
- - data/stored_strings.yml
64
64
  - lib/generators/quick_shoulda/g_generator.rb
65
65
  - lib/quick_shoulda.rb
66
66
  - lib/quick_shoulda/config.rb
@@ -74,6 +74,7 @@ files:
74
74
  - lib/quick_shoulda/main.rb
75
75
  - lib/quick_shoulda/path_resolver.rb
76
76
  - lib/quick_shoulda/random_string.rb
77
+ - lib/quick_shoulda/random_string/data.rb
77
78
  - lib/quick_shoulda/version.rb
78
79
  - quick_shoulda.gemspec
79
80
  - spec/file_writer_spec.rb
@@ -1,44 +0,0 @@
1
- [
2
- #URLs
3
- 'www.domain.com', 'www.domain.subdomain.com', 'http://www.domain.com', 'http://www.domain.subdomain.com',
4
- 'http://www.domain.com/path/1', 'https://www.domain.com', 'https://www.domain.subdomain.com', 'domain.subdomain.com',
5
- 'domain.com/path/1', 'subdomain.domain.com/path/1',
6
- #Emails
7
- 'us@gmail.com', 'us.vn@gmail.com', 'us_vn@gmail.com', 'us_vn@gmail.com.vn',
8
- #IPS
9
- '192.168.1.1', '192.168.1.2',
10
- #Sex
11
- 'male', 'female', 'gay', 'les', 'other',
12
- #Zip postal code
13
- '10001', '10002', '10003',
14
- #Phone numbers
15
- '732-757-2923', '1732-757-2923',
16
- #datestimes
17
- '1999-01-01', '99-01-01', '1999/01/01', '99/01/01', '01/01/99', '03/10/1986', '01-01-1999', '01-01-99', 'January 07, 2013',
18
- 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday',
19
- 'january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december',
20
- 'am', 'pm',
21
- #countries
22
- 'Vietnam', 'America', 'England',
23
- 'Vietnamese', 'American', 'English',
24
- #cities
25
- 'New York', 'London', 'Ho Chi Minh',
26
- #Status
27
- 'married', 'single', 'available', 'complicated',
28
- #Files
29
- 'filename.txt', 'filename.jpg', 'filename.png', 'filename.jpeg',
30
- #Extensions
31
- 'txt', 'jpg', 'png', 'jpeg', 'mp4', 'mp3', 'wmv',
32
- #Videos
33
- 'filename.wmv', 'filename.mp4', 'filename.flv',
34
- #credit cards number
35
- '4111 1111 1111 1111', '5500 0000 0000 0004', '3400 0000 0000 009', '3000 0000 0000 04', '+84 121731845', '84 121731845', '(84) 121731845',
36
- #some countries code
37
- '84', '1', '39',
38
- #ISO countries code
39
- 'US', 'USA', 'VN', 'VNM',
40
- #services'
41
- 'yahoo', 'google', 'facebook', 'amazone', 'youtube', 'paypal', 'alchemy',
42
- #marks
43
- 'excellent', 'good', 'bad'
44
- ]