Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/not operator #48

Merged
merged 3 commits into from
Sep 21, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## master
[full changelog](http://github.com/sue445/rubicure/compare/v0.1.2...master)

* Impl: `!Cure.passion`, `!Cure.beat`
* https://github.com/sue445/rubicure/pull/48

## v0.1.2
[full changelog](http://github.com/sue445/rubicure/compare/v0.1.1...v0.1.2)

Expand Down
30 changes: 1 addition & 29 deletions lib/rubicure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
require "rubicure/girl"
require "rubicure/core"
require "rubicure/movie"
require "rubicure/cure"

module Rubicure
def self.core
Expand All @@ -20,35 +21,6 @@ def self.method_missing(name, *args, &block)
end
end

module Cure
def self.method_missing(name, *args)
if Rubicure::Girl.valid?(name)
Rubicure::Girl.find(name)
else
super
end
end

[Cure.peace, Cure.cure_peace].each do |peace|
class << peace
HANDS =
(['グー'] * 13) +
(['チョキ'] * 14) +
(['パー'] * 15) +
['グッチョッパー']
MESSAGE = <<EOF
ピカピカピカリン
ジャンケンポン!
(%s)
EOF
def pikarin_janken
print_by_line(MESSAGE % HANDS.sample)
end
alias janken pikarin_janken
end
end
end

module Shiny
def self.luminous
Rubicure::Girl.find(:luminous)
Expand Down
64 changes: 64 additions & 0 deletions lib/rubicure/cure.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
module Cure
def self.method_missing(name, *args)
if Rubicure::Girl.valid?(name)
Rubicure::Girl.find(name)
else
super
end
end

[Cure.peace, Cure.cure_peace].each do |peace|
class << peace
HANDS =
(['グー'] * 13) +
(['チョキ'] * 14) +
(['パー'] * 15) +
['グッチョッパー']
MESSAGE = <<EOF
ピカピカピカリン
ジャンケンポン!
(%s)
EOF
def pikarin_janken
print_by_line(MESSAGE % HANDS.sample)
end
alias janken pikarin_janken
end
end

[Cure.passion, Cure.cure_passion].each do |passion|
class << passion
ORIGINAL_HUMAN_NAME = "東せつな"
ANOTHER_HUMAN_NAME = "イース"

def !
humanize
@another_human_name ||= ANOTHER_HUMAN_NAME
@state_names[0], @another_human_name = @another_human_name, @state_names[0]
end

def rollback
@state_names[0] = ORIGINAL_HUMAN_NAME
@another_human_name = ANOTHER_HUMAN_NAME
end
end
end

[Cure.beat, Cure.cure_beat].each do |beat|
class << beat
ORIGINAL_HUMAN_NAME = "黒川エレン"
ANOTHER_HUMAN_NAME = "セイレーン"

def !
humanize
@another_human_name ||= ANOTHER_HUMAN_NAME
@state_names[0], @another_human_name = @another_human_name, @state_names[0]
end

def rollback
@state_names[0] = ORIGINAL_HUMAN_NAME
@another_human_name = ANOTHER_HUMAN_NAME
end
end
end
end
87 changes: 87 additions & 0 deletions spec/cure_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
describe "Cure" do
describe ".peace" do
describe "#pikarin_janken" do
subject{ girl.pikarin_janken }

shared_examples :do_janken do
it{ should match %r/ピカピカピカリン\nジャンケンポン!\n(.+)/ }
end

context "When peace" do
let(:girl){ Cure.peace }
it_behaves_like :do_janken
end

context "When cure_peace" do
let(:girl){ Cure.cure_peace }
it_behaves_like :do_janken
end
end
end

describe ".passion" do
describe "!" do
subject{ !Cure.passion }

let(:girl){ Cure.passion }

after do
girl.rollback
girl.humanize
end

context "called once" do
it{ expect{ subject }.to change{ girl.name }.from("東せつな").to("イース") }
end

context "called twice" do
before do
!Cure.passion
end

it{ expect{ subject }.to change{ girl.name }.from("イース").to("東せつな") }
end

context "after transform" do
before do
girl.transform!
end

it{ expect{ subject }.to change{ girl.name }.from("キュアパッション").to("イース") }
end
end
end

describe ".beat" do
describe "!" do
subject{ !Cure.beat }

let(:girl){ Cure.beat }

after do
girl.rollback
girl.humanize
end

context "called once" do
it{ expect{ subject }.to change{ girl.name }.from("黒川エレン").to("セイレーン") }
end

context "called twice" do
before do
!Cure.beat
end

it{ expect{ subject }.to change{ girl.name }.from("セイレーン").to("黒川エレン") }
end

context "after transform" do
before do
girl.transform!
end

it{ expect{ subject }.to change{ girl.name }.from("キュアビート").to("セイレーン") }
end
end
end
end
18 changes: 0 additions & 18 deletions spec/rubicure_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,4 @@
it { expect( Milky.rose.precure_name ).to eq "ミルキィローズ" }
end
end

describe "#pikarin_janken" do
subject{ girl.pikarin_janken }

shared_examples :do_janken do
it{ should match %r/ピカピカピカリン\nジャンケンポン!\n(.+)/ }
end

context "When peace" do
let(:girl){ Cure.peace }
it_behaves_like :do_janken
end

context "When cure_peace" do
let(:girl){ Cure.cure_peace }
it_behaves_like :do_janken
end
end
end